mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
backend: force initial mmap size to 0 for windows
boltdb on windows allocates a file with the full mmap size even if the db is empty. Force the initial mmap size to 0 so there's no huge initial db file on windows. Fixes #7910
This commit is contained in:
parent
6ce9aed8c5
commit
8516d8ccc5
@ -124,7 +124,7 @@ func newBackend(bcfg BackendConfig) *backend {
|
||||
if boltOpenOptions != nil {
|
||||
*bopts = *boltOpenOptions
|
||||
}
|
||||
bopts.InitialMmapSize = int(bcfg.MmapSize)
|
||||
bopts.InitialMmapSize = bcfg.mmapSize()
|
||||
|
||||
db, err := bolt.Open(bcfg.Path, 0600, bopts)
|
||||
if err != nil {
|
||||
|
@ -12,10 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build !linux
|
||||
// +build !linux,!windows
|
||||
|
||||
package backend
|
||||
|
||||
import "github.com/boltdb/bolt"
|
||||
|
||||
var boltOpenOptions *bolt.Options = nil
|
||||
|
||||
func (bcfg *BackendConfig) mmapSize() int { return int(bcfg.MmapSize) }
|
@ -29,3 +29,5 @@ import (
|
||||
var boltOpenOptions = &bolt.Options{
|
||||
MmapFlags: syscall.MAP_POPULATE,
|
||||
}
|
||||
|
||||
func (bcfg *BackendConfig) mmapSize() int { return int(bcfg.MmapSize) }
|
26
mvcc/backend/config_windows.go
Normal file
26
mvcc/backend/config_windows.go
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2017 The etcd Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build windows
|
||||
|
||||
package backend
|
||||
|
||||
import "github.com/boltdb/bolt"
|
||||
|
||||
var boltOpenOptions *bolt.Options = nil
|
||||
|
||||
// setting mmap size != 0 on windows will allocate the entire
|
||||
// mmap size for the file, instead of growing it. So, force 0.
|
||||
|
||||
func (bcfg *BackendConfig) mmapSize() int { return 0 }
|
Loading…
x
Reference in New Issue
Block a user