Skip to content

Commit

Permalink
Merge 1bbeeb7 into 7182df1
Browse files Browse the repository at this point in the history
  • Loading branch information
Enjection authored May 29, 2024
2 parents 7182df1 + 1bbeeb7 commit c6354b5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ void DoAlterPqPart(const TOperationId& opId, const TPath& topicPath, TTopicInfo:
result.push_back(CreateAlterPQ(NextPartId(opId, result), outTx));
}

void DoCreateIncBackupTable(const TOperationId& opId, const TPath& dst, NKikimrSchemeOp::TTableDescription tableDesc, TVector<ISubOperation::TPtr>& result) {
auto outTx = TransactionTemplate(dst.Parent().PathString(), NKikimrSchemeOp::EOperationType::ESchemeOpCreateTable);
// outTx.SetFailOnExist(!acceptExisted);

outTx.SetAllowAccessToPrivatePaths(true);

auto& desc = *outTx.MutableCreateTable();
desc.CopyFrom(tableDesc);
desc.SetName(dst.LeafName());

auto col = desc.AddColumns();
col->SetName("__incrBackupImpl_deleted");
col->SetType("Bool");

result.push_back(CreateNewTable(NextPartId(opId, result), outTx));
}

TVector<ISubOperation::TPtr> CreateAlterContinuousBackup(TOperationId opId, const TTxTransaction& tx, TOperationContext& context) {
Y_ABORT_UNLESS(tx.GetOperationType() == NKikimrSchemeOp::EOperationType::ESchemeOpAlterContinuousBackup);

Expand All @@ -48,9 +65,19 @@ TVector<ISubOperation::TPtr> CreateAlterContinuousBackup(TOperationId opId, cons
}

const auto [tablePath, streamPath] = std::get<NCdc::TStreamPaths>(checksResult);
TTableInfo::TPtr table = context.SS->Tables.at(tablePath.Base()->PathId);

const auto topicPath = streamPath.Child("streamImpl");
TTopicInfo::TPtr topic = context.SS->Topics.at(topicPath.Base()->PathId);

const auto backupTablePath = tablePath.Child("incBackupImpl");

const NScheme::TTypeRegistry* typeRegistry = AppData(context.Ctx)->TypeRegistry;

NKikimrSchemeOp::TTableDescription schema;
context.SS->DescribeTable(table, typeRegistry, true, false, &schema);
schema.MutablePartitionConfig()->CopyFrom(table->TableDescription.GetPartitionConfig());

TString errStr;
if (!context.SS->CheckApplyIf(tx, errStr)) {
return {CreateReject(opId, NKikimrScheme::StatusPreconditionFailed, errStr)};
Expand Down Expand Up @@ -79,6 +106,7 @@ TVector<ISubOperation::TPtr> CreateAlterContinuousBackup(TOperationId opId, cons
NCdc::DoAlterStream(alterCdcStreamOp, opId, workingDirPath, tablePath, result);

if (cbOp.GetActionCase() == NKikimrSchemeOp::TAlterContinuousBackup::kTakeIncrementalBackup) {
DoCreateIncBackupTable(opId, backupTablePath, schema, result);
DoAlterPqPart(opId, topicPath, topic, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class TCreateTable: public TSubOperation {
checks.IsInsideTableIndexPath()
.IsUnderCreating(NKikimrScheme::StatusNameConflict)
.IsUnderTheSameOperation(OperationId.GetTxId()); //allow only as part of creating base table
} else {
} else if (!Transaction.GetAllowAccessToPrivatePaths()) {
checks.IsCommonSensePath()
.IsLikeDirectory();
}
Expand Down
5 changes: 5 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6693,6 +6693,11 @@ void TSchemeShard::FillTableDescriptionForShardIdx(
break;
}

case NKikimrSchemeOp::EPathTypeTable: {
// TODO: move BackupImplTable under special scheme element
break;
}

default:
Y_FAIL_S("Unexpected table's child"
<< ": tableId# " << tableId
Expand Down
3 changes: 3 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard_path_describer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
case NKikimrSchemeOp::EPathTypeSequence:
Self->DescribeSequence(childPathId, childName, *entry->AddSequences(), returnSetVal);
break;
case NKikimrSchemeOp::EPathTypeTable:
// TODO: move BackupImplTable under special scheme element
break;
default:
Y_FAIL_S("Unexpected table's child"
<< ": tableId# " << pathId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,11 @@ Y_UNIT_TEST_SUITE(TContinuousBackupTests) {
NLs::PathExist,
NLs::HasOffloadConfig,
});

TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/incBackupImpl"), {
NLs::PathExist,
NLs::IsTable,
NLs::CheckColumns("incBackupImpl", {"key", "value", "__incrBackupImpl_deleted"}, {}, {"key"}),
});
}
} // TCdcStreamWithInitialScanTests

0 comments on commit c6354b5

Please sign in to comment.