do not update digest during recovery

This commit is contained in:
Alexander Tokmakov 2023-06-21 21:07:59 +02:00
parent 9240a82c64
commit 50ee424148

View File

@ -1181,7 +1181,7 @@ void DatabaseReplicated::dropTable(ContextPtr local_context, const String & tabl
std::lock_guard lock{metadata_mutex};
UInt64 new_digest = tables_metadata_digest;
new_digest -= getMetadataHash(table_name);
if (txn && !txn->isCreateOrReplaceQuery())
if (txn && !txn->isCreateOrReplaceQuery() && !is_recovering)
txn->addOp(zkutil::makeSetRequest(replica_path + "/digest", toString(new_digest), -1));
DatabaseAtomic::dropTableImpl(local_context, table_name, sync);
@ -1235,7 +1235,7 @@ void DatabaseReplicated::renameTable(ContextPtr local_context, const String & ta
new_digest -= DB::getMetadataHash(to_table_name, statement_to);
new_digest += DB::getMetadataHash(table_name, statement_to);
}
if (txn)
if (txn && !is_recovering)
txn->addOp(zkutil::makeSetRequest(replica_path + "/digest", toString(new_digest), -1));
DatabaseAtomic::renameTable(local_context, table_name, to_database, to_table_name, exchange, dictionary);
@ -1261,7 +1261,7 @@ void DatabaseReplicated::commitCreateTable(const ASTCreateQuery & query, const S
std::lock_guard lock{metadata_mutex};
UInt64 new_digest = tables_metadata_digest;
new_digest += DB::getMetadataHash(query.getTable(), statement);
if (txn && !txn->isCreateOrReplaceQuery())
if (txn && !txn->isCreateOrReplaceQuery() && !is_recovering)
txn->addOp(zkutil::makeSetRequest(replica_path + "/digest", toString(new_digest), -1));
DatabaseAtomic::commitCreateTable(query, table, table_metadata_tmp_path, table_metadata_path, query_context);
@ -1285,7 +1285,7 @@ void DatabaseReplicated::commitAlterTable(const StorageID & table_id,
UInt64 new_digest = tables_metadata_digest;
new_digest -= getMetadataHash(table_id.table_name);
new_digest += DB::getMetadataHash(table_id.table_name, statement);
if (txn)
if (txn && !is_recovering)
txn->addOp(zkutil::makeSetRequest(replica_path + "/digest", toString(new_digest), -1));
DatabaseAtomic::commitAlterTable(table_id, table_metadata_tmp_path, table_metadata_path, statement, query_context);
@ -1308,7 +1308,7 @@ void DatabaseReplicated::detachTablePermanently(ContextPtr local_context, const
std::lock_guard lock{metadata_mutex};
UInt64 new_digest = tables_metadata_digest;
new_digest -= getMetadataHash(table_name);
if (txn)
if (txn && !is_recovering)
txn->addOp(zkutil::makeSetRequest(replica_path + "/digest", toString(new_digest), -1));
DatabaseAtomic::detachTablePermanently(local_context, table_name);
@ -1332,7 +1332,7 @@ void DatabaseReplicated::removeDetachedPermanentlyFlag(ContextPtr local_context,
if (attach)
{
new_digest += getMetadataHash(table_name);
if (txn)
if (txn && !is_recovering)
txn->addOp(zkutil::makeSetRequest(replica_path + "/digest", toString(new_digest), -1));
}