Skip to content

EOperationKind::WriteTx #976

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

Merged
merged 1 commit into from
Jan 12, 2024
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
4 changes: 1 addition & 3 deletions ydb/core/tx/datashard/check_write_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ EExecutionStatus TCheckWriteUnit::Execute(TOperation::TPtr op,
TTransactionContext &,
const TActorContext &ctx)
{
Y_ABORT_UNLESS(op->IsDataTx() || op->IsReadTable());
Copy link
Member

Choose a reason for hiding this comment

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

Тут можно было сделать Y_ABORT_UNLESS(op->IsWriteTx()).

Copy link
Collaborator Author

@azevaykin azevaykin Jan 12, 2024

Choose a reason for hiding this comment

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

Ниже в 52 строке есть TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op); , там внутри есть Y_ABORT_UNLESS(op->IsWriteTx()).

Но могу и тут продублировать.

Y_ABORT_UNLESS(!op->IsAborted());

if (CheckRejectDataTx(op, ctx)) {
Expand All @@ -50,8 +49,7 @@ EExecutionStatus TCheckWriteUnit::Execute(TOperation::TPtr op,
return EExecutionStatus::Executed;
}

TWriteOperation* writeOp = dynamic_cast<TWriteOperation*>(op.Get());
Y_VERIFY_S(writeOp, "cannot cast operation of kind " << op->GetKind());
TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op);
auto writeTx = writeOp->GetWriteTx();
Y_ABORT_UNLESS(writeTx);
Y_ABORT_UNLESS(writeTx->Ready() || writeTx->RequirePrepare());
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/datashard/datashard_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ TOperation::TPtr TPipeline::BuildOperation(NEvents::TDataEvents::TEvWrite::TPtr&
const TActorContext& ctx, NWilson::TSpan &&operationSpan)
{
const auto& rec = ev->Get()->Record;
TBasicOpInfo info(rec.GetTxId(), EOperationKind::DataTx, EvWrite::Convertor::GetProposeFlags(rec.GetTxMode()), 0, receivedAt, tieBreakerIndex);
TBasicOpInfo info(rec.GetTxId(), EOperationKind::WriteTx, EvWrite::Convertor::GetProposeFlags(rec.GetTxMode()), 0, receivedAt, tieBreakerIndex);
auto writeOp = MakeIntrusive<TWriteOperation>(info, ev, Self, txc, ctx);
writeOp->OperationSpan = std::move(operationSpan);
auto writeTx = writeOp->GetWriteTx();
Expand Down
6 changes: 3 additions & 3 deletions ydb/core/tx/datashard/datashard_write_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ void TValidatedWriteTx::ComputeTxSize() {

TWriteOperation* TWriteOperation::CastWriteOperation(TOperation::TPtr op)
{
Y_ABORT_UNLESS(op->IsWriteTx());
TWriteOperation* writeOp = dynamic_cast<TWriteOperation*>(op.Get());
Y_ABORT_UNLESS(writeOp);
return writeOp;
Expand Down Expand Up @@ -453,7 +454,7 @@ ERestoreDataStatus TWriteOperation::RestoreTxData(

void TWriteOperation::FinalizeWriteTxPlan()
{
Y_ABORT_UNLESS(IsDataTx());
Y_ABORT_UNLESS(IsWriteTx());
Y_ABORT_UNLESS(!IsImmediate());
Y_ABORT_UNLESS(!IsKqpScanTransaction());

Expand Down Expand Up @@ -494,8 +495,7 @@ class TFinalizeWriteTxPlanUnit: public TExecutionUnit {
Y_UNUSED(txc);
Y_UNUSED(ctx);

TWriteOperation* writeOp = dynamic_cast<TWriteOperation*>(op.Get());
Y_VERIFY_S(writeOp, "cannot cast operation of kind " << op->GetKind());
TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op);

writeOp->FinalizeWriteTxPlan();

Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/datashard/operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ enum class EOperationKind : ui32 {
// Values [100, inf) are used for internal kinds.
DirectTx = 101,
ReadTx = 102,
WriteTx = 103,
};

class TBasicOpInfo {
Expand Down Expand Up @@ -165,6 +166,7 @@ class TBasicOpInfo {

bool IsDataTx() const { return Kind == EOperationKind::DataTx; }
bool IsReadTx() const { return Kind == EOperationKind::ReadTx; }
bool IsWriteTx() const { return Kind == EOperationKind::WriteTx; }
bool IsDirectTx() const { return Kind == EOperationKind::DirectTx; }
bool IsSchemeTx() const { return Kind == EOperationKind::SchemeTx; }
bool IsReadTable() const { return Kind == EOperationKind::ReadTable; }
Expand Down
6 changes: 2 additions & 4 deletions ydb/core/tx/datashard/write_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ class TWriteUnit : public TExecutionUnit {
}

EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override {
TWriteOperation* writeOp = dynamic_cast<TWriteOperation*>(op.Get());
Y_ABORT_UNLESS(writeOp != nullptr);
TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op);

LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Executing write operation for " << *op << " at " << DataShard.TabletID());

Expand Down Expand Up @@ -164,8 +163,7 @@ class TWriteUnit : public TExecutionUnit {
DataShard.EnqueueChangeRecords(std::move(op->ChangeRecords()));
DataShard.EmitHeartbeats(ctx);

TWriteOperation* writeOp = dynamic_cast<TWriteOperation*>(op.Get());
Y_ABORT_UNLESS(writeOp != nullptr);
TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op);

const auto& status = writeOp->GetWriteResult()->Record.status();
LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Completed write operation for " << *op << " at " << DataShard.TabletID() << ", status " << status);
Expand Down