Skip to content

Commit

Permalink
Merge b59e362 into fb31079
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberROFL authored Jul 5, 2024
2 parents fb31079 + b59e362 commit 1c642cd
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ydb/core/tx/datashard/datashard_user_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ void TUserTable::AlterSchema() {
schema.SetPartitionRangeEnd(Range.To.GetBuffer());
schema.SetPartitionRangeEndIsInclusive(Range.ToInclusive);

ReplicationConfig.Serialize(*schema.MutableReplicationConfig());

schema.SetName(Name);
schema.SetPath(Path);

Expand Down
5 changes: 5 additions & 0 deletions ydb/core/tx/datashard/datashard_user_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ struct TUserTable : public TThrRefBase {
bool HasStrongConsistency() const {
return Consistency == NKikimrSchemeOp::TTableReplicationConfig::CONSISTENCY_STRONG;
}

void Serialize(NKikimrSchemeOp::TTableReplicationConfig& proto) const {
proto.SetMode(Mode);
proto.SetConsistency(Consistency);
}
};

struct TStats {
Expand Down
3 changes: 3 additions & 0 deletions ydb/core/tx/datashard/datashard_ut_replication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ Y_UNIT_TEST_SUITE(DataShardReplication) {
ExecSQL(server, sender, "SELECT * FROM `/Root/table-1`");
ExecSQL(server, sender, "INSERT INTO `/Root/table-1` (key, value) VALUES (1, 10);", true,
Ydb::StatusIds::GENERIC_ERROR);

WaitTxNotification(server, sender, AsyncAlterDropReplicationConfig(server, "/Root", "table-1"));
ExecSQL(server, sender, "INSERT INTO `/Root/table-1` (key, value) VALUES (1, 10);");
}

Y_UNIT_TEST(ApplyChangesToReplicatedTable) {
Expand Down
16 changes: 16 additions & 0 deletions ydb/core/tx/datashard/ut_common/datashard_ut_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,22 @@ ui64 AsyncAlterDropStream(
return RunSchemeTx(*server->GetRuntime(), std::move(request));
}

ui64 AsyncAlterDropReplicationConfig(
Tests::TServer::TPtr server,
const TString& workingDir,
const TString& tableName)
{
auto request = SchemeTxTemplate(NKikimrSchemeOp::ESchemeOpAlterTable, workingDir);
auto& tx = *request->Record.MutableTransaction()->MutableModifyScheme();
tx.SetInternal(true);

auto& desc = *tx.MutableAlterTable();
desc.SetName(tableName);
desc.MutableReplicationConfig()->SetMode(NKikimrSchemeOp::TTableReplicationConfig::REPLICATION_MODE_NONE);

return RunSchemeTx(*server->GetRuntime(), std::move(request));
}

ui64 AsyncCreateContinuousBackup(
Tests::TServer::TPtr server,
const TString& workingDir,
Expand Down
5 changes: 5 additions & 0 deletions ydb/core/tx/datashard/ut_common/datashard_ut_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,11 @@ ui64 AsyncAlterDropStream(
const TString& tableName,
const TString& streamName);

ui64 AsyncAlterDropReplicationConfig(
Tests::TServer::TPtr server,
const TString& workingDir,
const TString& tableName);

ui64 AsyncCreateContinuousBackup(
Tests::TServer::TPtr server,
const TString& workingDir,
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6538,6 +6538,12 @@ TString TSchemeShard::FillAlterTableTxBody(TPathId pathId, TShardIdx shardIdx, T
*patch);
}

if (alterData->TableDescriptionFull.Defined() && alterData->TableDescriptionFull->HasReplicationConfig()) {
proto->MutableReplicationConfig()->CopyFrom(alterData->TableDescriptionFull->GetReplicationConfig());
} else if (tableInfo->HasReplicationConfig()) {
proto->MutableReplicationConfig()->CopyFrom(tableInfo->ReplicationConfig());
}

TString txBody;
Y_PROTOBUF_SUPPRESS_NODISCARD tx.SerializeToString(&txBody);
return txBody;
Expand Down

0 comments on commit 1c642cd

Please sign in to comment.