Skip to content

Commit 3faed21

Browse files
committedNov 26, 2018
*: add flags to setup backend related config
1 parent 6c649de commit 3faed21

File tree

7 files changed

+40
-1
lines changed

7 files changed

+40
-1
lines changed
 

‎Documentation/op-guide/configuration.md

+10
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ To start etcd automatically using custom settings at startup in Linux, using a [
8282
+ default: 0
8383
+ env variable: ETCD_QUOTA_BACKEND_BYTES
8484

85+
### --backend-batch-limit
86+
+ BackendBatchLimit is the maximum operations before commit the backend transaction.
87+
+ default: 0
88+
+ env variable: ETCD_BACKEND_BATCH_LIMIT
89+
90+
### --backend-batch-interval
91+
+ BackendBatchInterval is the maximum time before commit the backend transaction.
92+
+ default: 0
93+
+ env variable: ETCD_BACKEND_BATCH_INTERVAL
94+
8595
### --max-txn-ops
8696
+ Maximum number of operations permitted in a transaction.
8797
+ default: 128

‎embed/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ type Config struct {
165165
// See https://github.com/etcd-io/etcd/issues/9333 for more detail.
166166
InitialElectionTickAdvance bool `json:"initial-election-tick-advance"`
167167

168+
// BackendBatchInterval is the maximum time before commit the backend transaction.
169+
BackendBatchInterval time.Duration `json:"backend-batch-interval"`
170+
// BackendBatchLimit is the maximum operations before commit the backend transaction.
171+
BackendBatchLimit int `json:"backend-batch-limit"`
168172
QuotaBackendBytes int64 `json:"quota-backend-bytes"`
169173
MaxTxnOps uint `json:"max-txn-ops"`
170174
MaxRequestBytes uint `json:"max-request-bytes"`

‎embed/etcd.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import (
4343
"go.etcd.io/etcd/version"
4444

4545
"github.com/coreos/pkg/capnslog"
46-
"github.com/grpc-ecosystem/go-grpc-prometheus"
46+
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
4747
"github.com/soheilhy/cmux"
4848
"go.uber.org/zap"
4949
"google.golang.org/grpc"
@@ -181,6 +181,8 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
181181
AutoCompactionRetention: autoCompactionRetention,
182182
AutoCompactionMode: cfg.AutoCompactionMode,
183183
QuotaBackendBytes: cfg.QuotaBackendBytes,
184+
BackendBatchLimit: cfg.BackendBatchLimit,
185+
BackendBatchInterval: cfg.BackendBatchInterval,
184186
MaxTxnOps: cfg.MaxTxnOps,
185187
MaxRequestBytes: cfg.MaxRequestBytes,
186188
StrictReconfigCheck: cfg.StrictReconfigCheck,

‎etcdmain/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ func newConfig() *config {
155155
fs.UintVar(&cfg.ec.ElectionMs, "election-timeout", cfg.ec.ElectionMs, "Time (in milliseconds) for an election to timeout.")
156156
fs.BoolVar(&cfg.ec.InitialElectionTickAdvance, "initial-election-tick-advance", cfg.ec.InitialElectionTickAdvance, "Whether to fast-forward initial election ticks on boot for faster election.")
157157
fs.Int64Var(&cfg.ec.QuotaBackendBytes, "quota-backend-bytes", cfg.ec.QuotaBackendBytes, "Raise alarms when backend size exceeds the given quota. 0 means use the default quota.")
158+
fs.DurationVar(&cfg.ec.BackendBatchInterval, "backend-batch-interval", cfg.ec.BackendBatchInterval, "BackendBatchInterval is the maximum time before commit the backend transaction.")
159+
fs.IntVar(&cfg.ec.BackendBatchLimit, "backend-batch-limit", cfg.ec.BackendBatchLimit, "BackendBatchLimit is the maximum operations before commit the backend transaction.")
158160
fs.UintVar(&cfg.ec.MaxTxnOps, "max-txn-ops", cfg.ec.MaxTxnOps, "Maximum number of operations permitted in a transaction.")
159161
fs.UintVar(&cfg.ec.MaxRequestBytes, "max-request-bytes", cfg.ec.MaxRequestBytes, "Maximum client request size in bytes the server will accept.")
160162
fs.DurationVar(&cfg.ec.GRPCKeepAliveMinTime, "grpc-keepalive-min-time", cfg.ec.GRPCKeepAliveMinTime, "Minimum interval duration that a client should wait before pinging server.")

‎etcdmain/help.go

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Member:
6969
Maximum number of wal files to retain (0 is unlimited).
7070
--quota-backend-bytes '0'
7171
Raise alarms when backend size exceeds the given quota (0 defaults to low space quota).
72+
--backend-batch-interval ''
73+
BackendBatchInterval is the maximum time before commit the backend transaction.
74+
--backend-batch-limit '0'
75+
BackendBatchLimit is the maximum operations before commit the backend transaction.
7276
--max-txn-ops '128'
7377
Maximum number of operations permitted in a transaction.
7478
--max-request-bytes '1572864'

‎etcdserver/backend.go

+12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ import (
3131
func newBackend(cfg ServerConfig) backend.Backend {
3232
bcfg := backend.DefaultBackendConfig()
3333
bcfg.Path = cfg.backendPath()
34+
if cfg.BackendBatchLimit != 0 {
35+
bcfg.BatchLimit = cfg.BackendBatchLimit
36+
if cfg.Logger != nil {
37+
cfg.Logger.Info("setting backend batch limit", zap.Int("batch limit", cfg.BackendBatchLimit))
38+
}
39+
}
40+
if cfg.BackendBatchInterval != 0 {
41+
bcfg.BatchInterval = cfg.BackendBatchInterval
42+
if cfg.Logger != nil {
43+
cfg.Logger.Info("setting backend batch interval", zap.Duration("batch interval", cfg.BackendBatchInterval))
44+
}
45+
}
3446
bcfg.Logger = cfg.Logger
3547
if cfg.QuotaBackendBytes > 0 && cfg.QuotaBackendBytes != DefaultQuotaBytes {
3648
// permit 10% excess over quota for disarm

‎etcdserver/config.go

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ type ServerConfig struct {
5555
MaxSnapFiles uint
5656
MaxWALFiles uint
5757

58+
// BackendBatchInterval is the maximum time before commit the backend transaction.
59+
BackendBatchInterval time.Duration
60+
// BackendBatchLimit is the maximum operations before commit the backend transaction.
61+
BackendBatchLimit int
62+
5863
InitialPeerURLsMap types.URLsMap
5964
InitialClusterToken string
6065
NewCluster bool

0 commit comments

Comments
 (0)
Please sign in to comment.