storage/backend: set initial db size to avoid potential deadlock

This commit is contained in:
Xiang Li 2016-02-05 10:57:51 -08:00
parent 8156a58ba3
commit 26c645f049
2 changed files with 9 additions and 1 deletions

View File

@ -31,6 +31,11 @@ import (
var (
defaultBatchLimit = 10000
defaultBatchInterval = 100 * time.Millisecond
// InitialMmapSize is the initial size of the mmapped region. Setting this larger than
// the potential max db size can prevent writer from blocking reader.
// This only works for linux.
InitialMmapSize = 10 * 1024 * 1024 * 1024
)
type Backend interface {

View File

@ -28,4 +28,7 @@ import (
// package. If your kernel version is lower than 2.6.23
// (https://github.com/torvalds/linux/releases/tag/v2.6.23), mmap might
// silently ignore this flag. Please update your kernel to prevent this.
var boltOpenOptions = &bolt.Options{MmapFlags: syscall.MAP_POPULATE}
var boltOpenOptions = &bolt.Options{
MmapFlags: syscall.MAP_POPULATE,
InitialMmapSize: InitialMmapSize,
}