Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = streamPath.Child("incBackupImpl");
Comment thread
Enjection marked this conversation as resolved.
Outdated

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
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/continuousBackupImpl/incBackupImpl"), {
NLs::PathExist,
NLs::IsTable,
NLs::CheckColumns("incBackupImpl", {"key", "value", "__incrBackupImpl_deleted"}, {}, {"key"}),
});
}
} // TCdcStreamWithInitialScanTests