mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: add flag to let etcd use the new boltdb freelistType feature
This commit is contained in:
parent
3e0f0ba40e
commit
e6c6d8492e
@ -408,6 +408,11 @@ Follow the instructions when using these flags.
|
|||||||
|
|
||||||
## Experimental flags
|
## Experimental flags
|
||||||
|
|
||||||
|
### --experimental-backend-bbolt-freelist-type
|
||||||
|
+ The freelist type that etcd backend(bboltdb) uses (array and map are supported types).
|
||||||
|
+ default: array
|
||||||
|
+ env variable: ETCD_EXPERIMENTAL_BACKEND_BBOLT_FREELIST_TYPE
|
||||||
|
|
||||||
### --experimental-corrupt-check-time
|
### --experimental-corrupt-check-time
|
||||||
+ Duration of time between cluster corruption check passes
|
+ Duration of time between cluster corruption check passes
|
||||||
+ default: 0s
|
+ default: 0s
|
||||||
|
@ -37,6 +37,7 @@ import (
|
|||||||
"go.etcd.io/etcd/pkg/types"
|
"go.etcd.io/etcd/pkg/types"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
|
bolt "go.etcd.io/bbolt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
@ -75,6 +76,8 @@ const (
|
|||||||
// maxElectionMs specifies the maximum value of election timeout.
|
// maxElectionMs specifies the maximum value of election timeout.
|
||||||
// More details are listed in ../Documentation/tuning.md#time-parameters.
|
// More details are listed in ../Documentation/tuning.md#time-parameters.
|
||||||
maxElectionMs = 50000
|
maxElectionMs = 50000
|
||||||
|
// backend freelist map type
|
||||||
|
freelistMapType = "map"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -273,6 +276,8 @@ type Config struct {
|
|||||||
ExperimentalInitialCorruptCheck bool `json:"experimental-initial-corrupt-check"`
|
ExperimentalInitialCorruptCheck bool `json:"experimental-initial-corrupt-check"`
|
||||||
ExperimentalCorruptCheckTime time.Duration `json:"experimental-corrupt-check-time"`
|
ExperimentalCorruptCheckTime time.Duration `json:"experimental-corrupt-check-time"`
|
||||||
ExperimentalEnableV2V3 string `json:"experimental-enable-v2v3"`
|
ExperimentalEnableV2V3 string `json:"experimental-enable-v2v3"`
|
||||||
|
// ExperimentalBackendFreelistType specifies the type of freelist that boltdb backend uses (array and map are supported types).
|
||||||
|
ExperimentalBackendFreelistType string `json:"experimental-backend-bbolt-freelist-type"`
|
||||||
|
|
||||||
// ForceNewCluster starts a new cluster even if previously started; unsafe.
|
// ForceNewCluster starts a new cluster even if previously started; unsafe.
|
||||||
ForceNewCluster bool `json:"force-new-cluster"`
|
ForceNewCluster bool `json:"force-new-cluster"`
|
||||||
@ -896,3 +901,11 @@ func (cfg *Config) getMetricsURLs() (ss []string) {
|
|||||||
}
|
}
|
||||||
return ss
|
return ss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseBackendFreelistType(freelistType string) bolt.FreelistType {
|
||||||
|
if freelistType == freelistMapType {
|
||||||
|
return bolt.FreelistMapType
|
||||||
|
}
|
||||||
|
|
||||||
|
return bolt.FreelistArrayType
|
||||||
|
}
|
||||||
|
@ -159,6 +159,8 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
|||||||
return e, err
|
return e, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backendFreelistType := parseBackendFreelistType(cfg.ExperimentalBackendFreelistType)
|
||||||
|
|
||||||
srvcfg := etcdserver.ServerConfig{
|
srvcfg := etcdserver.ServerConfig{
|
||||||
Name: cfg.Name,
|
Name: cfg.Name,
|
||||||
ClientURLs: cfg.ACUrls,
|
ClientURLs: cfg.ACUrls,
|
||||||
@ -182,6 +184,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
|||||||
AutoCompactionMode: cfg.AutoCompactionMode,
|
AutoCompactionMode: cfg.AutoCompactionMode,
|
||||||
QuotaBackendBytes: cfg.QuotaBackendBytes,
|
QuotaBackendBytes: cfg.QuotaBackendBytes,
|
||||||
BackendBatchLimit: cfg.BackendBatchLimit,
|
BackendBatchLimit: cfg.BackendBatchLimit,
|
||||||
|
BackendFreelistType: backendFreelistType,
|
||||||
BackendBatchInterval: cfg.BackendBatchInterval,
|
BackendBatchInterval: cfg.BackendBatchInterval,
|
||||||
MaxTxnOps: cfg.MaxTxnOps,
|
MaxTxnOps: cfg.MaxTxnOps,
|
||||||
MaxRequestBytes: cfg.MaxRequestBytes,
|
MaxRequestBytes: cfg.MaxRequestBytes,
|
||||||
|
@ -248,6 +248,7 @@ func newConfig() *config {
|
|||||||
fs.BoolVar(&cfg.ec.ExperimentalInitialCorruptCheck, "experimental-initial-corrupt-check", cfg.ec.ExperimentalInitialCorruptCheck, "Enable to check data corruption before serving any client/peer traffic.")
|
fs.BoolVar(&cfg.ec.ExperimentalInitialCorruptCheck, "experimental-initial-corrupt-check", cfg.ec.ExperimentalInitialCorruptCheck, "Enable to check data corruption before serving any client/peer traffic.")
|
||||||
fs.DurationVar(&cfg.ec.ExperimentalCorruptCheckTime, "experimental-corrupt-check-time", cfg.ec.ExperimentalCorruptCheckTime, "Duration of time between cluster corruption check passes.")
|
fs.DurationVar(&cfg.ec.ExperimentalCorruptCheckTime, "experimental-corrupt-check-time", cfg.ec.ExperimentalCorruptCheckTime, "Duration of time between cluster corruption check passes.")
|
||||||
fs.StringVar(&cfg.ec.ExperimentalEnableV2V3, "experimental-enable-v2v3", cfg.ec.ExperimentalEnableV2V3, "v3 prefix for serving emulated v2 state.")
|
fs.StringVar(&cfg.ec.ExperimentalEnableV2V3, "experimental-enable-v2v3", cfg.ec.ExperimentalEnableV2V3, "v3 prefix for serving emulated v2 state.")
|
||||||
|
fs.StringVar(&cfg.ec.ExperimentalBackendFreelistType, "experimental-backend-bbolt-freelist-type", cfg.ec.ExperimentalBackendFreelistType, "ExperimentalBackendFreelistType specifies the type of freelist that boltdb backend uses(array and map are supported types)")
|
||||||
|
|
||||||
// unsafe
|
// unsafe
|
||||||
fs.BoolVar(&cfg.ec.ForceNewCluster, "force-new-cluster", false, "Force to create a new one member cluster.")
|
fs.BoolVar(&cfg.ec.ForceNewCluster, "force-new-cluster", false, "Force to create a new one member cluster.")
|
||||||
|
@ -200,6 +200,8 @@ Experimental feature:
|
|||||||
Duration of time between cluster corruption check passes.
|
Duration of time between cluster corruption check passes.
|
||||||
--experimental-enable-v2v3 ''
|
--experimental-enable-v2v3 ''
|
||||||
Serve v2 requests through the v3 backend under a given prefix.
|
Serve v2 requests through the v3 backend under a given prefix.
|
||||||
|
--experimental-backend-bbolt-freelist-type
|
||||||
|
ExperimentalBackendFreelistType specifies the type of freelist that boltdb backend uses(array and map are supported types).
|
||||||
|
|
||||||
Unsafe feature:
|
Unsafe feature:
|
||||||
--force-new-cluster 'false'
|
--force-new-cluster 'false'
|
||||||
|
@ -43,6 +43,7 @@ func newBackend(cfg ServerConfig) backend.Backend {
|
|||||||
cfg.Logger.Info("setting backend batch interval", zap.Duration("batch interval", cfg.BackendBatchInterval))
|
cfg.Logger.Info("setting backend batch interval", zap.Duration("batch interval", cfg.BackendBatchInterval))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bcfg.BackendFreelistType = cfg.BackendFreelistType
|
||||||
bcfg.Logger = cfg.Logger
|
bcfg.Logger = cfg.Logger
|
||||||
if cfg.QuotaBackendBytes > 0 && cfg.QuotaBackendBytes != DefaultQuotaBytes {
|
if cfg.QuotaBackendBytes > 0 && cfg.QuotaBackendBytes != DefaultQuotaBytes {
|
||||||
// permit 10% excess over quota for disarm
|
// permit 10% excess over quota for disarm
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"go.etcd.io/etcd/pkg/transport"
|
"go.etcd.io/etcd/pkg/transport"
|
||||||
"go.etcd.io/etcd/pkg/types"
|
"go.etcd.io/etcd/pkg/types"
|
||||||
|
|
||||||
|
bolt "go.etcd.io/bbolt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
@ -60,6 +61,9 @@ type ServerConfig struct {
|
|||||||
// BackendBatchLimit is the maximum operations before commit the backend transaction.
|
// BackendBatchLimit is the maximum operations before commit the backend transaction.
|
||||||
BackendBatchLimit int
|
BackendBatchLimit int
|
||||||
|
|
||||||
|
// BackendFreelistType is the type of the backend boltdb freelist.
|
||||||
|
BackendFreelistType bolt.FreelistType
|
||||||
|
|
||||||
InitialPeerURLsMap types.URLsMap
|
InitialPeerURLsMap types.URLsMap
|
||||||
InitialClusterToken string
|
InitialClusterToken string
|
||||||
NewCluster bool
|
NewCluster bool
|
||||||
|
@ -110,6 +110,8 @@ type BackendConfig struct {
|
|||||||
BatchInterval time.Duration
|
BatchInterval time.Duration
|
||||||
// BatchLimit is the maximum puts before flushing the BatchTx.
|
// BatchLimit is the maximum puts before flushing the BatchTx.
|
||||||
BatchLimit int
|
BatchLimit int
|
||||||
|
// BackendFreelistType is the backend boltdb's freelist type.
|
||||||
|
BackendFreelistType bolt.FreelistType
|
||||||
// MmapSize is the number of bytes to mmap for the backend.
|
// MmapSize is the number of bytes to mmap for the backend.
|
||||||
MmapSize uint64
|
MmapSize uint64
|
||||||
// Logger logs backend-side operations.
|
// Logger logs backend-side operations.
|
||||||
@ -140,6 +142,7 @@ func newBackend(bcfg BackendConfig) *backend {
|
|||||||
*bopts = *boltOpenOptions
|
*bopts = *boltOpenOptions
|
||||||
}
|
}
|
||||||
bopts.InitialMmapSize = bcfg.mmapSize()
|
bopts.InitialMmapSize = bcfg.mmapSize()
|
||||||
|
bopts.FreelistType = bcfg.BackendFreelistType
|
||||||
|
|
||||||
db, err := bolt.Open(bcfg.Path, 0600, bopts)
|
db, err := bolt.Open(bcfg.Path, 0600, bopts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user