Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not clear shard lists #13189

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 17 additions & 19 deletions ydb/core/tx/columnshard/columnshard__write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class TCommitOperation {
using TPtr = std::shared_ptr<TCommitOperation>;

bool NeedSyncLocks() const {
return SendingShards.size() && ReceivingShards.size();
return SendingShards.size() || ReceivingShards.size();
}

bool IsPrimary() const {
Expand All @@ -317,29 +317,28 @@ class TCommitOperation {
}

TConclusionStatus Parse(const NEvents::TDataEvents::TEvWrite& evWrite) {
AFL_VERIFY(evWrite.Record.GetLocks().GetLocks().size() >= 1);
auto& locks = evWrite.Record.GetLocks();
auto& lock = evWrite.Record.GetLocks().GetLocks()[0];
TxId = evWrite.Record.GetTxId();
NActors::TLogContextGuard lGuard = NActors::TLogContextBuilder::Build()("tx_id", TxId);
const auto& locks = evWrite.Record.GetLocks();
AFL_VERIFY(!locks.GetLocks().empty());
auto& lock = locks.GetLocks()[0];
LockId = lock.GetLockId();
SendingShards = std::set<ui64>(locks.GetSendingShards().begin(), locks.GetSendingShards().end());
ReceivingShards = std::set<ui64>(locks.GetReceivingShards().begin(), locks.GetReceivingShards().end());
if (!ReceivingShards.size() || !SendingShards.size()) {
ReceivingShards.clear();
SendingShards.clear();
} else if (!locks.HasArbiterColumnShard()) {
ArbiterColumnShard = *ReceivingShards.begin();
const bool singleShardTx = SendingShards.empty() && ReceivingShards.empty();
if (!singleShardTx) {
if (!ReceivingShards.contains(TabletId) && !SendingShards.contains(TabletId)) {
return TConclusionStatus::Fail("shard is incorrect for sending/receiving lists");
return TConclusionStatus::Fail("shard is absent in sending and receiving lists");
}
} else {
ArbiterColumnShard = locks.GetArbiterColumnShard();
AFL_VERIFY(ArbiterColumnShard);
if (!ReceivingShards.contains(TabletId) && !SendingShards.contains(TabletId)) {
return TConclusionStatus::Fail("shard is incorrect for sending/receiving lists");
if (locks.HasArbiterColumnShard()) {
ArbiterColumnShard = locks.GetArbiterColumnShard();
} else {
AFL_VERIFY(!ReceivingShards.empty());
ArbiterColumnShard = *ReceivingShards.begin();
}
AFL_VERIFY(ArbiterColumnShard);
}

TxId = evWrite.Record.GetTxId();
LockId = lock.GetLockId();
Generation = lock.GetGeneration();
InternalGenerationCounter = lock.GetCounter();
if (!GetLockId()) {
Expand All @@ -348,15 +347,14 @@ class TCommitOperation {
if (!TxId) {
return TConclusionStatus::Fail("not initialized TxId for commit event");
}
if (evWrite.Record.GetLocks().GetOp() != NKikimrDataEvents::TKqpLocks::Commit) {
if (locks.GetOp() != NKikimrDataEvents::TKqpLocks::Commit) {
return TConclusionStatus::Fail("incorrect message type");
}
return TConclusionStatus::Success();
}

std::unique_ptr<NColumnShard::TEvWriteCommitSyncTransactionOperator> CreateTxOperator(
const NKikimrTxColumnShard::ETransactionKind kind) const {
AFL_VERIFY(ReceivingShards.size());
if (IsPrimary()) {
return std::make_unique<NColumnShard::TEvWriteCommitPrimaryTransactionOperator>(
TFullTxInfo::BuildFake(kind), LockId, ReceivingShards, SendingShards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class TEvWriteCommitPrimaryTransactionOperator: public TEvWriteCommitSyncTransac
for (auto&& i : protoData.GetWaitShardsResultAck()) {
WaitShardsResultAck.emplace(i);
}
AFL_VERIFY(ReceivingShards.empty() == SendingShards.empty());
if (protoData.HasTxBroken()) {
TxBroken = protoData.GetTxBroken();
}
Expand Down Expand Up @@ -160,8 +159,7 @@ class TEvWriteCommitPrimaryTransactionOperator: public TEvWriteCommitSyncTransac
};

virtual bool IsTxBroken() const override {
AFL_VERIFY(TxBroken);
return *TxBroken;
return TxBroken.value_or(false);
}

void InitializeRequests(TColumnShard& owner) {
Expand Down
Loading