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

fix: prevent tx_executor reading from sock if operation is canceled #4704

Merged
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
2 changes: 0 additions & 2 deletions src/server/cluster/incoming_slot_migration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ class ClusterShardMigration {

auto tx_data = tx_reader.NextTxData(&reader, cntx);
if (!tx_data) {
in_migration_->ReportError(GenericError("No tx data"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this?
if there is no transaction data you need to report error? if its not running doesnt it mean that error was already reported?

Copy link
Contributor Author

@BorysTheDev BorysTheDev Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do report inside tx_reader.NextTxData(&reader, cntx); If the cntx is canceled we don't need report. If we have error it is already reported

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why do you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get the question. I'v removed it, because we don't need it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ops sorry my eys are playing with me

VLOG(1) << "No tx data";
break;
}

Expand Down
3 changes: 3 additions & 0 deletions src/server/journal/tx_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ TransactionData TransactionData::FromEntry(journal::ParsedEntry&& entry) {

std::optional<TransactionData> TransactionReader::NextTxData(JournalReader* reader,
ExecutionState* cntx) {
if (!cntx->IsRunning()) {
return std::nullopt;
}
io::Result<journal::ParsedEntry> res;
if (res = reader->ReadEntry(); !res) {
cntx->ReportError(res.error());
Expand Down
7 changes: 2 additions & 5 deletions src/server/replica.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,8 @@ void DflyShardReplica::StableSyncDflyReadFb(ExecutionState* cntx) {

acks_fb_ = fb2::Fiber("shard_acks", &DflyShardReplica::StableSyncDflyAcksFb, this, cntx);

while (cntx->IsRunning()) {
auto tx_data = tx_reader.NextTxData(&reader, cntx);
if (!tx_data)
break;

std::optional<TransactionData> tx_data;
while ((tx_data = tx_reader.NextTxData(&reader, cntx))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it looks like we did not call the NextTxData if the cntx was closed..
so the problem is in cluster code only where you do not have such if as there was here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no problem here. just decided to make it shorter

DVLOG(3) << "Lsn: " << tx_data->lsn;

last_io_time_ = Proactor()->GetMonotonicTimeNs();
Expand Down
Loading