Skip to content

Commit 8fbb0bd

Browse files
feat(mutations): gate per-predicate pipeline behind a feature flag
Replace the hardcoded \`featureFlag := true\` in applyMutations with a real superflag knob, defaulted off: - Add WorkerOptions.MutationsUsePipeline (bool) in x/config.go. - Extend the feature-flags superflag with mutations-use-pipeline=false and wire alpha to populate WorkerConfig.MutationsUsePipeline from it. - worker/draft.go applyMutations now branches on x.WorkerConfig.MutationsUsePipeline; default false routes mutations through the legacy path, preserving current behavior. Tests can opt into the new pipeline by setting x.WorkerConfig.MutationsUsePipeline = true. CLI usage: dgraph alpha --feature-flags="mutations-use-pipeline=true" Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 4fe27e1 commit 8fbb0bd

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

dgraph/cmd/alpha/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ func run() {
796796
x.Config.NormalizeCompatibilityMode = featureFlagsConf.GetString("normalize-compatibility-mode")
797797
enableDetailedMetrics := featureFlagsConf.GetBool("enable-detailed-metrics")
798798
x.WorkerConfig.SlowQueryLogThreshold = featureFlagsConf.GetDuration("log-slow-query-threshold")
799+
x.WorkerConfig.MutationsUsePipeline = featureFlagsConf.GetBool("mutations-use-pipeline")
799800

800801
x.PrintVersion()
801802
glog.Infof("x.Config: %+v", x.Config)

worker/draft.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ func (n *node) applyMutations(ctx context.Context, proposal *pb.Proposal) (rerr
526526
// Discard the posting lists from cache to release memory at the end.
527527
defer txn.Update()
528528

529-
featureFlag := true
530-
if featureFlag {
529+
if x.WorkerConfig.MutationsUsePipeline {
531530
mp := posting.NewMutationPipeline(txn)
532531
return mp.Process(ctx, m.Edges)
533532
}

worker/server_state.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const (
4242
GraphQLDefaults = `introspection=true; debug=false; extensions=true; poll-interval=1s; ` +
4343
`lambda-url=;`
4444
CacheDefaults = `size-mb=4096; percentage=40,40,20; remove-on-update=false`
45-
FeatureFlagsDefaults = `normalize-compatibility-mode=; enable-detailed-metrics=false; log-slow-query-threshold=0`
45+
FeatureFlagsDefaults = `normalize-compatibility-mode=; enable-detailed-metrics=false; ` +
46+
`log-slow-query-threshold=0; mutations-use-pipeline=false`
4647
)
4748

4849
// ServerState holds the state of the Dgraph server.

x/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ type WorkerOptions struct {
138138
HardSync bool
139139
// Audit contains the audit flags that enables the audit.
140140
Audit bool
141+
// MutationsUsePipeline enables the per-predicate mutation pipeline in
142+
// applyMutations. When false (default), mutations follow the legacy
143+
// serial path. The flag is plumbed via the "feature-flags" superflag.
144+
MutationsUsePipeline bool
141145
}
142146

143147
// WorkerConfig stores the global instance of the worker package's options.

0 commit comments

Comments
 (0)