Skip to content

Commit c4e1a1c

Browse files
committed
WIP-34-1-5
1 parent 6d991e5 commit c4e1a1c

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

ydb/core/tx/datashard/datashard_ut_incremental_backup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,6 +3088,7 @@ Y_UNIT_TEST_SUITE(IncrementalBackup) {
30883088
)", false);
30893089

30903090
ExecSQL(server, edgeActor, R"(BACKUP `MyCollection`;)", false);
3091+
SimulateSleep(server, TDuration::Seconds(5));
30913092

30923093
ExecSQL(server, edgeActor, R"(
30933094
UPSERT INTO `/Root/Table` (key, value) VALUES

ydb/core/tx/schemeshard/schemeshard__operation_common_cdc_stream.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ TTableVersionContext BuildTableVersionContext(
115115
void SyncImplTableVersion(
116116
const TTableVersionContext& versionCtx,
117117
TTableInfo::TPtr& table,
118-
TOperationContext& context)
118+
TOperationId operationId,
119+
TOperationContext& context,
120+
NIceDb::TNiceDb& db)
119121
{
120122
Y_ABORT_UNLESS(context.SS->Tables.contains(versionCtx.GrandParentPathId));
121123
auto parentTable = context.SS->Tables.at(versionCtx.GrandParentPathId);
@@ -154,6 +156,20 @@ void SyncImplTableVersion(
154156
<< ", newImplVersion: " << table->AlterVersion
155157
<< ", at schemeshard: " << context.SS->SelfTabletId());
156158
}
159+
160+
// Persist the updated version and notify datashards
161+
context.SS->PersistTableAlterVersion(db, versionCtx.PathId, table);
162+
if (context.SS->PathsById.contains(versionCtx.PathId)) {
163+
auto implTablePath = context.SS->PathsById.at(versionCtx.PathId);
164+
context.SS->ClearDescribePathCaches(implTablePath);
165+
context.OnComplete.PublishToSchemeBoard(operationId, versionCtx.PathId);
166+
167+
LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
168+
"Published schema update to SchemeBoard for index impl table"
169+
<< ", implTablePathId: " << versionCtx.PathId
170+
<< ", newVersion: " << table->AlterVersion
171+
<< ", at schemeshard: " << context.SS->SelfTabletId());
172+
}
157173
}
158174

159175
void UpdateTableVersion(
@@ -181,7 +197,7 @@ void UpdateTableVersion(
181197
<< ", grandParentPathId: " << versionCtx.GrandParentPathId
182198
<< ", at schemeshard: " << context.SS->SelfTabletId());
183199

184-
SyncImplTableVersion(versionCtx, table, context);
200+
SyncImplTableVersion(versionCtx, table, operationId, context, db);
185201

186202
// Sync the index entity to match the impl table version
187203
::NKikimr::NSchemeShard::NCdcStreamState::SyncIndexEntityVersion(versionCtx.ParentPathId, table->AlterVersion, operationId, context, db);
@@ -330,27 +346,11 @@ void SyncChildIndexes(
330346

331347
NCdcStreamState::SyncIndexEntityVersion(childPathId, targetVersion, operationId, context, db);
332348

333-
// Also sync the index impl table
334-
for (const auto& [implChildName, implChildPathId] : childPath->GetChildren()) {
335-
auto implChildPath = context.SS->PathsById.at(implChildPathId);
336-
if (implChildPath->IsTable() && context.SS->Tables.contains(implChildPathId)) {
337-
auto implTable = context.SS->Tables.at(implChildPathId);
338-
if (implTable->AlterVersion < targetVersion) {
339-
implTable->AlterVersion = targetVersion;
340-
context.SS->PersistTableAlterVersion(db, implChildPathId, implTable);
341-
context.SS->ClearDescribePathCaches(implChildPath);
342-
context.OnComplete.PublishToSchemeBoard(operationId, implChildPathId);
343-
344-
LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
345-
"Synced index impl table version"
346-
<< ", indexImplTablePathId: " << implChildPathId
347-
<< ", indexPathId: " << childPathId
348-
<< ", newVersion: " << targetVersion
349-
<< ", at schemeshard: " << context.SS->SelfTabletId());
350-
}
351-
}
352-
}
353-
349+
// NOTE: We intentionally do NOT sync the index impl table version here.
350+
// Bumping AlterVersion without sending a TX_KIND_SCHEME transaction to datashards
351+
// causes SCHEME_CHANGED errors because datashards still have the old version.
352+
// The version should only be incremented when there's an actual schema change.
353+
354354
LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
355355
"Synced parent index version with parent table"
356356
<< ", parentTable: " << parentPath->Name

0 commit comments

Comments
 (0)