only add mutations can change configuration (#6760)

This commit is contained in:
Xiaoxi Wang 2022-04-05 17:05:51 -07:00 committed by GitHub
parent dcfb6ee520
commit ce33366396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -660,6 +660,11 @@ void DatabaseConfiguration::applyMutation(MutationRef m) {
} }
} }
bool DatabaseConfiguration::involveMutation(MutationRef m) {
return (m.type == MutationRef::SetValue && m.param1.startsWith(configKeysPrefix)) ||
(m.type == MutationRef::ClearRange && KeyRangeRef(m.param1, m.param2).intersects(configKeys));
}
bool DatabaseConfiguration::set(KeyRef key, ValueRef value) { bool DatabaseConfiguration::set(KeyRef key, ValueRef value) {
makeConfigurationMutable(); makeConfigurationMutable();
mutableConfiguration.get()[key.toString()] = value.toString(); mutableConfiguration.get()[key.toString()] = value.toString();

View File

@ -104,6 +104,8 @@ struct DatabaseConfiguration {
DatabaseConfiguration(); DatabaseConfiguration();
void applyMutation(MutationRef mutation); void applyMutation(MutationRef mutation);
// return true if mutation will cause configuration changes
bool involveMutation(MutationRef mutation);
bool set(KeyRef key, bool set(KeyRef key,
ValueRef value); // Returns true if a configuration option that requires recovery to take effect is changed ValueRef value); // Returns true if a configuration option that requires recovery to take effect is changed
bool clear(KeyRangeRef keys); bool clear(KeyRangeRef keys);

View File

@ -869,7 +869,8 @@ ACTOR Future<Standalone<CommitTransactionRef>> provisionalMaster(Reference<Clust
.detail("MType", m->type) .detail("MType", m->type)
.detail("Param1", m->param1) .detail("Param1", m->param1)
.detail("Param2", m->param2); .detail("Param2", m->param2);
if (isMetadataMutation(*m)) { // emergency transaction only mean to do configuration change
if (parent->configuration.involveMutation(*m)) {
// We keep the mutations and write conflict ranges from this transaction, but not its read // We keep the mutations and write conflict ranges from this transaction, but not its read
// conflict ranges // conflict ranges
Standalone<CommitTransactionRef> out; Standalone<CommitTransactionRef> out;