Skip to content

Commit 8a350ac

Browse files
committed
Add a feature flag for disabling erase cache
1 parent e432d9c commit 8a350ac

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

ydb/core/protos/feature_flags.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,5 @@ message TFeatureFlags {
183183
optional bool EnableVDiskThrottling = 158 [default = false];
184184
optional bool EnableDataShardInMemoryStateMigration = 159 [default = true];
185185
optional bool EnableDataShardInMemoryStateMigrationAcrossGenerations = 160 [default = false];
186+
optional bool DisableLocalDBEraseCache = 161 [default = false];
186187
}

ydb/core/tx/datashard/datashard_user_table.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,9 @@ void TUserTable::DoApplyCreate(
484484
alter.SetExecutorFastLogPolicy(partConfig.GetExecutorFastLogPolicy());
485485
}
486486

487-
alter.SetEraseCache(tid, partConfig.GetEnableEraseCache(), partConfig.GetEraseCacheMinRows(), partConfig.GetEraseCacheMaxBytes());
487+
if (!AppData().FeatureFlags.GetDisableEraseCache()) {
488+
alter.SetEraseCache(tid, partConfig.GetEnableEraseCache(), partConfig.GetEraseCacheMinRows(), partConfig.GetEraseCacheMaxBytes());
489+
}
488490

489491
if (IsBackup) {
490492
alter.SetColdBorrow(tid, true);
@@ -630,7 +632,9 @@ void TUserTable::ApplyAlter(
630632
if (configDelta.HasEraseCacheMaxBytes()) {
631633
config.SetEraseCacheMaxBytes(configDelta.GetEraseCacheMaxBytes());
632634
}
633-
alter.SetEraseCache(LocalTid, config.GetEnableEraseCache(), config.GetEraseCacheMinRows(), config.GetEraseCacheMaxBytes());
635+
if (!AppData().FeatureFlags.GetDisableEraseCache()) {
636+
alter.SetEraseCache(LocalTid, config.GetEnableEraseCache(), config.GetEraseCacheMinRows(), config.GetEraseCacheMaxBytes());
637+
}
634638
}
635639

636640
schema.SetTableSchemaVersion(delta.GetTableSchemaVersion());
@@ -650,12 +654,19 @@ void TUserTable::ApplyDefaults(TTransactionContext& txc) const
650654
GetSchema(schema);
651655
const auto& config = schema.GetPartitionConfig();
652656

653-
if ((!config.HasEnableEraseCache() && config.GetEnableEraseCache() != tableInfo->EraseCacheEnabled) ||
654-
(config.GetEnableEraseCache() && !config.HasEraseCacheMinRows() && config.GetEraseCacheMinRows() != tableInfo->EraseCacheMinRows) ||
655-
(config.GetEnableEraseCache() && !config.HasEraseCacheMaxBytes() && config.GetEraseCacheMaxBytes() != tableInfo->EraseCacheMaxBytes))
656-
{
657-
// Protobuf defaults for erase cache changed, apply to local database
658-
txc.DB.Alter().SetEraseCache(LocalTid, config.GetEnableEraseCache(), config.GetEraseCacheMinRows(), config.GetEraseCacheMaxBytes());
657+
if (AppData().FeatureFlags.GetDisableEraseCache()) {
658+
// Erase cache was disabled, make sure it is disabled in the schema as well
659+
if (tableInfo->EraseCacheEnabled) {
660+
txc.DB.Alter().SetEraseCache(LocalTid, false, 0, 0);
661+
}
662+
} else {
663+
// Erase cache not disabled, make sure current settings are re-applied
664+
if ((config.GetEnableEraseCache() != tableInfo->EraseCacheEnabled) ||
665+
(config.GetEnableEraseCache() && config.GetEraseCacheMinRows() != tableInfo->EraseCacheMinRows) ||
666+
(config.GetEnableEraseCache() && config.GetEraseCacheMaxBytes() != tableInfo->EraseCacheMaxBytes))
667+
{
668+
txc.DB.Alter().SetEraseCache(LocalTid, config.GetEnableEraseCache(), config.GetEraseCacheMinRows(), config.GetEraseCacheMaxBytes());
669+
}
659670
}
660671
}
661672

0 commit comments

Comments
 (0)