Skip to content

Commit ad5fac9

Browse files
committed
kvcoord: only allow buffered write read transformations in test builds
These transformations only benefit RC users, but RC buffered writes support is not enabled by default yet. Further, there is currently a known correctness issue related to enabling this feature, so we want an extra layer protection against accidental enablement. Epic: none Release note: None
1 parent e83f9e3 commit ad5fac9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/kv/kvclient/kvcoord/txn_interceptor_write_buffer.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,32 @@ var BufferedWritesEnabled = settings.RegisterBoolSetting(
4444
settings.WithPublic,
4545
)
4646

47+
var unsupportedInProductionBuildErr = errors.New("this option is not supported in production builds")
48+
4749
var bufferedWritesScanTransformEnabled = settings.RegisterBoolSetting(
4850
settings.ApplicationLevel,
4951
"kv.transaction.write_buffering.transformations.scans.enabled",
5052
"if enabled, locking scans and reverse scans with replicated durability are transformed to unreplicated durability",
5153
metamorphic.ConstantWithTestBool("kv.transaction.write_buffering.transformations.scans.enabled", false /* defaultValue */),
54+
settings.WithValidateBool(func(_ *settings.Values, enabled bool) error {
55+
if enabled && !buildutil.CrdbTestBuild {
56+
return unsupportedInProductionBuildErr
57+
}
58+
return nil
59+
}),
5260
)
5361

5462
var bufferedWritesGetTransformEnabled = settings.RegisterBoolSetting(
5563
settings.ApplicationLevel,
5664
"kv.transaction.write_buffering.transformations.get.enabled",
5765
"if enabled, locking get requests with replicated durability are transformed to unreplicated durability",
5866
metamorphic.ConstantWithTestBool("kv.transaction.write_buffering.transformations.get.enabled", false /* defaultValue */),
67+
settings.WithValidateBool(func(_ *settings.Values, enabled bool) error {
68+
if enabled && !buildutil.CrdbTestBuild {
69+
return unsupportedInProductionBuildErr
70+
}
71+
return nil
72+
}),
5973
)
6074

6175
const defaultBufferSize = 1 << 22 // 4MB

0 commit comments

Comments
 (0)