diff options
author | Aleksei Borzenkov <snaury@ydb.tech> | 2025-03-24 20:44:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-24 20:44:38 +0300 |
commit | b10a177dfbd54929bd4e0bf1f34eca1bb846412b (patch) | |
tree | 45738e881ca17e759d57078750c71dca51445448 | |
parent | 91300564043f1b8e3114e35803e66722fb514880 (diff) | |
download | ydb-main.tar.gz |
185 files changed, 1584 insertions, 1648 deletions
diff --git a/ydb/core/tx/datashard/alter_cdc_stream_unit.cpp b/ydb/core/tx/datashard/alter_cdc_stream_unit.cpp index fce561a621..545c03efdd 100644 --- a/ydb/core/tx/datashard/alter_cdc_stream_unit.cpp +++ b/ydb/core/tx/datashard/alter_cdc_stream_unit.cpp @@ -17,10 +17,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasAlterCdcStreamNotice()) { @@ -33,10 +33,10 @@ public: const auto state = streamDesc.GetState(); const auto pathId = TPathId::FromProto(params.GetPathId()); - Y_ABORT_UNLESS(pathId.OwnerId == DataShard.GetPathOwnerId()); + Y_ENSURE(pathId.OwnerId == DataShard.GetPathOwnerId()); const auto version = params.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); TUserTable::TPtr tableInfo; switch (state) { @@ -50,7 +50,7 @@ public: if (params.HasDropSnapshot()) { const auto& snapshot = params.GetDropSnapshot(); - Y_ABORT_UNLESS(snapshot.GetStep() != 0); + Y_ENSURE(snapshot.GetStep() != 0); const TSnapshotKey key(pathId, snapshot.GetStep(), snapshot.GetTxId()); DataShard.GetSnapshotManager().RemoveSnapshot(txc.DB, key); @@ -64,11 +64,11 @@ public: break; default: - Y_FAIL_S("Unexpected alter cdc stream" + Y_ENSURE(false, "Unexpected alter cdc stream" << ": params# " << params.ShortDebugString()); } - Y_ABORT_UNLESS(tableInfo); + Y_ENSURE(tableInfo); DataShard.AddUserTable(pathId, tableInfo); if (tableInfo->NeedSchemaSnapshots()) { diff --git a/ydb/core/tx/datashard/alter_table_unit.cpp b/ydb/core/tx/datashard/alter_table_unit.cpp index 60167f6625..7e979a07af 100644 --- a/ydb/core/tx/datashard/alter_table_unit.cpp +++ b/ydb/core/tx/datashard/alter_table_unit.cpp @@ -25,7 +25,7 @@ public: Y_UNUSED(ctx); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); // Only applicable when ALTER TABLE is in the transaction auto& schemeTx = tx->GetSchemeTx(); @@ -44,12 +44,12 @@ public: ui64 tableId = alter.GetId_Deprecated(); if (alter.HasPathId()) { auto& pathId = alter.GetPathId(); - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == pathId.GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == pathId.GetOwnerId()); tableId = pathId.GetLocalId(); } // Only applicable when table has ShadowData enabled - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const TUserTable& table = *DataShard.GetUserTables().at(tableId); const ui32 localTid = table.LocalTid; const ui32 shadowTid = table.ShadowTid; @@ -66,7 +66,7 @@ public: return EExecutionStatus::Continue; } - Y_ABORT_UNLESS(op->InputSnapshots().size() == 1, "Expected a single shadow snapshot"); + Y_ENSURE(op->InputSnapshots().size() == 1, "Expected a single shadow snapshot"); { auto& snapshot = op->InputSnapshots()[0]; txc.Env.MoveSnapshot(*snapshot, /* src */ shadowTid, /* dst */ localTid); @@ -129,7 +129,7 @@ EExecutionStatus TAlterTableUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasAlterTable()) @@ -138,7 +138,7 @@ EExecutionStatus TAlterTableUnit::Execute(TOperation::TPtr op, const auto& alterTableTx = schemeTx.GetAlterTable(); const auto version = alterTableTx.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, "Trying to ALTER TABLE at " << DataShard.TabletID() @@ -147,7 +147,7 @@ EExecutionStatus TAlterTableUnit::Execute(TOperation::TPtr op, TPathId tableId(DataShard.GetPathOwnerId(), alterTableTx.GetId_Deprecated()); if (alterTableTx.HasPathId()) { auto& pathId = alterTableTx.GetPathId(); - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == pathId.GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == pathId.GetOwnerId()); tableId.LocalPathId = pathId.GetLocalId(); } diff --git a/ydb/core/tx/datashard/backup_restore_common.h b/ydb/core/tx/datashard/backup_restore_common.h index 06d1970da3..31a7528046 100644 --- a/ydb/core/tx/datashard/backup_restore_common.h +++ b/ydb/core/tx/datashard/backup_restore_common.h @@ -31,7 +31,7 @@ protected: void Abort(TOperation::TPtr op, const TActorContext& ctx, const TString& error) { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); LOG_NOTICE_S(ctx, NKikimrServices::TX_DATASHARD, error); @@ -57,7 +57,7 @@ private: void PersistResult(TOperation::TPtr op, TTransactionContext& txc) { auto* schemeOp = DataShard.FindSchemaTx(op->GetTxId()); - Y_ABORT_UNLESS(schemeOp); + Y_ENSURE(schemeOp); NIceDb::TNiceDb db(txc.DB); DataShard.PersistSchemeTxResult(db, *schemeOp); @@ -87,7 +87,7 @@ public: EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override final { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (!IsRelevant(tx)) { return EExecutionStatus::Executed; diff --git a/ydb/core/tx/datashard/backup_restore_traits.cpp b/ydb/core/tx/datashard/backup_restore_traits.cpp index fc14d8f75e..2e966ecf6d 100644 --- a/ydb/core/tx/datashard/backup_restore_traits.cpp +++ b/ydb/core/tx/datashard/backup_restore_traits.cpp @@ -29,7 +29,7 @@ bool TryCodecFromTask(const NKikimrSchemeOp::TBackupTask& task, ECompressionCode ECompressionCodec CodecFromTask(const NKikimrSchemeOp::TBackupTask& task) { ECompressionCodec codec; - Y_ABORT_UNLESS(TryCodecFromTask(task, codec)); + Y_ENSURE(TryCodecFromTask(task, codec)); return codec; } @@ -64,10 +64,10 @@ TString DataFileExtension(EDataFormat format, ECompressionCodec codec) { }; auto fit = formats.find(format); - Y_VERIFY_S(fit != formats.end(), "Unexpected format: " << format); + Y_ENSURE(fit != formats.end(), "Unexpected format: " << format); auto cit = codecs.find(codec); - Y_VERIFY_S(cit != codecs.end(), "Unexpected codec: " << codec); + Y_ENSURE(cit != codecs.end(), "Unexpected codec: " << codec); return Sprintf("%s%s", fit->second.c_str(), cit->second.c_str()); } diff --git a/ydb/core/tx/datashard/backup_unit.cpp b/ydb/core/tx/datashard/backup_unit.cpp index e328860ada..0350299def 100644 --- a/ydb/core/tx/datashard/backup_unit.cpp +++ b/ydb/core/tx/datashard/backup_unit.cpp @@ -33,16 +33,16 @@ protected: bool Run(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); - Y_ABORT_UNLESS(tx->GetSchemeTx().HasBackup()); + Y_ENSURE(tx->GetSchemeTx().HasBackup()); const auto& backup = tx->GetSchemeTx().GetBackup(); const ui64 tableId = backup.GetTableId(); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const ui32 localTableId = DataShard.GetUserTables().at(tableId)->LocalTid; - Y_ABORT_UNLESS(txc.DB.GetScheme().GetTableInfo(localTableId)); + Y_ENSURE(txc.DB.GetScheme().GetTableInfo(localTableId)); auto* appData = AppData(ctx); const auto& columns = DataShard.GetUserTables().at(tableId)->Columns; @@ -115,7 +115,7 @@ protected: bool ProcessResult(TOperation::TPtr op, const TActorContext&) override { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto* result = CheckedCast<TExportScanProduct*>(op->ScanResult().Get()); bool done = true; @@ -129,7 +129,7 @@ protected: schemeOp->BytesProcessed = result->BytesRead; schemeOp->RowsProcessed = result->RowsRead; } else { - Y_FAIL_S("Cannot find schema tx: " << op->GetTxId()); + Y_ENSURE(false, "Cannot find schema tx: " << op->GetTxId()); } break; case EExportOutcome::Aborted: @@ -150,7 +150,7 @@ protected: const ui64 tableId = tx->GetSchemeTx().GetBackup().GetTableId(); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const ui32 localTableId = DataShard.GetUserTables().at(tableId)->LocalTid; DataShard.CancelScan(localTableId, tx->GetScanTask()); diff --git a/ydb/core/tx/datashard/buffer_data.h b/ydb/core/tx/datashard/buffer_data.h index 0b5cdddf77..bb0131d210 100644 --- a/ydb/core/tx/datashard/buffer_data.h +++ b/ydb/core/tx/datashard/buffer_data.h @@ -25,8 +25,8 @@ public: } void FlushTo(TBufferData& other) { - Y_ABORT_UNLESS(this != &other); - Y_ABORT_UNLESS(other.IsEmpty()); + Y_ENSURE(this != &other); + Y_ENSURE(other.IsEmpty()); other.Rows.swap(Rows); other.ByteSize = std::exchange(ByteSize, 0); other.LastKey = std::exchange(LastKey, {}); diff --git a/ydb/core/tx/datashard/build_and_wait_dependencies_unit.cpp b/ydb/core/tx/datashard/build_and_wait_dependencies_unit.cpp index cb0e80d14e..411f8d809f 100644 --- a/ydb/core/tx/datashard/build_and_wait_dependencies_unit.cpp +++ b/ydb/core/tx/datashard/build_and_wait_dependencies_unit.cpp @@ -117,7 +117,7 @@ EExecutionStatus TBuildAndWaitDependenciesUnit::Execute(TOperation::TPtr op, } } else if (BuildVolatileDependencies(op)) { // We acquired new volatile dependencies, wait for them too - Y_ABORT_UNLESS(!IsReadyToExecute(op)); + Y_ENSURE(!IsReadyToExecute(op)); return EExecutionStatus::Continue; } @@ -140,10 +140,10 @@ void TBuildAndWaitDependenciesUnit::BuildDependencies(const TOperation::TPtr &op // they are completed. if (op->IsSchemeTx() && !op->IsReadOnly()) { auto *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); for (const auto &pr : Pipeline.GetActivePlannedOps()) { - Y_VERIFY_S(pr.first < op->GetStepOrder(), + Y_ENSURE(pr.first < op->GetStepOrder(), "unexpected tx " << pr.first.ToString() << " when adding " << op->GetStepOrder().ToString()); if (!op->IsCompleted()) { @@ -174,7 +174,7 @@ bool TBuildAndWaitDependenciesUnit::BuildVolatileDependencies(const TOperation:: op->AddVolatileDependency(info->TxId); bool added = DataShard.GetVolatileTxManager() .AttachWaitingRemovalOperation(info->TxId, op->GetTxId()); - Y_ABORT_UNLESS(added); + Y_ENSURE(added); } } diff --git a/ydb/core/tx/datashard/build_data_tx_out_rs_unit.cpp b/ydb/core/tx/datashard/build_data_tx_out_rs_unit.cpp index 8f8f42d14b..9f13ceff75 100644 --- a/ydb/core/tx/datashard/build_data_tx_out_rs_unit.cpp +++ b/ydb/core/tx/datashard/build_data_tx_out_rs_unit.cpp @@ -45,7 +45,7 @@ EExecutionStatus TBuildDataTxOutRSUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); DataShard.ReleaseCache(*tx); @@ -56,7 +56,7 @@ EExecutionStatus TBuildDataTxOutRSUnit::Execute(TOperation::TPtr op, case ERestoreDataStatus::Restart: return EExecutionStatus::Restart; case ERestoreDataStatus::Error: - Y_ABORT("Failed to restore tx data: %s", tx->GetDataTx()->GetErrors().c_str()); + Y_ENSURE(false, "Failed to restore tx data: " << tx->GetDataTx()->GetErrors()); } } @@ -76,7 +76,7 @@ EExecutionStatus TBuildDataTxOutRSUnit::Execute(TOperation::TPtr op, op->OutReadSets().clear(); auto result = engine->PrepareOutgoingReadsets(); - Y_VERIFY_S(result == IEngineFlat::EResult::Ok, + Y_ENSURE(result == IEngineFlat::EResult::Ok, "Engine errors at " << DataShard.TabletID() << " for " << *op << ": " << engine->GetErrors()); diff --git a/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp b/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp index bc25bdff02..21d746d3fb 100644 --- a/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp +++ b/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp @@ -18,7 +18,7 @@ class TBuildDistributedEraseTxOutRSUnit : public TExecutionUnit { static TVector<NTable::TTag> MakeTags(const TVector<NTable::TTag>& conditionTags, const google::protobuf::RepeatedField<ui32>& indexColumnIds) { - Y_ABORT_UNLESS(conditionTags.size() == 1, "Multi-column conditions are not supported"); + Y_ENSURE(conditionTags.size() == 1, "Multi-column conditions are not supported"); TVector<NTable::TTag> tags = conditionTags; THashSet<NTable::TTag> uniqTags(tags.begin(), tags.end()); @@ -45,10 +45,10 @@ class TBuildDistributedEraseTxOutRSUnit : public TExecutionUnit { TVector<TCell> result; for (const auto columnId : indexColumnIds) { auto it = tagToPos.find(columnId); - Y_ABORT_UNLESS(it != tagToPos.end()); + Y_ENSURE(it != tagToPos.end()); const auto pos = it->second; - Y_ABORT_UNLESS(pos < row.Size()); + Y_ENSURE(pos < row.Size()); result.push_back(row.Get(pos)); } @@ -57,7 +57,7 @@ class TBuildDistributedEraseTxOutRSUnit : public TExecutionUnit { } static bool CompareCells(const TVector<std::pair<NScheme::TTypeInfo, TRawTypeValue>>& expectedValue, const TVector<TCell>& actualValue) { - Y_ABORT_UNLESS(expectedValue.size() == actualValue.size()); + Y_ENSURE(expectedValue.size() == actualValue.size()); for (ui32 pos = 0; pos < expectedValue.size(); ++pos) { const auto& expected = expectedValue.at(pos); @@ -81,10 +81,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext&) override { - Y_ABORT_UNLESS(op->IsDistributedEraseTx()); + Y_ENSURE(op->IsDistributedEraseTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); const auto& eraseTx = tx->GetDistributedEraseTx(); if (!eraseTx->HasDependents()) { @@ -95,11 +95,11 @@ public: const ui64 tableId = request.GetTableId(); const TTableId fullTableId(DataShard.GetPathOwnerId(), tableId); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const TUserTable& tableInfo = *DataShard.GetUserTables().at(tableId); THolder<IEraseRowsCondition> condition{CreateEraseRowsCondition(request)}; - Y_ABORT_UNLESS(condition.Get()); + Y_ENSURE(condition.Get()); condition->Prepare(txc.DB.GetRowScheme(tableInfo.LocalTid), 0); const auto tags = MakeTags(condition->Tags(), eraseTx->GetIndexColumnIds()); @@ -112,8 +112,8 @@ public: TDynBitMap confirmedRows; for (ui32 i = 0; i < request.KeyColumnsSize(); ++i) { TSerializedCellVec keyCells; - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(request.GetKeyColumns(i), keyCells)); - Y_ABORT_UNLESS(keyCells.GetCells().size() == tableInfo.KeyColumnTypes.size()); + Y_ENSURE(TSerializedCellVec::TryParse(request.GetKeyColumns(i), keyCells)); + Y_ENSURE(keyCells.GetCells().size() == tableInfo.KeyColumnTypes.size()); TVector<TRawTypeValue> key; for (ui32 pos = 0; pos < tableInfo.KeyColumnTypes.size(); ++pos) { @@ -125,13 +125,13 @@ public: TSerializedCellVec indexCells; TVector<std::pair<NScheme::TTypeInfo, TRawTypeValue>> indexTypedVals; if (!eraseTx->GetIndexColumns().empty()) { - Y_ABORT_UNLESS(i < static_cast<ui32>(eraseTx->GetIndexColumns().size())); - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(eraseTx->GetIndexColumns().at(i), indexCells)); - Y_ABORT_UNLESS(indexCells.GetCells().size() == static_cast<ui32>(eraseTx->GetIndexColumnIds().size())); + Y_ENSURE(i < static_cast<ui32>(eraseTx->GetIndexColumns().size())); + Y_ENSURE(TSerializedCellVec::TryParse(eraseTx->GetIndexColumns().at(i), indexCells)); + Y_ENSURE(indexCells.GetCells().size() == static_cast<ui32>(eraseTx->GetIndexColumnIds().size())); for (ui32 pos = 0; pos < static_cast<ui32>(eraseTx->GetIndexColumnIds().size()); ++pos) { auto it = tableInfo.Columns.find(eraseTx->GetIndexColumnIds().Get(pos)); - Y_ABORT_UNLESS(it != tableInfo.Columns.end()); + Y_ENSURE(it != tableInfo.Columns.end()); const NScheme::TTypeInfo& typeInfo = it->second.Type; const TCell& cell = indexCells.GetCells()[pos]; @@ -168,9 +168,9 @@ public: for (ui64 txId : userDb.GetVolatileReadDependencies()) { op->AddVolatileDependency(txId); bool ok = DataShard.GetVolatileTxManager().AttachBlockedOperation(txId, op->GetTxId()); - Y_VERIFY_S(ok, "Unexpected failure to attach " << *op << " to volatile tx " << txId); + Y_ENSURE(ok, "Unexpected failure to attach " << *op << " to volatile tx " << txId); } - Y_ABORT_UNLESS(!txc.DB.HasChanges(), + Y_ENSURE(!txc.DB.HasChanges(), "Unexpected database changes while building distributed erase outgoing readsets"); return EExecutionStatus::Continue; } diff --git a/ydb/core/tx/datashard/build_index.cpp b/ydb/core/tx/datashard/build_index.cpp index 9823c786c1..dbc4f6070c 100644 --- a/ydb/core/tx/datashard/build_index.cpp +++ b/ydb/core/tx/datashard/build_index.cpp @@ -32,7 +32,7 @@ namespace NKikimr::NDataShard { static std::shared_ptr<NTxProxy::TUploadTypes> BuildTypes(const TUserTable& tableInfo, const NKikimrIndexBuilder::TColumnBuildSettings& buildSettings) { auto types = GetAllTypes(tableInfo); - Y_ABORT_UNLESS(buildSettings.columnSize() > 0); + Y_ENSURE(buildSettings.columnSize() > 0); auto result = std::make_shared<NTxProxy::TUploadTypes>(); result->reserve(tableInfo.KeyColumnIds.size() + buildSettings.columnSize()); @@ -320,12 +320,12 @@ private: << " ev->Sender: " << ev->Sender.ToString()); if (Uploader) { - Y_VERIFY_S(Uploader == ev->Sender, + Y_ENSURE(Uploader == ev->Sender, "Mismatch" << " Uploader: " << Uploader.ToString() << " ev->Sender: " << ev->Sender.ToString()); } else { - Y_ABORT_UNLESS(Driver == nullptr); + Y_ENSURE(Driver == nullptr); return; } @@ -446,14 +446,14 @@ public: const TUserTable& tableInfo, TUploadLimits limits) : TBuildScanUpload(buildIndexId, target, seqNo, dataShardId, progressActorId, range, tableInfo, limits) { - Y_ABORT_UNLESS(columnBuildSettings.columnSize() > 0); + Y_ENSURE(columnBuildSettings.columnSize() > 0); UploadColumnsTypes = BuildTypes(tableInfo, columnBuildSettings); UploadMode = NTxProxy::EUploadRowsMode::UpsertIfExists; TMemoryPool valueDataPool(256); TVector<TCell> cells; TString err; - Y_ABORT_UNLESS(BuildExtraColumns(cells, columnBuildSettings, err, valueDataPool)); + Y_ENSURE(BuildExtraColumns(cells, columnBuildSettings, err, valueDataPool)); ValueSerialized = TSerializedCellVec::Serialize(cells); } diff --git a/ydb/core/tx/datashard/build_kqp_data_tx_out_rs_unit.cpp b/ydb/core/tx/datashard/build_kqp_data_tx_out_rs_unit.cpp index 5aafd5a20a..cd8b00f0e0 100644 --- a/ydb/core/tx/datashard/build_kqp_data_tx_out_rs_unit.cpp +++ b/ydb/core/tx/datashard/build_kqp_data_tx_out_rs_unit.cpp @@ -45,7 +45,7 @@ EExecutionStatus TBuildKqpDataTxOutRSUnit::Execute(TOperation::TPtr op, TTransac const TActorContext& ctx) { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); DataShard.ReleaseCache(*tx); @@ -56,7 +56,7 @@ EExecutionStatus TBuildKqpDataTxOutRSUnit::Execute(TOperation::TPtr op, TTransac case ERestoreDataStatus::Restart: return EExecutionStatus::Restart; case ERestoreDataStatus::Error: - Y_ABORT("Failed to restore tx data: %s", tx->GetDataTx()->GetErrors().c_str()); + Y_ENSURE(false, "Failed to restore tx data: " << tx->GetDataTx()->GetErrors()); } } @@ -96,7 +96,7 @@ EExecutionStatus TBuildKqpDataTxOutRSUnit::Execute(TOperation::TPtr op, TTransac if (dataTx->GetKqpComputeCtx().HasPersistentChannels()) { auto result = KqpRunTransaction(ctx, op->GetTxId(), useGenericReadSets, tasksRunner); - Y_VERIFY_S(!dataTx->GetKqpComputeCtx().HadInconsistentReads(), + Y_ENSURE(!dataTx->GetKqpComputeCtx().HadInconsistentReads(), "Unexpected inconsistent reads in operation " << *op << " when preparing persistent channels"); if (result == NYql::NDq::ERunStatus::PendingInput && dataTx->GetKqpComputeCtx().IsTabletNotReady()) { @@ -131,7 +131,7 @@ EExecutionStatus TBuildKqpDataTxOutRSUnit::Execute(TOperation::TPtr op, TTransac ->AddError(NKikimrTxDataShard::TError::PROGRAM_ERROR, TStringBuilder() << "Tx was terminated: " << e.what()); return EExecutionStatus::Executed; } else { - Y_FAIL_S("Unexpected exception in KQP out-readsets prepare: " << e.what()); + throw; } } diff --git a/ydb/core/tx/datashard/build_scheme_tx_out_rs_unit.cpp b/ydb/core/tx/datashard/build_scheme_tx_out_rs_unit.cpp index deda8a6889..65dab64923 100644 --- a/ydb/core/tx/datashard/build_scheme_tx_out_rs_unit.cpp +++ b/ydb/core/tx/datashard/build_scheme_tx_out_rs_unit.cpp @@ -41,13 +41,13 @@ EExecutionStatus TBuildSchemeTxOutRSUnit::Execute(TOperation::TPtr op, const TActorContext &) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasSendSnapshot() && !schemeTx.HasCreateIncrementalBackupSrc()) return EExecutionStatus::Executed; - Y_ABORT_UNLESS(!op->InputSnapshots().empty(), "Snapshots expected"); + Y_ENSURE(!op->InputSnapshots().empty(), "Snapshots expected"); auto &outReadSets = op->OutReadSets(); ui64 srcTablet = DataShard.TabletID(); @@ -59,20 +59,20 @@ EExecutionStatus TBuildSchemeTxOutRSUnit::Execute(TOperation::TPtr op, ui64 targetTablet = snapshot.GetSendTo(0).GetShard(); ui64 tableId = snapshot.GetTableId_Deprecated(); if (snapshot.HasTableId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == snapshot.GetTableId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == snapshot.GetTableId().GetOwnerId()); tableId = snapshot.GetTableId().GetTableId(); } - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); ui32 localTableId = DataShard.GetUserTables().at(tableId)->LocalTid; for (auto &snapshot : op->InputSnapshots()) { auto* txSnapshot = dynamic_cast<TTxTableSnapshotContext*>(snapshot.Get()); - Y_ABORT_UNLESS(txSnapshot, "Unexpected input snapshot type"); + Y_ENSURE(txSnapshot, "Unexpected input snapshot type"); TString snapBody = DataShard.BorrowSnapshot(localTableId, *snapshot, { }, { }, targetTablet); txc.Env.DropSnapshot(snapshot); - Y_ABORT_UNLESS(snapBody, "Failed to make full borrow snap. w/o tx restarts"); + Y_ENSURE(snapBody, "Failed to make full borrow snap. w/o tx restarts"); TRowVersion minVersion = TRowVersion(op->GetStep(), op->GetTxId()).Next(); TRowVersion completeEdge = DataShard.GetSnapshotManager().GetCompleteEdge(); @@ -122,7 +122,7 @@ EExecutionStatus TBuildSchemeTxOutRSUnit::Execute(TOperation::TPtr op, rsBody.reserve(SnapshotTransferReadSetMagic.size() + rs.ByteSizeLong()); rsBody.append(SnapshotTransferReadSetMagic); bool ok = rs.AppendToString(&rsBody); - Y_ABORT_UNLESS(ok, "Failed to serialize schema readset"); + Y_ENSURE(ok, "Failed to serialize schema readset"); outReadSets[std::make_pair(srcTablet, targetTablet)] = rsBody; } diff --git a/ydb/core/tx/datashard/build_write_out_rs_unit.cpp b/ydb/core/tx/datashard/build_write_out_rs_unit.cpp index 446507e326..21907e469b 100644 --- a/ydb/core/tx/datashard/build_write_out_rs_unit.cpp +++ b/ydb/core/tx/datashard/build_write_out_rs_unit.cpp @@ -45,7 +45,7 @@ EExecutionStatus TBuildWriteOutRSUnit::Execute(TOperation::TPtr op, TTransaction { TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op); auto writeTx = writeOp->GetWriteTx(); - Y_ABORT_UNLESS(writeTx); + Y_ENSURE(writeTx); DataShard.ReleaseCache(*writeOp); @@ -56,7 +56,7 @@ EExecutionStatus TBuildWriteOutRSUnit::Execute(TOperation::TPtr op, TTransaction case ERestoreDataStatus::Restart: return EExecutionStatus::Restart; case ERestoreDataStatus::Error: - Y_ABORT("Failed to restore writeOp data: %s", writeTx->GetErrStr().c_str()); + Y_ENSURE(false, "Failed to restore writeOp data: " << writeTx->GetErrStr()); } } @@ -85,7 +85,7 @@ EExecutionStatus TBuildWriteOutRSUnit::Execute(TOperation::TPtr op, TTransaction writeOp->SetError(NKikimrDataEvents::TEvWriteResult::STATUS_INTERNAL_ERROR, TStringBuilder() << "Tx was terminated: " << e.what()); return EExecutionStatus::Executed; } else { - Y_FAIL_S("Unexpected exception in KQP out-readsets prepare: " << e.what()); + throw; } } diff --git a/ydb/core/tx/datashard/cdc_stream_heartbeat.cpp b/ydb/core/tx/datashard/cdc_stream_heartbeat.cpp index 0c228730c1..9c7c7e3576 100644 --- a/ydb/core/tx/datashard/cdc_stream_heartbeat.cpp +++ b/ydb/core/tx/datashard/cdc_stream_heartbeat.cpp @@ -148,7 +148,7 @@ bool TCdcStreamHeartbeatManager::Load(NIceDb::TNiceDb& db) { rowset.GetValue<Schema::CdcStreamHeartbeats::LastTxId>() ); - Y_ABORT_UNLESS(!CdcStreams.contains(streamPathId)); + Y_ENSURE(!CdcStreams.contains(streamPathId)); CdcStreams.emplace(streamPathId, THeartbeatInfo{ .TablePathId = tablePathId, .Interval = interval, @@ -170,7 +170,7 @@ void TCdcStreamHeartbeatManager::AddCdcStream(NTable::TDatabase& db, { const auto last = TRowVersion::Min(); - Y_ABORT_UNLESS(!CdcStreams.contains(streamPathId)); + Y_ENSURE(!CdcStreams.contains(streamPathId)); auto res = CdcStreams.emplace(streamPathId, THeartbeatInfo{ .TablePathId = tablePathId, .Interval = heartbeatInterval, @@ -239,7 +239,7 @@ THashMap<TPathId, TCdcStreamHeartbeatManager::THeartbeatInfo> TCdcStreamHeartbea } auto it = CdcStreams.find(top.StreamPathId); - Y_ABORT_UNLESS(it != CdcStreams.end()); + Y_ENSURE(it != CdcStreams.end()); const auto& streamPathId = it->first; auto& info = it->second; diff --git a/ydb/core/tx/datashard/cdc_stream_scan.cpp b/ydb/core/tx/datashard/cdc_stream_scan.cpp index ece5fe82ea..77cb3daf76 100644 --- a/ydb/core/tx/datashard/cdc_stream_scan.cpp +++ b/ydb/core/tx/datashard/cdc_stream_scan.cpp @@ -44,7 +44,7 @@ bool TCdcStreamScanManager::Load(NIceDb::TNiceDb& db) { rowset.GetValue<Schema::CdcStreamScans::StreamPathId>() ); - Y_ABORT_UNLESS(!Scans.contains(streamPathId)); + Y_ENSURE(!Scans.contains(streamPathId)); auto& info = Scans[streamPathId]; info.SnapshotVersion = TRowVersion( @@ -54,7 +54,7 @@ bool TCdcStreamScanManager::Load(NIceDb::TNiceDb& db) { if (rowset.HaveValue<Schema::CdcStreamScans::LastKey>()) { info.LastKey.ConstructInPlace(); - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(rowset.GetValue<Schema::CdcStreamScans::LastKey>(), *info.LastKey)); + Y_ENSURE(TSerializedCellVec::TryParse(rowset.GetValue<Schema::CdcStreamScans::LastKey>(), *info.LastKey)); } info.Stats.RowsProcessed = rowset.GetValueOrDefault<Schema::CdcStreamScans::RowsProcessed>(0); @@ -71,7 +71,7 @@ bool TCdcStreamScanManager::Load(NIceDb::TNiceDb& db) { void TCdcStreamScanManager::Add(NTable::TDatabase& db, const TPathId& tablePathId, const TPathId& streamPathId, const TRowVersion& snapshotVersion) { - Y_ABORT_UNLESS(!Scans.contains(streamPathId)); + Y_ENSURE(!Scans.contains(streamPathId)); auto& info = Scans[streamPathId]; info.SnapshotVersion = snapshotVersion; @@ -85,7 +85,7 @@ void TCdcStreamScanManager::Forget(NTable::TDatabase& db, const TPathId& tablePa } void TCdcStreamScanManager::Enqueue(const TPathId& streamPathId, ui64 txId, ui64 scanId) { - Y_ABORT_UNLESS(Scans.contains(streamPathId)); + Y_ENSURE(Scans.contains(streamPathId)); auto& info = Scans.at(streamPathId); info.TxId = txId; info.ScanId = scanId; @@ -93,7 +93,7 @@ void TCdcStreamScanManager::Enqueue(const TPathId& streamPathId, ui64 txId, ui64 } void TCdcStreamScanManager::Register(ui64 txId, const TActorId& actorId) { - Y_ABORT_UNLESS(TxIdToPathId.contains(txId)); + Y_ENSURE(TxIdToPathId.contains(txId)); Scans[TxIdToPathId.at(txId)].ActorId = actorId; } @@ -109,7 +109,7 @@ void TCdcStreamScanManager::Complete(const TPathId& streamPathId) { } void TCdcStreamScanManager::Complete(ui64 txId) { - Y_ABORT_UNLESS(TxIdToPathId.contains(txId)); + Y_ENSURE(TxIdToPathId.contains(txId)); Complete(TxIdToPathId.at(txId)); } @@ -118,7 +118,7 @@ bool TCdcStreamScanManager::IsCompleted(const TPathId& streamPathId) const { } const TCdcStreamScanManager::TStats& TCdcStreamScanManager::GetCompletedStats(const TPathId& streamPathId) const { - Y_ABORT_UNLESS(CompletedScans.contains(streamPathId)); + Y_ENSURE(CompletedScans.contains(streamPathId)); return CompletedScans.at(streamPathId); } @@ -188,11 +188,11 @@ class TDataShard::TTxCdcStreamScanProgress static TVector<TUpdateOp> MakeUpdates(TArrayRef<const TCell> cells, TArrayRef<const TTag> tags, TUserTable::TCPtr table) { TVector<TUpdateOp> updates(Reserve(cells.size())); - Y_ABORT_UNLESS(cells.size() == tags.size()); + Y_ENSURE(cells.size() == tags.size()); for (TPos pos = 0; pos < cells.size(); ++pos) { const auto tag = tags.at(pos); auto it = table->Columns.find(tag); - Y_ABORT_UNLESS(it != table->Columns.end()); + Y_ENSURE(it != table->Columns.end()); updates.emplace_back(tag, ECellOp::Set, TRawTypeValue(cells.at(pos).AsRef(), it->second.Type.GetTypeId())); } @@ -318,7 +318,7 @@ public: break; } default: - Y_FAIL_S("Invalid stream mode: " << static_cast<ui32>(it->second.Mode)); + Y_ENSURE(false, "Invalid stream mode: " << static_cast<ui32>(it->second.Mode)); } auto recordPtr = TChangeRecordBuilder(TChangeRecord::EKind::CdcDataChange) @@ -356,7 +356,7 @@ public: const auto& [key, _] = ev.Rows.back(); auto* info = Self->CdcStreamScanManager.Get(streamPathId); - Y_ABORT_UNLESS(info); + Y_ENSURE(info); info->LastKey = key; info->Stats = ev.Stats; @@ -466,7 +466,7 @@ public: IScan::TInitialState Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) override { TlsActivationContext->AsActorContext().RegisterWithSameMailbox(this); Driver = driver; - Y_ABORT_UNLESS(!LastKey || LastKey->GetCells().size() == scheme->Tags(true).size()); + Y_ENSURE(!LastKey || LastKey->GetCells().size() == scheme->Tags(true).size()); return {EScan::Feed, {}}; } @@ -655,7 +655,7 @@ public: } const auto* info = Self->CdcStreamScanManager.Get(streamPathId); - Y_ABORT_UNLESS(info); + Y_ENSURE(info); auto* appData = AppData(ctx); const auto& taskName = appData->DataShardConfig.GetCdcInitialScanTaskName(); @@ -672,10 +672,10 @@ public: } const auto snapshotVersion = TRowVersion(snapshotKey.Step, snapshotKey.TxId); - Y_ABORT_UNLESS(info->SnapshotVersion == snapshotVersion); + Y_ENSURE(info->SnapshotVersion == snapshotVersion); // Note: cdc stream is added with a schema transaction and those wait for volatile txs - Y_ABORT_UNLESS(!Self->GetVolatileTxManager().HasVolatileTxsAtSnapshot(snapshotVersion)); + Y_ENSURE(!Self->GetVolatileTxManager().HasVolatileTxsAtSnapshot(snapshotVersion)); const ui64 localTxId = Self->NextTieBreakerIndex++; auto scan = MakeHolder<TCdcStreamScan>(Self, Request->Sender, localTxId, diff --git a/ydb/core/tx/datashard/change_collector.cpp b/ydb/core/tx/datashard/change_collector.cpp index 56f4e673ba..7e5e707de4 100644 --- a/ydb/core/tx/datashard/change_collector.cpp +++ b/ydb/core/tx/datashard/change_collector.cpp @@ -114,9 +114,9 @@ public: void AddChange(const TTableId& tableId, const TPathId& pathId, TChangeRecord::EKind kind, const TDataChange& body) override { NIceDb::TNiceDb db(Db); - Y_VERIFY_S(Self->IsUserTable(tableId), "Unknown table: " << tableId); + Y_ENSURE(Self->IsUserTable(tableId), "Unknown table: " << tableId); auto userTable = Self->GetUserTables().at(tableId.PathId.LocalPathId); - Y_ABORT_UNLESS(userTable->GetTableSchemaVersion()); + Y_ENSURE(userTable->GetTableSchemaVersion()); TChangeRecordBuilder builder(kind); if (!WriteTxId) { @@ -207,7 +207,7 @@ IDataShardChangeCollector* CreateChangeCollector( NTable::TDatabase& db, ui64 tableId) { - Y_ABORT_UNLESS(dataShard.GetUserTables().contains(tableId)); + Y_ENSURE(dataShard.GetUserTables().contains(tableId)); const TUserTable& tableInfo = *dataShard.GetUserTables().at(tableId); return CreateChangeCollector(dataShard, userDb, groupProvider, db, tableInfo); } diff --git a/ydb/core/tx/datashard/change_collector_async_index.cpp b/ydb/core/tx/datashard/change_collector_async_index.cpp index 3b09a82a0c..2860a5090b 100644 --- a/ydb/core/tx/datashard/change_collector_async_index.cpp +++ b/ydb/core/tx/datashard/change_collector_async_index.cpp @@ -35,8 +35,8 @@ public: } } - Y_ABORT_UNLESS(!tags.empty()); - Y_ABORT_UNLESS(!IndexTags.empty()); + Y_ENSURE(!tags.empty()); + Y_ENSURE(!IndexTags.empty()); return TCachedTags(std::move(tags), std::make_pair(0, IndexTags.size() - 1)); } @@ -70,10 +70,10 @@ bool TAsyncIndexChangeCollector::NeedToReadKeys() const { bool TAsyncIndexChangeCollector::Collect(const TTableId& tableId, ERowOp rop, TArrayRef<const TRawTypeValue> key, TArrayRef<const TUpdateOp> updates) { - Y_VERIFY_S(Self->IsUserTable(tableId), "Unknown table: " << tableId); + Y_ENSURE(Self->IsUserTable(tableId), "Unknown table: " << tableId); auto userTable = Self->GetUserTables().at(tableId.PathId.LocalPathId); - Y_VERIFY_S(key.size() == userTable->KeyColumnIds.size(), "Count doesn't match" + Y_ENSURE(key.size() == userTable->KeyColumnIds.size(), "Count doesn't match" << ": key# " << key.size() << ", tags# " << userTable->KeyColumnIds.size()); @@ -83,7 +83,7 @@ bool TAsyncIndexChangeCollector::Collect(const TTableId& tableId, ERowOp rop, case ERowOp::Reset: break; default: - Y_FAIL_S("Unsupported row op: " << static_cast<ui8>(rop)); + Y_ENSURE(false, "Unsupported row op: " << static_cast<ui8>(rop)); } const auto tagsToSelect = GetTagsToSelect(tableId, rop); @@ -114,8 +114,8 @@ bool TAsyncIndexChangeCollector::Collect(const TTableId& tableId, ERowOp rop, needDeletion = true; } - Y_ABORT_UNLESS(tagToPos.contains(tag)); - Y_ABORT_UNLESS(userTable->Columns.contains(tag)); + Y_ENSURE(tagToPos.contains(tag)); + Y_ENSURE(userTable->Columns.contains(tag)); AddCellValue(KeyVals, tag, row.Get(tagToPos.at(tag)), userTable->Columns.at(tag).Type); KeyTagsSeen.insert(tag); } @@ -143,14 +143,14 @@ bool TAsyncIndexChangeCollector::Collect(const TTableId& tableId, ERowOp rop, AddValue(KeyVals, updates.at(updatedTagToPos.at(tag))); KeyTagsSeen.insert(tag); } else { - Y_ABORT_UNLESS(userTable->Columns.contains(tag)); + Y_ENSURE(userTable->Columns.contains(tag)); const auto& column = userTable->Columns.at(tag); if (rop == ERowOp::Reset && !column.IsKey) { AddNullValue(KeyVals, tag, column.Type); KeyTagsSeen.insert(tag); } else { - Y_ABORT_UNLESS(tagToPos.contains(tag)); + Y_ENSURE(tagToPos.contains(tag)); AddCellValue(KeyVals, tag, row.Get(tagToPos.at(tag)), column.Type); KeyTagsSeen.insert(tag); } @@ -169,13 +169,13 @@ bool TAsyncIndexChangeCollector::Collect(const TTableId& tableId, ERowOp rop, needUpdate = true; AddValue(DataVals, updates.at(updatedTagToPos.at(tag))); } else { - Y_ABORT_UNLESS(userTable->Columns.contains(tag)); + Y_ENSURE(userTable->Columns.contains(tag)); const auto& column = userTable->Columns.at(tag); if (rop == ERowOp::Reset && !column.IsKey) { AddNullValue(DataVals, tag, column.Type); } else { - Y_ABORT_UNLESS(tagToPos.contains(tag)); + Y_ENSURE(tagToPos.contains(tag)); AddCellValue(DataVals, tag, row.Get(tagToPos.at(tag)), column.Type); } } @@ -193,7 +193,7 @@ bool TAsyncIndexChangeCollector::Collect(const TTableId& tableId, ERowOp rop, } auto TAsyncIndexChangeCollector::CacheTags(const TTableId& tableId) const { - Y_ABORT_UNLESS(Self->GetUserTables().contains(tableId.PathId.LocalPathId)); + Y_ENSURE(Self->GetUserTables().contains(tableId.PathId.LocalPathId)); auto userTable = Self->GetUserTables().at(tableId.PathId.LocalPathId); TCachedTagsBuilder builder; @@ -219,12 +219,12 @@ TArrayRef<TTag> TAsyncIndexChangeCollector::GetTagsToSelect(const TTableId& tabl case ERowOp::Reset: return it->second.IndexColumns; default: - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } } void TAsyncIndexChangeCollector::AddValue(TVector<TUpdateOp>& out, const TUpdateOp& update) { - Y_VERIFY_S(update.Op == ECellOp::Set, "Unexpected op: " << update.Op.Raw()); + Y_ENSURE(update.Op == ECellOp::Set, "Unexpected op: " << update.Op.Raw()); out.push_back(update); } diff --git a/ydb/core/tx/datashard/change_collector_cdc_stream.cpp b/ydb/core/tx/datashard/change_collector_cdc_stream.cpp index fb82c3edbf..2087a0ea1a 100644 --- a/ydb/core/tx/datashard/change_collector_cdc_stream.cpp +++ b/ydb/core/tx/datashard/change_collector_cdc_stream.cpp @@ -49,8 +49,8 @@ namespace { auto MakeUpdates(TArrayRef<const TCell> cells, TArrayRef<const TTag> tags, TArrayRef<const NScheme::TTypeInfo> types) { TVector<TUpdateOp> result(Reserve(cells.size())); - Y_ABORT_UNLESS(cells.size() == tags.size()); - Y_ABORT_UNLESS(cells.size() == types.size()); + Y_ENSURE(cells.size() == tags.size()); + Y_ENSURE(cells.size() == types.size()); for (TPos pos = 0; pos < cells.size(); ++pos) { result.emplace_back(tags.at(pos), ECellOp::Set, TRawTypeValue(cells.at(pos).AsRef(), types.at(pos).GetTypeId())); @@ -88,7 +88,7 @@ namespace { case ERowOp::Erase: return nullptr; default: - Y_FAIL_S("Unexpected row op: " << static_cast<int>(state->GetRowState())); + Y_ENSURE(false, "Unexpected row op: " << static_cast<int>(state->GetRowState())); } } @@ -139,7 +139,7 @@ bool TCdcStreamChangeCollector::NeedToReadKeys() const { value = true; break; default: - Y_FAIL_S("Invalid stream mode: " << static_cast<ui32>(streamInfo.Mode)); + Y_ENSURE(false, "Invalid stream mode: " << static_cast<ui32>(streamInfo.Mode)); } } } @@ -151,7 +151,7 @@ bool TCdcStreamChangeCollector::NeedToReadKeys() const { bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, TArrayRef<const TRawTypeValue> key, TArrayRef<const TUpdateOp> updates) { - Y_VERIFY_S(Self->IsUserTable(tableId), "Unknown table: " << tableId); + Y_ENSURE(Self->IsUserTable(tableId), "Unknown table: " << tableId); auto userTable = Self->GetUserTables().at(tableId.PathId.LocalPathId); const auto& keyTags = userTable->KeyColumnIds; @@ -159,7 +159,7 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, const auto valueTags = MakeValueTags(userTable->Columns); const auto valueTypes = MakeValueTypes(userTable->Columns); - Y_VERIFY_S(key.size() == keyTags.size(), "Count doesn't match" + Y_ENSURE(key.size() == keyTags.size(), "Count doesn't match" << ": key# " << key.size() << ", tags# " << keyTags.size()); @@ -169,7 +169,7 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, case ERowOp::Reset: break; default: - Y_FAIL_S("Unsupported row op: " << static_cast<ui8>(rop)); + Y_ENSURE(false, "Unsupported row op: " << static_cast<ui8>(rop)); } for (const auto& [pathId, stream] : userTable->CdcStreams) { @@ -200,8 +200,8 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, const auto& lastKeyCells = info->LastKey->GetCells(); const auto keyCells = MakeKeyCells(key); - Y_ABORT_UNLESS(keyCells.size() == lastKeyCells.size()); - Y_ABORT_UNLESS(keyCells.size() == keyTypes.size()); + Y_ENSURE(keyCells.size() == lastKeyCells.size()); + Y_ENSURE(keyCells.size() == keyTypes.size()); const int cmp = CompareTypedCellVectors(keyCells.data(), lastKeyCells.data(), keyTypes.data(), keyCells.size()); if (cmp > 0) { @@ -217,7 +217,7 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, } if (initialState) { - Y_ABORT_UNLESS(snapshotVersion.Defined()); + Y_ENSURE(snapshotVersion.Defined()); TVersionContext ctx(Sink, *snapshotVersion); switch (stream.Mode) { @@ -228,7 +228,7 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, Persist(tableId, pathId, ERowOp::Upsert, key, keyTags, MakeUpdates(**initialState, valueTags, valueTypes)); break; case NKikimrSchemeOp::ECdcStreamModeRestoreIncrBackup: { - Y_FAIL_S("Invariant violation: source table must be locked before restore."); + Y_ENSURE(false, "Invariant violation: source table must be locked before restore."); break; } case NKikimrSchemeOp::ECdcStreamModeNewImage: @@ -239,7 +239,7 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, Persist(tableId, pathId, ERowOp::Upsert, key, keyTags, &*initialState, nullptr, valueTags); break; default: - Y_FAIL_S("Invalid stream mode: " << static_cast<ui32>(stream.Mode)); + Y_ENSURE(false, "Invalid stream mode: " << static_cast<ui32>(stream.Mode)); } } @@ -251,7 +251,7 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, Persist(tableId, pathId, rop, key, keyTags, updates); break; case NKikimrSchemeOp::ECdcStreamModeRestoreIncrBackup: - Y_FAIL_S("Invariant violation: source table must be locked before restore."); + Y_ENSURE(false, "Invariant violation: source table must be locked before restore."); case NKikimrSchemeOp::ECdcStreamModeNewImage: case NKikimrSchemeOp::ECdcStreamModeOldImage: case NKikimrSchemeOp::ECdcStreamModeNewAndOldImages: @@ -271,7 +271,7 @@ bool TCdcStreamChangeCollector::Collect(const TTableId& tableId, ERowOp rop, } break; default: - Y_FAIL_S("Invalid stream mode: " << static_cast<ui32>(stream.Mode)); + Y_ENSURE(false, "Invalid stream mode: " << static_cast<ui32>(stream.Mode)); } } @@ -325,10 +325,10 @@ TRowState TCdcStreamChangeCollector::PatchState(const TRowState& oldState, ERowO case ERowOp::Erase: break; default: - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } - Y_ABORT_UNLESS(newState.IsFinalized()); + Y_ENSURE(newState.IsFinalized()); return newState; } diff --git a/ydb/core/tx/datashard/change_exchange_split.cpp b/ydb/core/tx/datashard/change_exchange_split.cpp index 93e6d68a3b..7db238e8fa 100644 --- a/ydb/core/tx/datashard/change_exchange_split.cpp +++ b/ydb/core/tx/datashard/change_exchange_split.cpp @@ -300,10 +300,10 @@ class TCdcWorker return Ack(); } - Y_ABORT_UNLESS(entry.ListNodeEntry->Children.size() == 1); + Y_ENSURE(entry.ListNodeEntry->Children.size() == 1); const auto& topic = entry.ListNodeEntry->Children.at(0); - Y_ABORT_UNLESS(topic.Kind == TNavigate::KindTopic); + Y_ENSURE(topic.Kind == TNavigate::KindTopic); ResolveTopic(topic.PathId); } @@ -522,7 +522,7 @@ class TChangeExchageSplit: public TActorBootstrapped<TChangeExchageSplit> { case EWorkerType::CdcStream: return Register(new TCdcWorker(SelfId(), pathId, DataShard.TabletId, DstDataShards)); case EWorkerType::AsyncIndex: - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } } diff --git a/ydb/core/tx/datashard/change_record.cpp b/ydb/core/tx/datashard/change_record.cpp index c087125ddc..4cb8012128 100644 --- a/ydb/core/tx/datashard/change_record.cpp +++ b/ydb/core/tx/datashard/change_record.cpp @@ -16,15 +16,15 @@ void TChangeRecord::Serialize(NKikimrChangeExchange::TChangeRecord& record) cons switch (Kind) { case EKind::AsyncIndex: { - Y_ABORT_UNLESS(record.MutableAsyncIndex()->ParseFromArray(Body.data(), Body.size())); + Y_ENSURE(record.MutableAsyncIndex()->ParseFromArray(Body.data(), Body.size())); break; } case EKind::IncrementalRestore: { - Y_ABORT_UNLESS(record.MutableIncrementalRestore()->ParseFromArray(Body.data(), Body.size())); + Y_ENSURE(record.MutableIncrementalRestore()->ParseFromArray(Body.data(), Body.size())); break; } case EKind::CdcDataChange: { - Y_ABORT_UNLESS(record.MutableCdcDataChange()->ParseFromArray(Body.data(), Body.size())); + Y_ENSURE(record.MutableCdcDataChange()->ParseFromArray(Body.data(), Body.size())); break; } case EKind::CdcHeartbeat: { @@ -35,7 +35,7 @@ void TChangeRecord::Serialize(NKikimrChangeExchange::TChangeRecord& record) cons static auto ParseBody(const TString& protoBody) { NKikimrChangeExchange::TDataChange body; - Y_ABORT_UNLESS(body.ParseFromArray(protoBody.data(), protoBody.size())); + Y_ENSURE(body.ParseFromArray(protoBody.data(), protoBody.size())); return body; } @@ -51,23 +51,23 @@ TConstArrayRef<TCell> TChangeRecord::GetKey() const { const auto parsed = ParseBody(Body); TSerializedCellVec key; - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(parsed.GetKey().GetData(), key)); + Y_ENSURE(TSerializedCellVec::TryParse(parsed.GetKey().GetData(), key)); Key.ConstructInPlace(key.GetCells()); break; } case EKind::CdcHeartbeat: { - Y_ABORT("Not supported"); + Y_ENSURE(false, "Not supported"); } } - Y_ABORT_UNLESS(Key); + Y_ENSURE(Key); return *Key; } i64 TChangeRecord::GetSeqNo() const { - Y_ABORT_UNLESS(Order <= Max<i64>()); + Y_ENSURE(Order <= Max<i64>()); return static_cast<i64>(Order); } diff --git a/ydb/core/tx/datashard/change_record_body_serializer.cpp b/ydb/core/tx/datashard/change_record_body_serializer.cpp index ccd196d503..a1ae4a0c0a 100644 --- a/ydb/core/tx/datashard/change_record_body_serializer.cpp +++ b/ydb/core/tx/datashard/change_record_body_serializer.cpp @@ -9,7 +9,7 @@ using namespace NTable; void TChangeRecordBodySerializer::SerializeCells(TSerializedCells& out, TArrayRef<const TRawTypeValue> in, TArrayRef<const TTag> tags) { - Y_VERIFY_S(in.size() == tags.size(), "Count doesn't match" + Y_ENSURE(in.size() == tags.size(), "Count doesn't match" << ": in# " << in.size() << ", tags# " << tags.size()); @@ -31,7 +31,7 @@ void TChangeRecordBodySerializer::SerializeCells(TSerializedCells& out, TVector<TCell> cells(Reserve(in.size())); for (const auto& op : in) { - Y_VERIFY_S(op.Op == ECellOp::Set, "Unexpected cell op: " << op.Op.Raw()); + Y_ENSURE(op.Op == ECellOp::Set, "Unexpected cell op: " << op.Op.Raw()); out.AddTags(op.Tag); cells.emplace_back(op.AsCell()); @@ -43,7 +43,7 @@ void TChangeRecordBodySerializer::SerializeCells(TSerializedCells& out, void TChangeRecordBodySerializer::SerializeCells(TSerializedCells& out, const TRowState& state, TArrayRef<const TTag> tags) { - Y_VERIFY_S(state.Size() == tags.size(), "Count doesn't match" + Y_ENSURE(state.Size() == tags.size(), "Count doesn't match" << ": state# " << state.Size() << ", tags# " << tags.size()); @@ -72,7 +72,7 @@ void TChangeRecordBodySerializer::Serialize(TDataChange& out, ERowOp rop, SerializeCells(*out.MutableReset(), updates); break; default: - Y_FAIL_S("Unsupported row op: " << static_cast<ui8>(rop)); + Y_ENSURE(false, "Unsupported row op: " << static_cast<ui8>(rop)); } } diff --git a/ydb/core/tx/datashard/change_record_cdc_serializer.cpp b/ydb/core/tx/datashard/change_record_cdc_serializer.cpp index 162b3f922b..b8549fc08a 100644 --- a/ydb/core/tx/datashard/change_record_cdc_serializer.cpp +++ b/ydb/core/tx/datashard/change_record_cdc_serializer.cpp @@ -63,7 +63,7 @@ public: return SerializeHeartbeat(cmd, record); case TChangeRecord::EKind::AsyncIndex: case TChangeRecord::EKind::IncrementalRestore: - Y_ABORT("Unexpected"); + Y_ENSURE(false, "Unexpected"); } } @@ -108,26 +108,26 @@ class TJsonSerializer: public TBaseSerializer { protected: static auto ParseBody(const TString& protoBody) { NKikimrChangeExchange::TDataChange body; - Y_ABORT_UNLESS(body.ParseFromArray(protoBody.data(), protoBody.size())); + Y_ENSURE(body.ParseFromArray(protoBody.data(), protoBody.size())); return body; } static NJson::TJsonValue StringToJson(TStringBuf in) { NJson::TJsonValue result; - Y_ABORT_UNLESS(NJson::ReadJsonTree(in, &result)); + Y_ENSURE(NJson::ReadJsonTree(in, &result)); return result; } static NJson::TJsonValue YsonToJson(TStringBuf in) { NJson::TJsonValue result; - Y_ABORT_UNLESS(NJson2Yson::DeserializeYsonAsJsonValue(in, &result)); + Y_ENSURE(NJson2Yson::DeserializeYsonAsJsonValue(in, &result)); return result; } static NJson::TJsonValue UuidToJson(const TCell& cell) { TStringStream ss; ui16 dw[8]; - Y_ABORT_UNLESS(cell.Size() == 16); + Y_ENSURE(cell.Size() == 16); cell.CopyDataInto((char*)dw); NUuid::UuidToString(dw, ss); return NJson::TJsonValue(ss.Str()); @@ -196,22 +196,22 @@ protected: case NScheme::NTypeIds::Uuid: return UuidToJson(cell); default: - Y_ABORT("Unexpected type"); + Y_ENSURE(false, "Unexpected type"); } } static void SerializeJsonKey(TUserTable::TCPtr schema, NJson::TJsonValue& key, const NKikimrChangeExchange::TDataChange::TSerializedCells& in) { - Y_ABORT_UNLESS(in.TagsSize() == schema->KeyColumnIds.size()); + Y_ENSURE(in.TagsSize() == schema->KeyColumnIds.size()); for (size_t i = 0; i < schema->KeyColumnIds.size(); ++i) { - Y_ABORT_UNLESS(in.GetTags(i) == schema->KeyColumnIds.at(i)); + Y_ENSURE(in.GetTags(i) == schema->KeyColumnIds.at(i)); } TSerializedCellVec cells; - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(in.GetData(), cells)); + Y_ENSURE(TSerializedCellVec::TryParse(in.GetData(), cells)); - Y_ABORT_UNLESS(cells.GetCells().size() == schema->KeyColumnTypes.size()); + Y_ENSURE(cells.GetCells().size() == schema->KeyColumnTypes.size()); for (size_t i = 0; i < schema->KeyColumnTypes.size(); ++i) { const auto type = schema->KeyColumnTypes.at(i); const auto& cell = cells.GetCells().at(i); @@ -223,15 +223,15 @@ protected: const NKikimrChangeExchange::TDataChange::TSerializedCells& in) { TSerializedCellVec cells; - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(in.GetData(), cells)); - Y_ABORT_UNLESS(in.TagsSize() == cells.GetCells().size()); + Y_ENSURE(TSerializedCellVec::TryParse(in.GetData(), cells)); + Y_ENSURE(in.TagsSize() == cells.GetCells().size()); for (ui32 i = 0; i < in.TagsSize(); ++i) { const auto tag = in.GetTags(i); const auto& cell = cells.GetCells().at(i); auto it = schema->Columns.find(tag); - Y_ABORT_UNLESS(it != schema->Columns.end()); + Y_ENSURE(it != schema->Columns.end()); const auto& column = it->second; value.InsertValue(column.Name, ToJson(cell, column.Type)); @@ -239,7 +239,7 @@ protected: } static void ExtendJson(NJson::TJsonValue& value, const NJson::TJsonValue& ext) { - Y_ABORT_UNLESS(ext.GetType() == NJson::JSON_MAP); + Y_ENSURE(ext.GetType() == NJson::JSON_MAP); for (const auto& [k, v] : ext.GetMapSafe()) { value.InsertValue(k, v); } @@ -304,19 +304,19 @@ protected: return SerializeVirtualTimestamp(json["resolved"], {record.GetStep(), record.GetTxId()}); } - Y_ABORT_UNLESS(record.GetSchema()); + Y_ENSURE(record.GetSchema()); const auto body = ParseBody(record.GetBody()); switch (record.GetKind()) { case TChangeRecord::EKind::AsyncIndex: - Y_ABORT_UNLESS(Opts.Debug); + Y_ENSURE(Opts.Debug); SerializeJsonValue(record.GetSchema(), json["key"], body.GetKey()); break; case TChangeRecord::EKind::CdcDataChange: SerializeJsonKey(record.GetSchema(), json["key"], body.GetKey()); break; default: - Y_ABORT("Unexpected record"); + Y_ENSURE(false, "Unexpected record"); } if (body.HasOldImage()) { @@ -345,7 +345,7 @@ protected: json["erase"].SetType(NJson::JSON_MAP); break; default: - Y_FAIL_S("Unexpected row operation: " << static_cast<int>(body.GetRowOperationCase())); + Y_ENSURE(false, "Unexpected row operation: " << static_cast<int>(body.GetRowOperationCase())); } if (Opts.VirtualTimestamps) { @@ -363,8 +363,8 @@ class TDynamoDBStreamsJsonSerializer: public TJsonSerializer { const NKikimrChangeExchange::TDataChange::TSerializedCells& in) { TSerializedCellVec cells; - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(in.GetData(), cells)); - Y_ABORT_UNLESS(in.TagsSize() == cells.GetCells().size()); + Y_ENSURE(TSerializedCellVec::TryParse(in.GetData(), cells)); + Y_ENSURE(in.TagsSize() == cells.GetCells().size()); for (ui32 i = 0; i < in.TagsSize(); ++i) { const auto tag = in.GetTags(i); @@ -375,7 +375,7 @@ class TDynamoDBStreamsJsonSerializer: public TJsonSerializer { } auto it = schema->Columns.find(tag); - Y_ABORT_UNLESS(it != schema->Columns.end()); + Y_ENSURE(it != schema->Columns.end()); const auto& column = it->second; const auto& name = column.Name; @@ -389,7 +389,7 @@ class TDynamoDBStreamsJsonSerializer: public TJsonSerializer { if (index.Type != TUserTable::TTableIndex::EType::EIndexTypeGlobalAsync) { continue; } - Y_ABORT_UNLESS(index.KeyColumnIds.size() >= 1); + Y_ENSURE(index.KeyColumnIds.size() >= 1); if (index.KeyColumnIds.at(0) == tag) { indexed = true; break; @@ -425,8 +425,8 @@ class TDynamoDBStreamsJsonSerializer: public TJsonSerializer { protected: void SerializeToJson(NJson::TJsonValue& json, const TChangeRecord& record) override { - Y_ABORT_UNLESS(record.GetKind() == TChangeRecord::EKind::CdcDataChange); - Y_ABORT_UNLESS(record.GetSchema()); + Y_ENSURE(record.GetKind() == TChangeRecord::EKind::CdcDataChange); + Y_ENSURE(record.GetSchema()); json = NJson::TJsonMap({ {"awsRegion", Opts.AwsRegion}, @@ -488,7 +488,7 @@ protected: json["eventName"] = "REMOVE"; break; default: - Y_FAIL_S("Unexpected row operation: " << static_cast<int>(body.GetRowOperationCase())); + Y_ENSURE(false, "Unexpected row operation: " << static_cast<int>(body.GetRowOperationCase())); } } @@ -500,8 +500,8 @@ public: class TDebeziumJsonSerializer: public TJsonSerializer { protected: void SerializeToJson(NJson::TJsonValue& json, const TChangeRecord& record) override { - Y_ABORT_UNLESS(record.GetKind() == TChangeRecord::EKind::CdcDataChange); - Y_ABORT_UNLESS(record.GetSchema()); + Y_ENSURE(record.GetKind() == TChangeRecord::EKind::CdcDataChange); + Y_ENSURE(record.GetSchema()); const auto body = ParseBody(record.GetBody()); auto& keyJson = json["key"]; @@ -538,7 +538,7 @@ protected: valueJson["payload"]["op"] = "d"; // d = delete break; default: - Y_FAIL_S("Unexpected row operation: " << static_cast<int>(body.GetRowOperationCase())); + Y_ENSURE(false, "Unexpected row operation: " << static_cast<int>(body.GetRowOperationCase())); } } @@ -592,7 +592,7 @@ IChangeRecordSerializer* CreateChangeRecordSerializer(const TChangeRecordSeriali case TUserTable::TCdcStream::EFormat::ECdcStreamFormatDebeziumJson: return new TDebeziumJsonSerializer(opts); default: - Y_ABORT("Unsupported format"); + Y_ENSURE(false, "Unsupported format"); } } @@ -605,8 +605,8 @@ TString TChangeRecord::GetPartitionKey() const { return *PartitionKey; } - Y_ABORT_UNLESS(Kind == EKind::CdcDataChange); - Y_ABORT_UNLESS(Schema); + Y_ENSURE(Kind == EKind::CdcDataChange); + Y_ENSURE(Schema); const auto body = TJsonSerializer::ParseBody(Body); diff --git a/ydb/core/tx/datashard/change_sender.cpp b/ydb/core/tx/datashard/change_sender.cpp index d1c5e8c403..95c31117fe 100644 --- a/ydb/core/tx/datashard/change_sender.cpp +++ b/ydb/core/tx/datashard/change_sender.cpp @@ -107,8 +107,8 @@ class TChangeSender: public TActor<TChangeSender> { auto it = Senders.find(msg.PathId); if (it != Senders.end()) { - Y_ABORT_UNLESS(it->second.UserTableId == msg.UserTableId); - Y_ABORT_UNLESS(it->second.Type == msg.Type); + Y_ENSURE(it->second.UserTableId == msg.UserTableId); + Y_ENSURE(it->second.Type == msg.Type); LOG_W("Trying to add duplicate sender" << ": userTableId# " << msg.UserTableId << ", type# " << msg.Type diff --git a/ydb/core/tx/datashard/change_sender_async_index.cpp b/ydb/core/tx/datashard/change_sender_async_index.cpp index 55a5bae872..fee947e8d0 100644 --- a/ydb/core/tx/datashard/change_sender_async_index.cpp +++ b/ydb/core/tx/datashard/change_sender_async_index.cpp @@ -80,10 +80,10 @@ private: return AsDerived()->OnIndexUnderRemove(); } - Y_ABORT_UNLESS(entry.ListNodeEntry->Children.size() == 1); + Y_ENSURE(entry.ListNodeEntry->Children.size() == 1); const auto& indexTable = entry.ListNodeEntry->Children.at(0); - Y_ABORT_UNLESS(indexTable.Kind == TNavigate::KindTable); + Y_ENSURE(indexTable.Kind == TNavigate::KindTable); AsDerived()->TargetTablePathId = indexTable.PathId; AsDerived()->NextState(TStateTag{}); @@ -247,7 +247,7 @@ class TAsyncIndexChangeSenderMain void Handle(TEvChangeExchange::TEvRemoveSender::TPtr& ev) { LOG_D("Handle " << ev->Get()->ToString()); - Y_ABORT_UNLESS(ev->Get()->PathId == GetChangeSenderIdentity()); + Y_ENSURE(ev->Get()->PathId == GetChangeSenderIdentity()); RemoveRecords(); PassAway(); diff --git a/ydb/core/tx/datashard/change_sender_cdc_stream.cpp b/ydb/core/tx/datashard/change_sender_cdc_stream.cpp index 7634146b92..1bbab141ea 100644 --- a/ydb/core/tx/datashard/change_sender_cdc_stream.cpp +++ b/ydb/core/tx/datashard/change_sender_cdc_stream.cpp @@ -67,7 +67,7 @@ class TCdcChangeSenderPartition: public TActorBootstrapped<TCdcChangeSenderParti } const auto& info = result.GetResult().SourceIdInfo; - Y_ABORT_UNLESS(info.GetExplicit()); + Y_ENSURE(info.GetExplicit()); MaxSeqNo = info.GetSeqNo(); Ready(); @@ -503,10 +503,10 @@ class TCdcChangeSenderMain Stream = TUserTable::TCdcStream(entry.CdcStreamInfo->Description); - Y_ABORT_UNLESS(entry.ListNodeEntry->Children.size() == 1); + Y_ENSURE(entry.ListNodeEntry->Children.size() == 1); const auto& topic = entry.ListNodeEntry->Children.at(0); - Y_ABORT_UNLESS(topic.Kind == TNavigate::KindTopic); + Y_ENSURE(topic.Kind == TNavigate::KindTopic); TopicPathId = topic.PathId; ResolveTopic(); @@ -582,13 +582,13 @@ class TCdcChangeSenderMain } const bool topicAutoPartitioning = IsTopicAutoPartitioningEnabled(pqConfig.GetPartitionStrategy().GetPartitionStrategyType()); - Y_ABORT_UNLESS(topicAutoPartitioning || entry.PQGroupInfo->Schema); + Y_ENSURE(topicAutoPartitioning || entry.PQGroupInfo->Schema); KeyDesc = NKikimr::TKeyDesc::CreateMiniKeyDesc(entry.PQGroupInfo->Schema); - Y_ABORT_UNLESS(entry.PQGroupInfo->Partitioning); + Y_ENSURE(entry.PQGroupInfo->Partitioning); KeyDesc->Partitioning = std::make_shared<TVector<NKikimr::TKeyDesc::TPartitionInfo>>(entry.PQGroupInfo->Partitioning); if (topicAutoPartitioning) { - Y_ABORT_UNLESS(entry.PQGroupInfo->PartitionChooser); + Y_ENSURE(entry.PQGroupInfo->PartitionChooser); SetPartitionResolver(new TBoundaryPartitionResolver(entry.PQGroupInfo->PartitionChooser)); } else if (NKikimrSchemeOp::ECdcStreamFormatProto == Stream.Format) { SetPartitionResolver(CreateDefaultPartitionResolver(*KeyDesc.Get())); @@ -619,7 +619,7 @@ class TCdcChangeSenderMain } IActor* CreateSender(ui64 partitionId) const override { - Y_ABORT_UNLESS(PartitionToShard.contains(partitionId)); + Y_ENSURE(PartitionToShard.contains(partitionId)); const auto shardId = PartitionToShard.at(partitionId); return new TCdcChangeSenderPartition(SelfId(), DataShard, partitionId, shardId, Stream); } @@ -651,7 +651,7 @@ class TCdcChangeSenderMain void Handle(TEvChangeExchange::TEvRemoveSender::TPtr& ev) { LOG_D("Handle " << ev->Get()->ToString()); - Y_ABORT_UNLESS(ev->Get()->PathId == GetChangeSenderIdentity()); + Y_ENSURE(ev->Get()->PathId == GetChangeSenderIdentity()); RemoveRecords(); PassAway(); diff --git a/ydb/core/tx/datashard/change_sender_incr_restore.cpp b/ydb/core/tx/datashard/change_sender_incr_restore.cpp index 64209e9bb5..fb2d75a5bb 100644 --- a/ydb/core/tx/datashard/change_sender_incr_restore.cpp +++ b/ydb/core/tx/datashard/change_sender_incr_restore.cpp @@ -77,7 +77,7 @@ class TIncrRestoreChangeSenderMain } void NextState(TResolveUserTableState::TStateTag) { - Y_ABORT_UNLESS(MainColumnToTag.contains("__ydb_incrBackupImpl_deleted")); + Y_ENSURE(MainColumnToTag.contains("__ydb_incrBackupImpl_deleted")); ResolveTargetTable(); } @@ -166,7 +166,7 @@ class TIncrRestoreChangeSenderMain void Handle(TEvChangeExchange::TEvRemoveSender::TPtr& ev) { LOG_D("Handle " << ev->Get()->ToString()); - Y_ABORT_UNLESS(ev->Get()->PathId == GetChangeSenderIdentity()); + Y_ENSURE(ev->Get()->PathId == GetChangeSenderIdentity()); RemoveRecords(); PassAway(); diff --git a/ydb/core/tx/datashard/change_sender_table_base.cpp b/ydb/core/tx/datashard/change_sender_table_base.cpp index 824028571b..baaa94a338 100644 --- a/ydb/core/tx/datashard/change_sender_table_base.cpp +++ b/ydb/core/tx/datashard/change_sender_table_base.cpp @@ -153,11 +153,11 @@ class TTableChangeSenderShard: public TActorBootstrapped<TTableChangeSenderShard switch(Type) { case ETableChangeSenderType::AsyncIndex: - Y_ABORT_UNLESS(record.HasAsyncIndex()); + Y_ENSURE(record.HasAsyncIndex()); AdjustTags(*record.MutableAsyncIndex()); break; case ETableChangeSenderType::IncrementalRestore: - Y_ABORT_UNLESS(record.HasIncrementalRestore()); + Y_ENSURE(record.HasIncrementalRestore()); AdjustTags(*record.MutableIncrementalRestore()); break; } @@ -181,7 +181,7 @@ class TTableChangeSenderShard: public TActorBootstrapped<TTableChangeSenderShard void AdjustTags(google::protobuf::RepeatedField<ui32>& tags) const { for (int i = 0; i < tags.size(); ++i) { auto it = TagMap.find(tags[i]); - Y_ABORT_UNLESS(it != TagMap.end()); + Y_ENSURE(it != TagMap.end()); tags[i] = it->second; } } diff --git a/ydb/core/tx/datashard/change_sender_table_base.h b/ydb/core/tx/datashard/change_sender_table_base.h index 4756aa7964..7fda044db1 100644 --- a/ydb/core/tx/datashard/change_sender_table_base.h +++ b/ydb/core/tx/datashard/change_sender_table_base.h @@ -162,7 +162,7 @@ private: for (const auto& [tag, column] : entry.Columns) { auto it = AsDerived()->MainColumnToTag.find(column.Name); - Y_ABORT_UNLESS(it != AsDerived()->MainColumnToTag.end()); + Y_ENSURE(it != AsDerived()->MainColumnToTag.end()); Y_DEBUG_ABORT_UNLESS(!AsDerived()->TagMap.contains(it->second)); AsDerived()->TagMap.emplace(it->second, tag); diff --git a/ydb/core/tx/datashard/check_commit_writes_tx_unit.cpp b/ydb/core/tx/datashard/check_commit_writes_tx_unit.cpp index 67547d2a67..2320591a48 100644 --- a/ydb/core/tx/datashard/check_commit_writes_tx_unit.cpp +++ b/ydb/core/tx/datashard/check_commit_writes_tx_unit.cpp @@ -18,11 +18,11 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext&, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsCommitWritesTx()); - Y_ABORT_UNLESS(!op->IsAborted()); + Y_ENSURE(op->IsCommitWritesTx()); + Y_ENSURE(!op->IsAborted()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (CheckRejectDataTx(op, ctx)) { op->Abort(EExecutionUnitKind::FinishPropose); diff --git a/ydb/core/tx/datashard/check_data_tx_unit.cpp b/ydb/core/tx/datashard/check_data_tx_unit.cpp index c97224f47f..cc499ca99f 100644 --- a/ydb/core/tx/datashard/check_data_tx_unit.cpp +++ b/ydb/core/tx/datashard/check_data_tx_unit.cpp @@ -43,8 +43,8 @@ EExecutionStatus TCheckDataTxUnit::Execute(TOperation::TPtr op, TTransactionContext &, const TActorContext &ctx) { - Y_ABORT_UNLESS(op->IsDataTx() || op->IsReadTable()); - Y_ABORT_UNLESS(!op->IsAborted()); + Y_ENSURE(op->IsDataTx() || op->IsReadTable()); + Y_ENSURE(!op->IsAborted()); if (CheckRejectDataTx(op, ctx)) { op->Abort(EExecutionUnitKind::FinishPropose); @@ -53,15 +53,15 @@ EExecutionStatus TCheckDataTxUnit::Execute(TOperation::TPtr op, } TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto dataTx = tx->GetDataTx(); - Y_ABORT_UNLESS(dataTx); - Y_ABORT_UNLESS(dataTx->Ready() || dataTx->RequirePrepare()); + Y_ENSURE(dataTx); + Y_ENSURE(dataTx->Ready() || dataTx->RequirePrepare()); if (dataTx->Ready()) { DataShard.IncCounter(COUNTER_MINIKQL_PROGRAM_SIZE, dataTx->ProgramSize()); } else { - Y_ABORT_UNLESS(dataTx->RequirePrepare()); + Y_ENSURE(dataTx->RequirePrepare()); LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Require prepare Tx " << op->GetTxId() << " at " << DataShard.TabletID() << ": " << dataTx->GetErrors()); diff --git a/ydb/core/tx/datashard/check_distributed_erase_tx_unit.cpp b/ydb/core/tx/datashard/check_distributed_erase_tx_unit.cpp index ab41e0757d..5f75b8e22c 100644 --- a/ydb/core/tx/datashard/check_distributed_erase_tx_unit.cpp +++ b/ydb/core/tx/datashard/check_distributed_erase_tx_unit.cpp @@ -22,11 +22,11 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext&, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsDistributedEraseTx()); - Y_ABORT_UNLESS(!op->IsAborted()); + Y_ENSURE(op->IsDistributedEraseTx()); + Y_ENSURE(!op->IsAborted()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (CheckRejectDataTx(op, ctx)) { op->Abort(EExecutionUnitKind::FinishPropose); @@ -70,7 +70,7 @@ public: } // checked at CheckedExecute stage - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(request.GetTableId())); + Y_ENSURE(DataShard.GetUserTables().contains(request.GetTableId())); const TUserTable& tableInfo = *DataShard.GetUserTables().at(request.GetTableId()); for (const auto columnId : eraseTx->GetIndexColumnIds()) { diff --git a/ydb/core/tx/datashard/check_read_unit.cpp b/ydb/core/tx/datashard/check_read_unit.cpp index a6a7071c96..e0c5244e93 100644 --- a/ydb/core/tx/datashard/check_read_unit.cpp +++ b/ydb/core/tx/datashard/check_read_unit.cpp @@ -19,7 +19,7 @@ public: EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { IReadOperation* readOperation = dynamic_cast<IReadOperation*>(op.Get()); - Y_ABORT_UNLESS(readOperation != nullptr); + Y_ENSURE(readOperation != nullptr); readOperation->CheckRequestAndInit(txc, ctx); return EExecutionStatus::Executed; diff --git a/ydb/core/tx/datashard/check_scheme_tx_unit.cpp b/ydb/core/tx/datashard/check_scheme_tx_unit.cpp index bbeb026be9..e13b6f3c18 100644 --- a/ydb/core/tx/datashard/check_scheme_tx_unit.cpp +++ b/ydb/core/tx/datashard/check_scheme_tx_unit.cpp @@ -73,13 +73,13 @@ EExecutionStatus TCheckSchemeTxUnit::Execute(TOperation::TPtr op, TTransactionContext &txc, const TActorContext &ctx) { - Y_ABORT_UNLESS(op->IsSchemeTx()); - Y_ABORT_UNLESS(!op->IsAborted()); + Y_ENSURE(op->IsSchemeTx()); + Y_ENSURE(!op->IsAborted()); Pipeline.RemoveWaitingSchemeOp(op); TActiveTransaction *activeTx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(activeTx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(activeTx, "cannot cast operation of kind " << op->GetKind()); const NKikimrTxDataShard::TFlatSchemeTransaction &tx = activeTx->GetSchemeTx(); bool unfreezeTx = false; if (tx.HasAlterTable() && tx.GetAlterTable().HasPartitionConfig() && @@ -144,7 +144,7 @@ EExecutionStatus TCheckSchemeTxUnit::Execute(TOperation::TPtr op, if (existingOp && existingOp->IsSchemeTx()) { // Check if we have propose for the same transaction type auto *schemaOp = Pipeline.FindSchemaTx(activeTx->GetTxId()); - Y_VERIFY_S(schemaOp, "Unexpected failure to find schema tx " << activeTx->GetTxId()); + Y_ENSURE(schemaOp, "Unexpected failure to find schema tx " << activeTx->GetTxId()); // N.B. cannot use existingOp as it may not be loaded yet if (activeTx->GetSchemeTxType() != schemaOp->Type) { @@ -187,7 +187,7 @@ EExecutionStatus TCheckSchemeTxUnit::Execute(TOperation::TPtr op, // Check scheme tx content. if (!CheckSchemeTx(activeTx)) { - Y_ABORT_UNLESS(op->Result()); + Y_ENSURE(op->Result()); op->Abort(EExecutionUnitKind::FinishPropose); return EExecutionStatus::ExecutedNoMoreRestarts; @@ -304,7 +304,7 @@ bool TCheckSchemeTxUnit::HasPathId(TActiveTransaction *activeTx, const T &op, co template <typename T> TPathId TCheckSchemeTxUnit::GetPathId(const T &op) const { auto pathId = TPathId::FromProto(op.GetPathId()); - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == pathId.OwnerId); + Y_ENSURE(DataShard.GetPathOwnerId() == pathId.OwnerId); return pathId; } @@ -312,7 +312,7 @@ template <typename T> bool TCheckSchemeTxUnit::CheckSchemaVersion(TActiveTransaction *activeTx, ui64 tableId, const T &op) { const auto tablePtr = DataShard.GetUserTables().FindPtr(tableId); - Y_ABORT_UNLESS(tablePtr); + Y_ENSURE(tablePtr); const auto &table = **tablePtr; const auto current = table.GetTableSchemaVersion(); @@ -410,11 +410,11 @@ bool TCheckSchemeTxUnit::CheckCreate(TActiveTransaction *activeTx) { const auto &create = tx.GetCreateTable(); ui64 tableId = create.GetId_Deprecated(); if (create.HasPathId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == create.GetPathId().GetOwnerId() || DataShard.GetPathOwnerId() == INVALID_TABLET_ID); + Y_ENSURE(DataShard.GetPathOwnerId() == create.GetPathId().GetOwnerId() || DataShard.GetPathOwnerId() == INVALID_TABLET_ID); tableId = create.GetPathId().GetLocalId(); } - Y_ABORT_UNLESS(!DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(!DataShard.GetUserTables().contains(tableId)); return true; } @@ -429,10 +429,10 @@ bool TCheckSchemeTxUnit::CheckDrop(TActiveTransaction *activeTx) { const auto &drop = tx.GetDropTable(); ui64 tableId = drop.GetId_Deprecated(); if (drop.HasPathId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == drop.GetPathId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == drop.GetPathId().GetOwnerId()); tableId = drop.GetPathId().GetLocalId(); } - Y_ABORT_UNLESS(DataShard.GetUserTables().FindPtr(tableId)); + Y_ENSURE(DataShard.GetUserTables().FindPtr(tableId)); return true; } @@ -440,7 +440,7 @@ bool TCheckSchemeTxUnit::CheckDrop(TActiveTransaction *activeTx) { bool TCheckSchemeTxUnit::CheckAlter(TActiveTransaction *activeTx) { const NKikimrTxDataShard::TFlatSchemeTransaction &tx = activeTx->GetSchemeTx(); - Y_ABORT_UNLESS(!Pipeline.HasDrop()); + Y_ENSURE(!Pipeline.HasDrop()); const TStringBuf kind = "Alter"; if (HasDuplicate(activeTx, kind, &TPipeline::HasAlter)) { @@ -505,37 +505,37 @@ bool TCheckSchemeTxUnit::CheckAlter(TActiveTransaction *activeTx) ui64 tableId = alter.GetId_Deprecated(); if (alter.HasPathId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == alter.GetPathId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == alter.GetPathId().GetOwnerId()); tableId = alter.GetPathId().GetLocalId(); } const auto tablePtr = DataShard.GetUserTables().FindPtr(tableId); - Y_VERIFY_S(tablePtr, "tableId: " << tableId); + Y_ENSURE(tablePtr, "tableId: " << tableId); const TUserTable &table = **tablePtr; auto curSchemaVersion = table.GetTableSchemaVersion(); for (const auto &col : alter.GetColumns()) { - Y_ABORT_UNLESS(col.HasId()); - Y_ABORT_UNLESS(col.HasTypeId()); - Y_ABORT_UNLESS(col.HasName()); + Y_ENSURE(col.HasId()); + Y_ENSURE(col.HasTypeId()); + Y_ENSURE(col.HasName()); ui32 colId = col.GetId(); if (table.Columns.contains(colId)) { const TUserTable::TUserColumn &column = table.Columns.at(colId); - Y_ABORT_UNLESS(column.Name == col.GetName()); + Y_ENSURE(column.Name == col.GetName()); const auto& typeInfoMod = NScheme::TypeInfoModFromProtoColumnType(col.GetTypeId(), &col.GetTypeInfo()); - Y_ABORT_UNLESS(column.Type == typeInfoMod.TypeInfo); - Y_ABORT_UNLESS(column.TypeMod == typeInfoMod.TypeMod); - Y_ABORT_UNLESS(col.HasFamily()); + Y_ENSURE(column.Type == typeInfoMod.TypeInfo); + Y_ENSURE(column.TypeMod == typeInfoMod.TypeMod); + Y_ENSURE(col.HasFamily()); } } for (const auto &col : alter.GetDropColumns()) { ui32 colId = col.GetId(); const TUserTable::TUserColumn *userColumn = table.Columns.FindPtr(colId); - Y_ABORT_UNLESS(userColumn); - Y_ABORT_UNLESS(userColumn->Name == col.GetName()); + Y_ENSURE(userColumn); + Y_ENSURE(userColumn->Name == col.GetName()); } auto res = CheckSchemaVersion(activeTx, proposedSchemaVersion, curSchemaVersion, curSchemaVersion + 1); @@ -546,7 +546,7 @@ bool TCheckSchemeTxUnit::CheckAlter(TActiveTransaction *activeTx) bool TCheckSchemeTxUnit::CheckBackup(TActiveTransaction *activeTx) { const NKikimrTxDataShard::TFlatSchemeTransaction &tx = activeTx->GetSchemeTx(); - Y_ABORT_UNLESS(!Pipeline.HasDrop()); + Y_ENSURE(!Pipeline.HasDrop()); const TStringBuf kind = "Backup"; if (HasDuplicate(activeTx, kind, &TPipeline::HasBackup)) { @@ -562,7 +562,7 @@ bool TCheckSchemeTxUnit::CheckBackup(TActiveTransaction *activeTx) } const auto &backup = tx.GetBackup(); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(backup.GetTableId())); + Y_ENSURE(DataShard.GetUserTables().contains(backup.GetTableId())); return true; } @@ -570,7 +570,7 @@ bool TCheckSchemeTxUnit::CheckBackup(TActiveTransaction *activeTx) bool TCheckSchemeTxUnit::CheckRestore(TActiveTransaction *activeTx) { const NKikimrTxDataShard::TFlatSchemeTransaction &tx = activeTx->GetSchemeTx(); - Y_ABORT_UNLESS(!Pipeline.HasDrop()); + Y_ENSURE(!Pipeline.HasDrop()); const TStringBuf kind = "Restore"; if (HasDuplicate(activeTx, kind, &TPipeline::HasRestore)) { @@ -586,7 +586,7 @@ bool TCheckSchemeTxUnit::CheckRestore(TActiveTransaction *activeTx) } const auto &restore = tx.GetRestore(); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(restore.GetTableId())); + Y_ENSURE(DataShard.GetUserTables().contains(restore.GetTableId())); return true; } @@ -601,10 +601,10 @@ bool TCheckSchemeTxUnit::CheckCopy(TActiveTransaction *activeTx) { const auto &snap = tx.GetSendSnapshot(); ui64 tableId = snap.GetTableId_Deprecated(); if (snap.HasTableId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == snap.GetTableId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == snap.GetTableId().GetOwnerId()); tableId = snap.GetTableId().GetTableId(); } - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); return true; } @@ -771,10 +771,10 @@ bool TCheckSchemeTxUnit::CheckCreateIncrementalBackupSrc(TActiveTransaction *act const auto &snap = activeTx->GetSchemeTx().GetCreateIncrementalBackupSrc().GetSendSnapshot(); ui64 tableId = snap.GetTableId_Deprecated(); if (snap.HasTableId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == snap.GetTableId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == snap.GetTableId().GetOwnerId()); tableId = snap.GetTableId().GetTableId(); } - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const auto ¬ice = activeTx->GetSchemeTx().GetCreateIncrementalBackupSrc().GetCreateCdcStreamNotice(); if (!HasPathId(activeTx, notice, "CreateIncrementalBackupSrc")) { diff --git a/ydb/core/tx/datashard/check_snapshot_tx_unit.cpp b/ydb/core/tx/datashard/check_snapshot_tx_unit.cpp index 8f06973564..825bee3f37 100644 --- a/ydb/core/tx/datashard/check_snapshot_tx_unit.cpp +++ b/ydb/core/tx/datashard/check_snapshot_tx_unit.cpp @@ -65,11 +65,11 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext&, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSnapshotTx()); - Y_ABORT_UNLESS(!op->IsAborted()); + Y_ENSURE(op->IsSnapshotTx()); + Y_ENSURE(!op->IsAborted()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (CheckRejectDataTx(op, ctx)) { op->Abort(EExecutionUnitKind::FinishPropose); diff --git a/ydb/core/tx/datashard/check_write_unit.cpp b/ydb/core/tx/datashard/check_write_unit.cpp index 1467b55547..922c0f6ebb 100644 --- a/ydb/core/tx/datashard/check_write_unit.cpp +++ b/ydb/core/tx/datashard/check_write_unit.cpp @@ -42,7 +42,7 @@ EExecutionStatus TCheckWriteUnit::Execute(TOperation::TPtr op, TTransactionContext &, const TActorContext &ctx) { - Y_ABORT_UNLESS(!op->IsAborted()); + Y_ENSURE(!op->IsAborted()); if (CheckRejectDataTx(op, ctx)) { op->Abort(EExecutionUnitKind::FinishProposeWrite); @@ -52,8 +52,8 @@ EExecutionStatus TCheckWriteUnit::Execute(TOperation::TPtr op, TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op); auto writeTx = writeOp->GetWriteTx(); - Y_ABORT_UNLESS(writeTx); - Y_ABORT_UNLESS(writeTx->Ready() || writeTx->RequirePrepare()); + Y_ENSURE(writeTx); + Y_ENSURE(writeTx->Ready() || writeTx->RequirePrepare()); // Check if we are out of space and tx wants to update user // or system table. diff --git a/ydb/core/tx/datashard/complete_data_tx_unit.cpp b/ydb/core/tx/datashard/complete_data_tx_unit.cpp index 2cd64b7264..178b4901e7 100644 --- a/ydb/core/tx/datashard/complete_data_tx_unit.cpp +++ b/ydb/core/tx/datashard/complete_data_tx_unit.cpp @@ -79,7 +79,7 @@ void TCompleteOperationUnit::CompleteOperation(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto duration = TAppData::TimeProvider->Now() - op->GetStartExecutionAt(); diff --git a/ydb/core/tx/datashard/conflicts_cache.cpp b/ydb/core/tx/datashard/conflicts_cache.cpp index 507c95f248..0540e1ae0f 100644 --- a/ydb/core/tx/datashard/conflicts_cache.cpp +++ b/ydb/core/tx/datashard/conflicts_cache.cpp @@ -27,7 +27,7 @@ void TTableConflictsCache::AddUncommittedWrite(TConstArrayRef<TCell> key, ui64 t p = std::make_unique<TUncommittedWrite>(); } auto r = p->WriteKeys.insert(k); - Y_ABORT_UNLESS(r.second); + Y_ENSURE(r.second); AddRollbackOp(TRollbackOpRemoveUncommittedWrite{ txId, k }, db); } } @@ -46,9 +46,9 @@ void TTableConflictsCache::RemoveUncommittedWrites(TConstArrayRef<TCell> key, NT auto* k = itWriteKey->second.get(); for (ui64 txId : k->UncommittedWrites) { auto it = UncommittedWrites.find(txId); - Y_ABORT_UNLESS(it != UncommittedWrites.end()); + Y_ENSURE(it != UncommittedWrites.end()); auto r = it->second->WriteKeys.erase(k); - Y_ABORT_UNLESS(r); + Y_ENSURE(r); AddRollbackOp(TRollbackOpAddUncommittedWrite{ txId, k }, db); if (it->second->WriteKeys.empty()) { AddRollbackOp(TRollbackOpRestoreUncommittedWrite{ txId, std::move(it->second) }, db); @@ -82,7 +82,7 @@ public: TTxObserver() {} void OnSkipUncommitted(ui64 txId) override { - Y_ABORT_UNLESS(Target); + Y_ENSURE(Target); Target->insert(txId); } @@ -142,7 +142,7 @@ bool TTableConflictsCache::RegisterDistributedWrite(ui64 txId, const TOwnedCellV } auto& k = WriteKeys[key]; - Y_ABORT_UNLESS(!k); + Y_ENSURE(!k); k = std::make_unique<TWriteKey>(); k->Key = key; @@ -154,7 +154,7 @@ bool TTableConflictsCache::RegisterDistributedWrite(ui64 txId, const TOwnedCellV p = std::make_unique<TUncommittedWrite>(); } auto r = p->WriteKeys.insert(k.get()); - Y_ABORT_UNLESS(r.second); + Y_ENSURE(r.second); } } @@ -163,7 +163,7 @@ bool TTableConflictsCache::RegisterDistributedWrite(ui64 txId, const TOwnedCellV p = std::make_unique<TDistributedWrite>(); } auto r = p->WriteKeys.insert(k.get()); - Y_ABORT_UNLESS(r.second); + Y_ENSURE(r.second); k->DistributedWrites++; return true; @@ -183,7 +183,7 @@ void TTableConflictsCache::UnregisterDistributedWrites(ui64 txId) { DistributedWrites.erase(it); for (auto* k : p->WriteKeys) { - Y_ABORT_UNLESS(k->DistributedWrites > 0); + Y_ENSURE(k->DistributedWrites > 0); if (0 == --k->DistributedWrites) { DropWriteKey(k); } @@ -191,18 +191,18 @@ void TTableConflictsCache::UnregisterDistributedWrites(ui64 txId) { } void TTableConflictsCache::DropWriteKey(TWriteKey* k) { - Y_ABORT_UNLESS(k->DistributedWrites == 0); + Y_ENSURE(k->DistributedWrites == 0); auto itWriteKey = WriteKeys.find(k->Key); - Y_ABORT_UNLESS(itWriteKey != WriteKeys.end()); - Y_ABORT_UNLESS(itWriteKey->second.get() == k); + Y_ENSURE(itWriteKey != WriteKeys.end()); + Y_ENSURE(itWriteKey->second.get() == k); std::unique_ptr<TWriteKey> saved = std::move(itWriteKey->second); WriteKeys.erase(itWriteKey); for (ui64 txId : k->UncommittedWrites) { auto it = UncommittedWrites.find(txId); - Y_ABORT_UNLESS(it != UncommittedWrites.end()); + Y_ENSURE(it != UncommittedWrites.end()); it->second->WriteKeys.erase(k); if (it->second->WriteKeys.empty()) { UncommittedWrites.erase(it); @@ -242,31 +242,31 @@ void TTableConflictsCache::OnCommitChanges() { } void TTableConflictsCache::OnRollbackChanges() { - Y_ABORT_UNLESS(RollbackAllowed, "Unexpected transaction rollback"); + Y_ENSURE(RollbackAllowed, "Unexpected transaction rollback"); struct TPerformRollback { TTableConflictsCache* Self; void operator()(TRollbackOpAddUncommittedWrite& op) const { auto it = Self->UncommittedWrites.find(op.TxId); - Y_ABORT_UNLESS(it != Self->UncommittedWrites.end()); + Y_ENSURE(it != Self->UncommittedWrites.end()); auto* p = it->second.get(); auto* k = op.WriteKey; auto r1 = p->WriteKeys.insert(k); - Y_ABORT_UNLESS(r1.second); + Y_ENSURE(r1.second); auto r2 = k->UncommittedWrites.insert(op.TxId); - Y_ABORT_UNLESS(r2.second); + Y_ENSURE(r2.second); } void operator()(TRollbackOpRemoveUncommittedWrite& op) const { auto it = Self->UncommittedWrites.find(op.TxId); - Y_ABORT_UNLESS(it != Self->UncommittedWrites.end()); + Y_ENSURE(it != Self->UncommittedWrites.end()); auto* p = it->second.get(); auto* k = op.WriteKey; auto r1 = p->WriteKeys.erase(k); - Y_ABORT_UNLESS(r1); + Y_ENSURE(r1); auto r2 = k->UncommittedWrites.erase(op.TxId); - Y_ABORT_UNLESS(r2); + Y_ENSURE(r2); if (p->WriteKeys.empty()) { Self->UncommittedWrites.erase(it); } @@ -274,11 +274,11 @@ void TTableConflictsCache::OnRollbackChanges() { void operator()(TRollbackOpRestoreUncommittedWrite& op) const { auto r1 = Self->UncommittedWrites.emplace(op.TxId, std::move(op.Data)); - Y_ABORT_UNLESS(r1.second); + Y_ENSURE(r1.second); auto& p = r1.first->second; for (auto* k : p->WriteKeys) { auto r2 = k->UncommittedWrites.insert(op.TxId); - Y_ABORT_UNLESS(r2.second); + Y_ENSURE(r2.second); } } }; @@ -309,7 +309,7 @@ public: } auto& writes = itWrites->second; - Y_ABORT_UNLESS(!writes.empty()); + Y_ENSURE(!writes.empty()); auto dst = writes.begin(); for (auto it = writes.begin(); it != writes.end(); ++it) { diff --git a/ydb/core/tx/datashard/conflicts_cache.h b/ydb/core/tx/datashard/conflicts_cache.h index 30e866def3..3ae0039cc4 100644 --- a/ydb/core/tx/datashard/conflicts_cache.h +++ b/ydb/core/tx/datashard/conflicts_cache.h @@ -124,7 +124,7 @@ public: std::piecewise_construct, std::forward_as_tuple(localTid), std::forward_as_tuple(localTid)); - Y_ABORT_UNLESS(res.second); + Y_ENSURE(res.second); return res.first->second; } diff --git a/ydb/core/tx/datashard/create_cdc_stream_unit.cpp b/ydb/core/tx/datashard/create_cdc_stream_unit.cpp index b48ba444b2..2b5f02812a 100644 --- a/ydb/core/tx/datashard/create_cdc_stream_unit.cpp +++ b/ydb/core/tx/datashard/create_cdc_stream_unit.cpp @@ -20,10 +20,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasCreateCdcStreamNotice() && !schemeTx.HasCreateIncrementalBackupSrc()) { @@ -38,10 +38,10 @@ public: const auto streamPathId = TPathId::FromProto(streamDesc.GetPathId()); const auto pathId = TPathId::FromProto(params.GetPathId()); - Y_ABORT_UNLESS(pathId.OwnerId == DataShard.GetPathOwnerId()); + Y_ENSURE(pathId.OwnerId == DataShard.GetPathOwnerId()); const auto version = params.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); auto tableInfo = DataShard.AlterTableAddCdcStream(ctx, txc, pathId, version, streamDesc); TDataShardLocksDb locksDb(DataShard, txc); @@ -52,8 +52,8 @@ public: } if (params.HasSnapshotName()) { - Y_ABORT_UNLESS(streamDesc.GetState() == NKikimrSchemeOp::ECdcStreamStateScan); - Y_ABORT_UNLESS(tx->GetStep() != 0); + Y_ENSURE(streamDesc.GetState() == NKikimrSchemeOp::ECdcStreamStateScan); + Y_ENSURE(tx->GetStep() != 0); DataShard.GetSnapshotManager().AddSnapshot(txc.DB, TSnapshotKey(pathId, tx->GetStep(), tx->GetTxId()), diff --git a/ydb/core/tx/datashard/create_incremental_restore_src_unit.cpp b/ydb/core/tx/datashard/create_incremental_restore_src_unit.cpp index c032d4bba1..30d779a7d3 100644 --- a/ydb/core/tx/datashard/create_incremental_restore_src_unit.cpp +++ b/ydb/core/tx/datashard/create_incremental_restore_src_unit.cpp @@ -47,7 +47,7 @@ protected: void Abort(TOperation::TPtr op, const TActorContext& ctx, const TString& error) { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); LOG_NOTICE_S(ctx, NKikimrServices::TX_DATASHARD, error); @@ -88,18 +88,18 @@ protected: bool Run(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); - Y_ABORT_UNLESS(tx->GetSchemeTx().HasCreateIncrementalRestoreSrc()); + Y_ENSURE(tx->GetSchemeTx().HasCreateIncrementalRestoreSrc()); const auto& restoreSrc = tx->GetSchemeTx().GetCreateIncrementalRestoreSrc(); const ui64 tableId = restoreSrc.GetSrcPathId().GetLocalId(); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const ui32 localTableId = DataShard.GetUserTables().at(tableId)->LocalTid; - Y_ABORT_UNLESS(txc.DB.GetScheme().GetTableInfo(localTableId)); + Y_ENSURE(txc.DB.GetScheme().GetTableInfo(localTableId)); - Y_ABORT_UNLESS(restoreSrc.HasDstPathId()); + Y_ENSURE(restoreSrc.HasDstPathId()); THolder<NTable::IScan> scan{CreateScan(restoreSrc, op->GetTxId())}; @@ -133,7 +133,7 @@ protected: bool ProcessResult(TOperation::TPtr op, const TActorContext&) { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto* result = CheckedCast<TExportScanProduct*>(op->ScanResult().Get()); bool done = true; @@ -147,7 +147,7 @@ protected: schemeOp->BytesProcessed = result->BytesRead; schemeOp->RowsProcessed = result->RowsRead; } else { - Y_FAIL_S("Cannot find schema tx: " << op->GetTxId()); + Y_ENSURE(false, "Cannot find schema tx: " << op->GetTxId()); } break; case EExportOutcome::Aborted: @@ -168,7 +168,7 @@ protected: const ui64 tableId = tx->GetSchemeTx().GetBackup().GetTableId(); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const ui32 localTableId = DataShard.GetUserTables().at(tableId)->LocalTid; DataShard.CancelScan(localTableId, tx->GetScanTask()); @@ -177,17 +177,17 @@ protected: void PersistResult(TOperation::TPtr op, TTransactionContext& txc) { auto* schemeOp = DataShard.FindSchemaTx(op->GetTxId()); - Y_ABORT_UNLESS(schemeOp); + Y_ENSURE(schemeOp); NIceDb::TNiceDb db(txc.DB); DataShard.PersistSchemeTxResult(db, *schemeOp); } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override final { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (!IsRelevant(tx)) { return EExecutionStatus::Executed; diff --git a/ydb/core/tx/datashard/create_persistent_snapshot_unit.cpp b/ydb/core/tx/datashard/create_persistent_snapshot_unit.cpp index 533d89e528..518252d033 100644 --- a/ydb/core/tx/datashard/create_persistent_snapshot_unit.cpp +++ b/ydb/core/tx/datashard/create_persistent_snapshot_unit.cpp @@ -16,10 +16,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext&) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasCreatePersistentSnapshot()) { @@ -32,7 +32,7 @@ public: ui64 pathId = params.GetPathId(); ui64 step = tx->GetStep(); ui64 txId = tx->GetTxId(); - Y_ABORT_UNLESS(step != 0); + Y_ENSURE(step != 0); const TSnapshotKey key(ownerId, pathId, step, txId); diff --git a/ydb/core/tx/datashard/create_table_unit.cpp b/ydb/core/tx/datashard/create_table_unit.cpp index cc7383f6ba..1d90d25f66 100644 --- a/ydb/core/tx/datashard/create_table_unit.cpp +++ b/ydb/core/tx/datashard/create_table_unit.cpp @@ -42,7 +42,7 @@ EExecutionStatus TCreateTableUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); const auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasCreateTable()) @@ -52,7 +52,7 @@ EExecutionStatus TCreateTableUnit::Execute(TOperation::TPtr op, TPathId tableId(DataShard.GetPathOwnerId(), createTableTx.GetId_Deprecated()); if (createTableTx.HasPathId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == createTableTx.GetPathId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == createTableTx.GetPathId().GetOwnerId()); tableId.LocalPathId = createTableTx.GetPathId().GetLocalId(); } diff --git a/ydb/core/tx/datashard/create_volatile_snapshot_unit.cpp b/ydb/core/tx/datashard/create_volatile_snapshot_unit.cpp index a8262e300f..738c330abb 100644 --- a/ydb/core/tx/datashard/create_volatile_snapshot_unit.cpp +++ b/ydb/core/tx/datashard/create_volatile_snapshot_unit.cpp @@ -16,10 +16,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSnapshotTx()); + Y_ENSURE(op->IsSnapshotTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); const auto& record = tx->GetSnapshotTx(); if (!record.HasCreateVolatileSnapshot()) { @@ -32,7 +32,7 @@ public: ui64 pathId = params.GetPathId(); ui64 step = tx->GetStep(); ui64 txId = tx->GetTxId(); - Y_ABORT_UNLESS(step != 0); + Y_ENSURE(step != 0); const TSnapshotKey key(ownerId, pathId, step, txId); diff --git a/ydb/core/tx/datashard/datashard.cpp b/ydb/core/tx/datashard/datashard.cpp index 150d5ac165..8e49843eb9 100644 --- a/ydb/core/tx/datashard/datashard.cpp +++ b/ydb/core/tx/datashard/datashard.cpp @@ -56,7 +56,7 @@ public: TRowVersion GetWriteVersion(const TTableId& tableId) const override { using Schema = TDataShard::Schema; - Y_VERIFY_S(tableId.PathId.OwnerId == Self->TabletID(), + Y_ENSURE(tableId.PathId.OwnerId == Self->TabletID(), "Unexpected table " << tableId.PathId.OwnerId << ":" << tableId.PathId.LocalPathId << " for datashard " << Self->TabletID() << " in a local minikql tx"); @@ -73,7 +73,7 @@ public: TRowVersion GetReadVersion(const TTableId& tableId) const override { using Schema = TDataShard::Schema; - Y_VERIFY_S(tableId.PathId.OwnerId == Self->TabletID(), + Y_ENSURE(tableId.PathId.OwnerId == Self->TabletID(), "Unexpected table " << tableId.PathId.OwnerId << ":" << tableId.PathId.LocalPathId << " for datashard " << Self->TabletID() << " in a local minikql tx"); @@ -269,7 +269,7 @@ void TDataShard::Cleanup(const TActorContext& ctx) { auto op = Pipeline.FindOp(Pipeline.CurrentSchemaTxId()); if (op && op->IsWaitingForAsyncJob()) { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_ABORT_UNLESS(tx); + Y_ENSURE(tx); tx->KillAsyncJobActor(ctx); } } @@ -306,7 +306,7 @@ void TDataShard::Die(const TActorContext& ctx) { UnsubscribeReadIteratorSessions(ctx); LoanReturnTracker.Shutdown(ctx); - Y_ABORT_UNLESS(LoanReturnTracker.Empty()); + Y_ENSURE(LoanReturnTracker.Empty()); SplitSrcSnapshotSender.Shutdown(ctx); Send(PersistentPipeCache, new TEvPipeCache::TEvUnlink(0)); @@ -379,7 +379,7 @@ void TDataShard::OnActivateExecutor(const TActorContext& ctx) { if (TabletCountersPtr) { Executor()->RegisterExternalTabletCounters(TabletCountersPtr); } - Y_ABORT_UNLESS(TabletCounters); + Y_ENSURE(TabletCounters); AllocCounters = TAlignedPagePoolCounters(AppData(ctx)->Counters, "datashard"); @@ -668,11 +668,11 @@ void TDataShard::WaitVolatileDependenciesThenSend( const TActorId& target, std::unique_ptr<IEventBase> event, ui64 cookie) { - Y_ABORT_UNLESS(!dependencies.empty(), "Unexpected empty dependencies"); + Y_ENSURE(!dependencies.empty(), "Unexpected empty dependencies"); auto callback = MakeIntrusive<TWaitVolatileDependencies>(this, dependencies, target, std::move(event), cookie); for (ui64 txId : dependencies) { bool ok = VolatileTxManager.AttachVolatileTxCallback(txId, callback); - Y_VERIFY_S(ok, "Unexpected failure to attach callback to volatile tx " << txId); + Y_ENSURE(ok, "Unexpected failure to attach callback to volatile tx " << txId); } } @@ -781,7 +781,7 @@ void TDataShard::SendResult(const TActorContext &ctx, ui64 txId, NWilson::TTraceId traceId) { - Y_ABORT_UNLESS(txId == res->GetTxId(), "%" PRIu64 " vs %" PRIu64, txId, res->GetTxId()); + Y_ENSURE(txId == res->GetTxId(), "Result for txId " << txId << " has txId " << res->GetTxId()); NWilson::TSpan span(TWilsonTablet::TabletDetailed, std::move(traceId), "Datashard.SendResult", NWilson::EFlags::AUTO_END); @@ -790,7 +790,7 @@ void TDataShard::SendResult(const TActorContext &ctx, bool ok = VolatileTxManager.AttachVolatileTxCallback(txId, new TSendVolatileResult(this, std::move(res), target, step, txId, std::move(span))); - Y_ABORT_UNLESS(ok); + Y_ENSURE(ok); return; } @@ -810,7 +810,7 @@ void TDataShard::SendWriteResult(const TActorContext& ctx, std::unique_ptr<NEven const TActorId& target, ui64 step, ui64 txId, NWilson::TTraceId traceId) { - Y_ABORT_UNLESS(txId == result->Record.GetTxId(), "%" PRIu64 " vs %" PRIu64, txId, result->Record.GetTxId()); + Y_ENSURE(txId == result->Record.GetTxId(), " Result for txId " << txId << " has txId " << result->Record.GetTxId()); NWilson::TSpan span(TWilsonTablet::TabletDetailed, std::move(traceId), "Datashard.SendWriteResult", NWilson::EFlags::AUTO_END); @@ -819,7 +819,7 @@ void TDataShard::SendWriteResult(const TActorContext& ctx, std::unique_ptr<NEven bool ok = VolatileTxManager.AttachVolatileTxCallback(txId, new TSendVolatileWriteResult(this, std::move(result), target, step, txId, std::move(span))); - Y_ABORT_UNLESS(ok); + Y_ENSURE(ok); return; } @@ -891,7 +891,7 @@ void TDataShard::PersistChangeRecord(NIceDb::TNiceDb& db, const TChangeRecord& r NIceDb::TUpdate<Schema::ChangeRecordDetails::Source>(record.GetSource())); auto res = ChangesQueue.emplace(record.GetOrder(), record); - Y_VERIFY_S(res.second, "Duplicate change record: " << record.GetOrder()); + Y_ENSURE(res.second, "Duplicate change record: " << record.GetOrder()); if (res.first->second.SchemaVersion) { res.first->second.SchemaSnapshotAcquired = SchemaSnapshotManager.AcquireReference( @@ -905,7 +905,7 @@ void TDataShard::PersistChangeRecord(NIceDb::TNiceDb& db, const TChangeRecord& r db.GetDatabase().OnRollback([this] { for (const auto order : CommittingChangeRecords) { auto cIt = ChangesQueue.find(order); - Y_VERIFY_S(cIt != ChangesQueue.end(), "Cannot find change record: " << order); + Y_ENSURE(cIt != ChangesQueue.end(), "Cannot find change record: " << order); if (cIt->second.SchemaSnapshotAcquired) { const auto snapshotKey = TSchemaSnapshotKey(cIt->second.TableId, cIt->second.SchemaVersion); @@ -924,20 +924,20 @@ void TDataShard::PersistChangeRecord(NIceDb::TNiceDb& db, const TChangeRecord& r CommittingChangeRecords.push_back(record.GetOrder()); } else { auto& state = LockChangeRecords[lockId]; - Y_ABORT_UNLESS(state.Changes.empty() || state.Changes.back().LockOffset < record.GetLockOffset(), + Y_ENSURE(state.Changes.empty() || state.Changes.back().LockOffset < record.GetLockOffset(), "Lock records must be added in their lock offset order"); if (state.Changes.size() == state.PersistentCount) { db.GetDatabase().OnCommit([this, lockId] { // We mark all added records as persistent auto it = LockChangeRecords.find(lockId); - Y_ABORT_UNLESS(it != LockChangeRecords.end()); + Y_ENSURE(it != LockChangeRecords.end()); it->second.PersistentCount = it->second.Changes.size(); }); db.GetDatabase().OnRollback([this, lockId] { // We remove all change records that have not been committed auto it = LockChangeRecords.find(lockId); - Y_ABORT_UNLESS(it != LockChangeRecords.end()); + Y_ENSURE(it != LockChangeRecords.end()); it->second.Changes.erase( it->second.Changes.begin() + it->second.PersistentCount, it->second.Changes.end()); @@ -987,7 +987,7 @@ void TDataShard::CommitLockChangeRecords(NIceDb::TNiceDb& db, ui64 lockId, ui64 << ", at tablet: " << TabletID()); auto it = LockChangeRecords.find(lockId); - Y_VERIFY_S(it != LockChangeRecords.end() && !it->second.Changes.empty(), "Cannot commit lock " << lockId << " change records: there are no pending change records"); + Y_ENSURE(it != LockChangeRecords.end() && !it->second.Changes.empty(), "Cannot commit lock " << lockId << " change records: there are no pending change records"); ui64 count = it->second.Changes.back().LockOffset + 1; ui64 order = AllocateChangeRecordOrder(db, count); @@ -1003,7 +1003,7 @@ void TDataShard::CommitLockChangeRecords(NIceDb::TNiceDb& db, ui64 lockId, ui64 collected.push_back(committed); auto res = ChangesQueue.emplace(committed.Order, committed); - Y_VERIFY_S(res.second, "Duplicate change record: " << committed.Order); + Y_ENSURE(res.second, "Duplicate change record: " << committed.Order); if (res.first->second.SchemaVersion) { res.first->second.SchemaSnapshotAcquired = SchemaSnapshotManager.AcquireReference( @@ -1011,10 +1011,10 @@ void TDataShard::CommitLockChangeRecords(NIceDb::TNiceDb& db, ui64 lockId, ui64 } } - Y_VERIFY_S(!CommittedLockChangeRecords.contains(lockId), "Cannot commit lock " << lockId << " more than once"); + Y_ENSURE(!CommittedLockChangeRecords.contains(lockId), "Cannot commit lock " << lockId << " more than once"); auto& entry = CommittedLockChangeRecords[lockId]; - Y_VERIFY_S(entry.Order == Max<ui64>(), "Cannot commit lock " << lockId << " change records multiple times"); + Y_ENSURE(entry.Order == Max<ui64>(), "Cannot commit lock " << lockId << " change records multiple times"); entry.Order = order; entry.Group = group; entry.Step = rowVersion.Step; @@ -1031,18 +1031,18 @@ void TDataShard::CommitLockChangeRecords(NIceDb::TNiceDb& db, ui64 lockId, ui64 // We expect operation to enqueue transformed change records, // so we no longer need original uncommitted records. auto it = LockChangeRecords.find(lockId); - Y_VERIFY_S(it != LockChangeRecords.end(), "Unexpected failure to find lockId# " << lockId); + Y_ENSURE(it != LockChangeRecords.end(), "Unexpected failure to find lockId# " << lockId); LockChangeRecords.erase(it); }); db.GetDatabase().OnRollback([this, lockId]() { auto it = CommittedLockChangeRecords.find(lockId); - Y_VERIFY_S(it != CommittedLockChangeRecords.end(), "Unexpected failure to find lockId# " << lockId); + Y_ENSURE(it != CommittedLockChangeRecords.end(), "Unexpected failure to find lockId# " << lockId); for (size_t i = 0; i < it->second.Count; ++i) { const ui64 order = it->second.Order + i; auto cIt = ChangesQueue.find(order); - Y_VERIFY_S(cIt != ChangesQueue.end(), "Cannot find change record: " << order); + Y_ENSURE(cIt != ChangesQueue.end(), "Cannot find change record: " << order); if (cIt->second.SchemaSnapshotAcquired) { const auto snapshotKey = TSchemaSnapshotKey(cIt->second.TableId, cIt->second.SchemaVersion); @@ -1111,7 +1111,7 @@ void TDataShard::RemoveChangeRecord(NIceDb::TNiceDb& db, ui64 order) { db.Table<Schema::ChangeRecordDetails>().Key(order).Delete(); } - Y_ABORT_UNLESS(record.BodySize <= ChangesQueueBytes); + Y_ENSURE(record.BodySize <= ChangesQueueBytes); ChangesQueueBytes -= record.BodySize; if (record.SchemaSnapshotAcquired) { @@ -1141,7 +1141,7 @@ void TDataShard::RemoveChangeRecord(NIceDb::TNiceDb& db, ui64 order) { void TDataShard::EnqueueChangeRecords(TVector<IDataShardChangeCollector::TChange>&& records, ui64 cookie, bool afterMove) { if (auto it = ChangeQueueReservations.find(cookie); it != ChangeQueueReservations.end()) { - Y_ABORT_UNLESS(!afterMove); + Y_ENSURE(!afterMove); ChangeQueueReservedCapacity -= it->second; it->second = records.size(); @@ -1174,7 +1174,7 @@ void TDataShard::EnqueueChangeRecords(TVector<IDataShardChangeCollector::TChange for (const auto& record : records) { auto it = ChangesQueue.find(record.Order); if (it == ChangesQueue.end()) { - Y_ABORT_UNLESS(afterMove); + Y_ENSURE(afterMove); continue; } @@ -1184,7 +1184,7 @@ void TDataShard::EnqueueChangeRecords(TVector<IDataShardChangeCollector::TChange it->second.ReservationCookie = cookie; ChangesList.PushBack(&it->second); - Y_ABORT_UNLESS(ChangesQueueBytes <= (Max<ui64>() - record.BodySize)); + Y_ENSURE(ChangesQueueBytes <= (Max<ui64>() - record.BodySize)); ChangesQueueBytes += record.BodySize; } @@ -1192,7 +1192,7 @@ void TDataShard::EnqueueChangeRecords(TVector<IDataShardChangeCollector::TChange IncCounter(COUNTER_CHANGE_RECORDS_ENQUEUED, forward.size()); SetCounter(COUNTER_CHANGE_QUEUE_SIZE, ChangesQueue.size()); - Y_ABORT_UNLESS(OutChangeSender); + Y_ENSURE(OutChangeSender); Send(OutChangeSender, new NChangeExchange::TEvChangeExchange::TEvEnqueueRecords(std::move(forward))); } @@ -1242,7 +1242,7 @@ void TDataShard::UpdateChangeExchangeLag(TInstant now) { } void TDataShard::CreateChangeSender(const TActorContext& ctx) { - Y_ABORT_UNLESS(!OutChangeSender); + Y_ENSURE(!OutChangeSender); OutChangeSender = Register(NDataShard::CreateChangeSender(this)); LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Change sender created" @@ -1286,7 +1286,7 @@ void TDataShard::MaybeActivateChangeSender(const TActorContext& ctx) { break; } - Y_ABORT_UNLESS(OutChangeSender); + Y_ENSURE(OutChangeSender); Send(OutChangeSender, new TEvChangeExchange::TEvActivateSender()); LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, "Change sender activated" @@ -1349,7 +1349,7 @@ bool TDataShard::LoadChangeRecords(NIceDb::TNiceDb& db, TVector<IDataShardChange }); auto res = ChangesQueue.emplace(records.back().Order, records.back()); - Y_VERIFY_S(res.second, "Duplicate change record: " << records.back().Order); + Y_ENSURE(res.second, "Duplicate change record: " << records.back().Order); if (res.first->second.SchemaVersion) { res.first->second.SchemaSnapshotAcquired = SchemaSnapshotManager.AcquireReference( @@ -1456,7 +1456,7 @@ bool TDataShard::LoadChangeRecordCommits(NIceDb::TNiceDb& db, TVector<IDataShard needSort = true; auto res = ChangesQueue.emplace(records.back().Order, records.back()); - Y_VERIFY_S(res.second, "Duplicate change record: " << records.back().Order); + Y_ENSURE(res.second, "Duplicate change record: " << records.back().Order); if (res.first->second.SchemaVersion) { res.first->second.SchemaSnapshotAcquired = SchemaSnapshotManager.AcquireReference( @@ -1521,10 +1521,10 @@ void TDataShard::ScheduleRemoveAbandonedLockChanges() { } void TDataShard::ScheduleRemoveSchemaSnapshot(const TSchemaSnapshotKey& key) { - Y_ABORT_UNLESS(!SchemaSnapshotManager.HasReference(key)); + Y_ENSURE(!SchemaSnapshotManager.HasReference(key)); const auto* snapshot = SchemaSnapshotManager.FindSnapshot(key); - Y_ABORT_UNLESS(snapshot); + Y_ENSURE(snapshot); auto it = TableInfos.find(key.PathId); if (it == TableInfos.end()) { @@ -1590,9 +1590,9 @@ void TDataShard::NotifySchemeshard(const TActorContext& ctx, ui64 txId) { << " txId " << txId << " state " << DatashardStateName(State) << " TxInFly " << TxInFly()); if (op->IsDrop()) { - Y_VERIFY_S(State == TShardState::PreOffline, + Y_ENSURE(State == TShardState::PreOffline, TabletID() << " is in wrong state (" << State << ") for drop"); - Y_VERIFY_S(!TxInFly(), + Y_ENSURE(!TxInFly(), TabletID() << " has " << TxInFly() << " txs in-fly " << TransQueue.TxInFlyToString()); } @@ -1659,7 +1659,7 @@ bool TDataShard::SysGetActorId(NIceDb::TNiceDb& db, ui64 key, TActorId& value) { } if (rowset.IsValid()) { TString buf = rowset.GetValue<Schema::Sys::Bytes>(); - Y_ABORT_UNLESS(buf.size() == sizeof(ui64) * 2, "Unexpected TActorId value size %" PRISZT, buf.size()); + Y_ENSURE(buf.size() == sizeof(ui64) * 2, "Unexpected TActorId value size " << buf.size()); const char* data = buf.data(); ui64 x1 = ReadUnaligned<ui64>(data); ui64 x2 = ReadUnaligned<ui64>(data + sizeof(ui64)); @@ -1703,12 +1703,12 @@ TUserTable::TPtr TDataShard::AlterTableSchemaVersion( const TPathId& pathId, const ui64 tableSchemaVersion, bool persist) { - Y_ABORT_UNLESS(GetPathOwnerId() == pathId.OwnerId); + Y_ENSURE(GetPathOwnerId() == pathId.OwnerId); ui64 tableId = pathId.LocalPathId; - Y_ABORT_UNLESS(TableInfos.contains(tableId)); + Y_ENSURE(TableInfos.contains(tableId)); auto oldTableInfo = TableInfos[tableId]; - Y_ABORT_UNLESS(oldTableInfo); + Y_ENSURE(oldTableInfo); TUserTable::TPtr newTableInfo = new TUserTable(*oldTableInfo); newTableInfo->SetTableSchemaVersion(tableSchemaVersion); @@ -1821,8 +1821,8 @@ void TDataShard::AddSchemaSnapshot(const TPathId& pathId, ui64 tableSchemaVersio << ", txId# " << txId << ", at tablet# " << TabletID()); - Y_ABORT_UNLESS(GetPathOwnerId() == pathId.OwnerId); - Y_ABORT_UNLESS(TableInfos.contains(pathId.LocalPathId)); + Y_ENSURE(GetPathOwnerId() == pathId.OwnerId); + Y_ENSURE(TableInfos.contains(pathId.LocalPathId)); auto tableInfo = TableInfos[pathId.LocalPathId]; const auto key = TSchemaSnapshotKey(pathId, tableSchemaVersion); @@ -1850,7 +1850,7 @@ TUserTable::TPtr TDataShard::CreateUserTable(TTransactionContext& txc, const TString mainTableName = TDataShard::Schema::UserTablePrefix + tableScheme.GetName(); ui64 tableId = tableScheme.GetId_Deprecated(); if (tableScheme.HasPathId()) { - Y_ABORT_UNLESS(GetPathOwnerId() == tableScheme.GetPathId().GetOwnerId() || GetPathOwnerId() == INVALID_TABLET_ID); + Y_ENSURE(GetPathOwnerId() == tableScheme.GetPathId().GetOwnerId() || GetPathOwnerId() == INVALID_TABLET_ID); tableId = tableScheme.GetPathId().GetLocalId(); } ui32 localTid = ++LastLocalTid; @@ -1903,11 +1903,11 @@ TUserTable::TPtr TDataShard::MoveUserTable(TOperation::TPtr op, const NKikimrTxD const auto prevId = TPathId::FromProto(move.GetPathId()); const auto newId = TPathId::FromProto(move.GetDstPathId()); - Y_ABORT_UNLESS(GetPathOwnerId() == prevId.OwnerId); - Y_ABORT_UNLESS(TableInfos.contains(prevId.LocalPathId)); + Y_ENSURE(GetPathOwnerId() == prevId.OwnerId); + Y_ENSURE(TableInfos.contains(prevId.LocalPathId)); const auto version = move.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); auto newTableInfo = AlterTableSchemaVersion(ctx, txc, prevId, version, false); newTableInfo->SetPath(move.GetDstPath()); @@ -1917,9 +1917,9 @@ TUserTable::TPtr TDataShard::MoveUserTable(TOperation::TPtr op, const NKikimrTxD NKikimrSchemeOp::TTableDescription schema; newTableInfo->GetSchema(schema); for (auto& indexDesc: *schema.MutableTableIndexes()) { - Y_ABORT_UNLESS(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); + Y_ENSURE(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); auto prevPathId = TPathId(indexDesc.GetPathOwnerId(), indexDesc.GetLocalPathId()); - Y_VERIFY_S(remap.contains(prevPathId), "no rule how to move index with pathId " << prevPathId); // we should remap all indexes + Y_ENSURE(remap.contains(prevPathId), "no rule how to move index with pathId " << prevPathId); // we should remap all indexes auto newPathId = remap.at(prevPathId); indexDesc.SetPathOwnerId(newPathId.OwnerId); @@ -1965,11 +1965,11 @@ TUserTable::TPtr TDataShard::MoveUserIndex(TOperation::TPtr op, const NKikimrTxD { const auto pathId = TPathId::FromProto(move.GetPathId()); - Y_ABORT_UNLESS(GetPathOwnerId() == pathId.OwnerId); - Y_ABORT_UNLESS(TableInfos.contains(pathId.LocalPathId)); + Y_ENSURE(GetPathOwnerId() == pathId.OwnerId); + Y_ENSURE(TableInfos.contains(pathId.LocalPathId)); const auto version = move.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); auto newTableInfo = AlterTableSchemaVersion(ctx, txc, pathId, version, false); @@ -1982,7 +1982,7 @@ TUserTable::TPtr TDataShard::MoveUserIndex(TOperation::TPtr op, const NKikimrTxD auto& indexes = *schema.MutableTableIndexes(); for (auto it = indexes.begin(); it != indexes.end(); ++it) { - Y_ABORT_UNLESS(it->HasPathOwnerId() && it->HasLocalPathId()); + Y_ENSURE(it->HasPathOwnerId() && it->HasLocalPathId()); if (oldPathId == TPathId(it->GetPathOwnerId(), it->GetLocalPathId())) { indexes.erase(it); break; @@ -1992,11 +1992,11 @@ TUserTable::TPtr TDataShard::MoveUserIndex(TOperation::TPtr op, const NKikimrTxD const auto remapPrevId = TPathId::FromProto(move.GetReMapIndex().GetSrcPathId()); const auto remapNewId = TPathId::FromProto(move.GetReMapIndex().GetDstPathId()); - Y_ABORT_UNLESS(move.GetReMapIndex().HasDstName()); + Y_ENSURE(move.GetReMapIndex().HasDstName()); const auto dstIndexName = move.GetReMapIndex().GetDstName(); for (auto& indexDesc: *schema.MutableTableIndexes()) { - Y_ABORT_UNLESS(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); + Y_ENSURE(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); auto prevPathId = TPathId(indexDesc.GetPathOwnerId(), indexDesc.GetLocalPathId()); if (remapPrevId != prevPathId) { continue; @@ -2032,11 +2032,11 @@ TUserTable::TPtr TDataShard::AlterUserTable(const TActorContext& ctx, TTransacti { ui64 tableId = alter.GetId_Deprecated(); if (alter.HasPathId()) { - Y_ABORT_UNLESS(GetPathOwnerId() == alter.GetPathId().GetOwnerId()); + Y_ENSURE(GetPathOwnerId() == alter.GetPathId().GetOwnerId()); tableId = alter.GetPathId().GetLocalId(); } TUserTable::TCPtr oldTable = TableInfos[tableId]; - Y_ABORT_UNLESS(oldTable); + Y_ENSURE(oldTable); TUserTable::TPtr tableInfo = new TUserTable(*oldTable, alter); TString strError; @@ -2093,7 +2093,7 @@ TUserTable::TPtr TDataShard::AlterUserTable(const TActorContext& ctx, TTransacti void TDataShard::DropUserTable(TTransactionContext& txc, ui64 tableId) { auto ti = TableInfos.find(tableId); - Y_ABORT_UNLESS(ti != TableInfos.end(), "Table with id %" PRIu64 " doesn't exist on this datashard", tableId); + Y_ENSURE(ti != TableInfos.end(), "Table with id " << tableId << " doesn't exist on this datashard"); NIceDb::TNiceDb db(txc.DB); txc.DB.NoMoreReadsForTx(); @@ -2159,7 +2159,7 @@ void TDataShard::SnapshotComplete(TIntrusivePtr<NTabletFlatExecutor::TTableSnaps return; } - Y_ABORT_UNLESS(txSnapContext->TablesToSnapshot().size() == 1, + Y_ENSURE(txSnapContext->TablesToSnapshot().size() == 1, "Currently only 1 table can be snapshotted"); ui32 tableId = txSnapContext->TablesToSnapshot()[0]; @@ -2178,17 +2178,16 @@ void TDataShard::SnapshotComplete(TIntrusivePtr<NTabletFlatExecutor::TTableSnaps return; } - Y_ABORT("Unexpected table snapshot context"); + Y_ENSURE(false, "Unexpected table snapshot context"); } TUserTable::TSpecialUpdate TDataShard::SpecialUpdates(const NTable::TDatabase& db, const TTableId& tableId) const { - Y_ABORT_UNLESS(tableId.PathId.OwnerId == PathOwnerId, "%" PRIu64 " vs %" PRIu64, - tableId.PathId.OwnerId, PathOwnerId); + Y_ENSURE(tableId.PathId.OwnerId == PathOwnerId, tableId.PathId.OwnerId << " != " << PathOwnerId); auto it = TableInfos.find(tableId.PathId.LocalPathId); - Y_ABORT_UNLESS(it != TableInfos.end()); + Y_ENSURE(it != TableInfos.end()); const TUserTable& tableInfo = *it->second; - Y_ABORT_UNLESS(tableInfo.LocalTid != Max<ui32>()); + Y_ENSURE(tableInfo.LocalTid != Max<ui32>()); TUserTable::TSpecialUpdate ret; @@ -2214,25 +2213,25 @@ TUserTable::TSpecialUpdate TDataShard::SpecialUpdates(const NTable::TDatabase& d } void TDataShard::SetTableAccessTime(const TTableId& tableId, TInstant ts) { - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); auto iter = TableInfos.find(tableId.PathId.LocalPathId); - Y_ABORT_UNLESS(iter != TableInfos.end()); + Y_ENSURE(iter != TableInfos.end()); iter->second->Stats.AccessTime = ts; } void TDataShard::SetTableUpdateTime(const TTableId& tableId, TInstant ts) { - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); auto iter = TableInfos.find(tableId.PathId.LocalPathId); - Y_ABORT_UNLESS(iter != TableInfos.end()); + Y_ENSURE(iter != TableInfos.end()); iter->second->Stats.AccessTime = ts; iter->second->Stats.UpdateTime = ts; } void TDataShard::SampleKeyAccess(const TTableId& tableId, const TArrayRef<const TCell>& row) { - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); auto iter = TableInfos.find(tableId.PathId.LocalPathId); - Y_ABORT_UNLESS(iter != TableInfos.end()); + Y_ENSURE(iter != TableInfos.end()); const ui64 samplingKeyPrefixSize = row.size(); TArrayRef<const TCell> key(row.data(), samplingKeyPrefixSize); @@ -2421,7 +2420,7 @@ TRowVersion TDataShard::GetMvccTxVersion(EMvccTxMode mode, TOperation* op) const } } - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); }(); switch (mode) { @@ -2436,7 +2435,7 @@ TRowVersion TDataShard::GetMvccTxVersion(EMvccTxMode mode, TOperation* op) const } } - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } TReadWriteVersions TDataShard::GetReadWriteVersions(TOperation* op) const { @@ -2458,7 +2457,7 @@ TReadWriteVersions TDataShard::GetReadWriteVersions(TOperation* op) const { TDataShard::TPromotePostExecuteEdges TDataShard::PromoteImmediatePostExecuteEdges( const TRowVersion& version, EPromotePostExecuteEdges mode, TTransactionContext& txc) { - Y_ABORT_UNLESS(!IsFollower(), "Unexpected attempt to promote edges on a follower"); + Y_ENSURE(!IsFollower(), "Unexpected attempt to promote edges on a follower"); TPromotePostExecuteEdges res; @@ -2732,7 +2731,7 @@ public: {} bool Execute(TTransactionContext& txc, const TActorContext&) override { - Y_ABORT_UNLESS(Self->MediatorStateRestoreTxPending); + Y_ENSURE(Self->MediatorStateRestoreTxPending); Self->MediatorStateRestoreTxPending = false; Self->FinishMediatorStateRestore(txc, ReadStep, ObservedStep); @@ -2829,7 +2828,7 @@ void TDataShard::CheckMediatorStateRestored() { } void TDataShard::FinishMediatorStateRestore(TTransactionContext& txc, ui64 readStep, ui64 observedStep) { - Y_ABORT_UNLESS(MediatorStateWaiting); + Y_ENSURE(MediatorStateWaiting); // Using the inferred last read step we restore the pessimistic unprotected // read edge. Note we only need to do so if there have actually been any @@ -3130,7 +3129,7 @@ bool TDataShard::CheckDataTxRejectAndReply(const NEvents::TDataEvents::TEvWrite: } break; default: - Y_FAIL_S("Unexpected rejectStatus " << rejectStatus); + Y_ENSURE(false, "Unexpected rejectStatus " << rejectStatus); } auto result = NEvents::TDataEvents::TEvWriteResult::BuildError(TabletID(), msg->GetTxId(), status, rejectDescription); @@ -3195,7 +3194,7 @@ void TDataShard::Handle(TEvDataShard::TEvProposeTransaction::TPtr &ev, const TAc UpdateProposeQueueSize(); return; } else { - Y_ABORT("Unexpected failure to add a waiting unrejected tx"); + Y_ENSURE(false, "Unexpected failure to add a waiting unrejected tx"); } } @@ -3417,7 +3416,7 @@ void TDataShard::Handle(TEvPrivate::TEvDelayedProposeTransaction::TPtr &ev, cons return; } default: - Y_FAIL_S("Unexpected event type " << item.Event->GetTypeRewrite()); + Y_ENSURE(false, "Unexpected event type " << item.Event->GetTypeRewrite()); } } @@ -3441,7 +3440,7 @@ void TDataShard::Handle(TEvPrivate::TEvDelayedProposeTransaction::TPtr &ev, cons break; } default: - Y_FAIL_S("Unexpected event type " << item.Event->GetTypeRewrite()); + Y_ENSURE(false, "Unexpected event type " << item.Event->GetTypeRewrite()); } @@ -3474,7 +3473,7 @@ void TDataShard::Handle(TEvPrivate::TEvRegisterScanActor::TPtr &ev, const TActor } TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); tx->SetScanActor(ev->Sender); } @@ -3493,7 +3492,7 @@ void TDataShard::Handle(TEvPrivate::TEvPersistScanState::TPtr& ev, const TActorC } void TDataShard::Handle(TEvTabletPipe::TEvClientConnected::TPtr &ev, const TActorContext &ctx) { - Y_ABORT_UNLESS(ev->Get()->Leader, "Unexpectedly connected to follower of tablet %" PRIu64, ev->Get()->TabletId); + Y_ENSURE(ev->Get()->Leader, "Unexpectedly connected to follower of tablet " << ev->Get()->TabletId); if (ev->Get()->ClientId == SchemeShardPipe) { if (!TransQueue.HasNotAckedSchemaTx()) { @@ -3740,9 +3739,9 @@ void TDataShard::Handle(TEvMediatorTimecast::TEvRegisterTabletResult::TPtr& ev, LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Got TEvMediatorTimecast::TEvRegisterTabletResult at " << TabletID() << " time " << ev->Get()->Entry->Get(TabletID())); - Y_ABORT_UNLESS(ev->Get()->TabletId == TabletID()); + Y_ENSURE(ev->Get()->TabletId == TabletID()); MediatorTimeCastEntry = ev->Get()->Entry; - Y_ABORT_UNLESS(MediatorTimeCastEntry); + Y_ENSURE(MediatorTimeCastEntry); SendAfterMediatorStepActivate(MediatorTimeCastEntry->Get(TabletID()), ctx); @@ -3759,7 +3758,7 @@ void TDataShard::Handle(TEvMediatorTimecast::TEvSubscribeReadStepResult::TPtr& e << " last step " << msg->LastReadStep << " next step " << msg->NextReadStep); auto it = CoordinatorSubscriptionById.find(msg->CoordinatorId); - Y_VERIFY_S(it != CoordinatorSubscriptionById.end(), + Y_ENSURE(it != CoordinatorSubscriptionById.end(), "Unexpected TEvSubscribeReadStepResult for coordinator " << msg->CoordinatorId); CoordinatorPrevReadStepMin = Max(CoordinatorPrevReadStepMin, msg->LastReadStep); CoordinatorPrevReadStepMax = Min(CoordinatorPrevReadStepMax, msg->NextReadStep); @@ -3773,9 +3772,9 @@ void TDataShard::Handle(TEvMediatorTimecast::TEvSubscribeReadStepResult::TPtr& e void TDataShard::Handle(TEvMediatorTimecast::TEvNotifyPlanStep::TPtr& ev, const TActorContext& ctx) { const auto* msg = ev->Get(); - Y_ABORT_UNLESS(msg->TabletId == TabletID()); + Y_ENSURE(msg->TabletId == TabletID()); - Y_ABORT_UNLESS(MediatorTimeCastEntry); + Y_ENSURE(MediatorTimeCastEntry); ui64 step = MediatorTimeCastEntry->Get(TabletID()); LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Notified by mediator time cast with PlanStep# " << step << " at tablet " << TabletID()); @@ -3790,7 +3789,7 @@ void TDataShard::Handle(TEvMediatorTimecast::TEvNotifyPlanStep::TPtr& ev, const } void TDataShard::Handle(TEvPrivate::TEvMediatorRestoreBackup::TPtr&, const TActorContext&) { - Y_ABORT("This code path was always no-op and no longer used"); + Y_ENSURE(false, "This code path was always no-op and no longer used"); } bool TDataShard::WaitPlanStep(ui64 step) { @@ -3925,7 +3924,7 @@ void TDataShard::DoPeriodicTasks(const TActorContext &ctx) { } void TDataShard::DoPeriodicTasks(TEvPrivate::TEvPeriodicWakeup::TPtr&, const TActorContext &ctx) { - Y_ABORT_UNLESS(PeriodicWakeupPending, "Unexpected TEvPeriodicWakeup message"); + Y_ENSURE(PeriodicWakeupPending, "Unexpected TEvPeriodicWakeup message"); PeriodicWakeupPending = false; DoPeriodicTasks(ctx); } @@ -4281,7 +4280,7 @@ void TDataShard::Handle(TEvDataShard::TEvGetReadTableSinkStateRequest::TPtr &ev, } TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); ctx.Send(ev->Forward(tx->GetStreamSink())); } @@ -4309,7 +4308,7 @@ void TDataShard::Handle(TEvDataShard::TEvGetReadTableScanStateRequest::TPtr &ev, } TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); ctx.Send(ev->Forward(tx->GetStreamSink())); if (!tx->GetScanActor()) { @@ -4347,7 +4346,7 @@ void TDataShard::Handle(TEvDataShard::TEvGetReadTableStreamStateRequest::TPtr &e } TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); ctx.Send(ev->Forward(tx->GetStreamSink())); } @@ -4554,7 +4553,7 @@ void TDataShard::ExecuteProgressTx(const TActorContext& ctx) { } void TDataShard::ExecuteProgressTx(TOperation::TPtr op, const TActorContext& ctx) { - Y_ABORT_UNLESS(op->IsInProgress()); + Y_ENSURE(op->IsInProgress()); NWilson::TTraceId traceId = op->GetTraceId(); Execute(new TTxProgressTransaction(this, std::move(op), std::move(traceId)), ctx); } @@ -4577,7 +4576,7 @@ public: bool Execute(TTransactionContext& txc, const TActorContext&) override { auto pathId = Ev->Get()->PathId; auto it = pathId ? Self->GetUserTables().find(pathId.LocalPathId) : Self->GetUserTables().begin(); - Y_ABORT_UNLESS(it != Self->GetUserTables().end()); + Y_ENSURE(it != Self->GetUserTables().end()); Reply = MakeHolder<TEvDataShard::TEvGetRemovedRowVersionsResult>(txc.DB.GetRemovedRowVersions(it->second->LocalTid)); return true; @@ -4623,7 +4622,7 @@ public: } void OnSkipUncommitted(ui64 txId) override { - Y_ABORT_UNLESS(VolatileDependencies); + Y_ENSURE(VolatileDependencies); Self->BreakWriteConflict(txId, *VolatileDependencies); } @@ -4655,7 +4654,7 @@ public: absl::flat_hash_set<ui64>& volatileDependencies) : Observer(observer) { - Y_ABORT_UNLESS(!Observer->VolatileDependencies); + Y_ENSURE(!Observer->VolatileDependencies); Observer->VolatileDependencies = &volatileDependencies; } @@ -4671,7 +4670,7 @@ bool TDataShard::BreakWriteConflicts(NTable::TDatabase& db, const TTableId& tabl TArrayRef<const TCell> keyCells, absl::flat_hash_set<ui64>& volatileDependencies) { const auto localTid = GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTid); + Y_ENSURE(localTid); if (auto* cached = GetConflictsCache().GetTableCache(localTid).FindUncommittedWrites(keyCells)) { for (ui64 txId : *cached) { @@ -4722,7 +4721,7 @@ public: bool Execute(TTransactionContext& txc, const TActorContext&) override { auto pathId = Ev->Get()->PathId; auto it = pathId ? Self->GetUserTables().find(pathId.LocalPathId) : Self->GetUserTables().begin(); - Y_ABORT_UNLESS(it != Self->GetUserTables().end()); + Y_ENSURE(it != Self->GetUserTables().end()); auto openTxs = txc.DB.GetOpenTxs(it->second->LocalTid); diff --git a/ydb/core/tx/datashard/datashard.h b/ydb/core/tx/datashard/datashard.h index 1f2b0973d2..b0eeba80f9 100644 --- a/ydb/core/tx/datashard/datashard.h +++ b/ydb/core/tx/datashard/datashard.h @@ -489,7 +489,7 @@ namespace TEvDataShard { const TStringBuf& txBody, const NKikimrSubDomains::TProcessingParams &processingParams, ui32 flags = NDataShard::TTxFlags::Default) : TEvProposeTransaction(txKind, source, txId, txBody, flags) { - Y_ABORT_UNLESS(txKind == NKikimrTxDataShard::TX_KIND_SCHEME); + Y_ENSURE(txKind == NKikimrTxDataShard::TX_KIND_SCHEME); Record.SetSchemeShardId(ssId); Record.MutableProcessingParams()->CopyFrom(processingParams); } @@ -1343,7 +1343,7 @@ namespace TEvDataShard { : TxId(txId) , Info(info) { - Y_ABORT_UNLESS(Info.DataETag); + Y_ENSURE(Info.DataETag); } TString ToString() const override { @@ -1390,7 +1390,7 @@ namespace TEvDataShard { , Record(*RecordHolder) , Info(info) { - Y_ABORT_UNLESS(Info.DataETag); + Y_ENSURE(Info.DataETag); } TString ToString() const override { diff --git a/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp b/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp index 84c4a778a4..e0cee8b4ca 100644 --- a/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp +++ b/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp @@ -139,8 +139,8 @@ class TCondEraseScan: public IActorCallback, public IScan, public IEraserOps { TVector<TCell> keyCells; for (const auto& key : keyOrder) { - Y_ABORT_UNLESS(key.Pos != Max<TPos>()); - Y_ABORT_UNLESS(key.Pos < row.Size()); + Y_ENSURE(key.Pos != Max<TPos>()); + Y_ENSURE(key.Pos < row.Size()); keyCells.push_back(row.Get(key.Pos)); } @@ -156,7 +156,7 @@ class TCondEraseScan: public IActorCallback, public IScan, public IEraserOps { request->Record.SetSchemaVersion(tableId.SchemaVersion); for (const auto& key : keyOrder) { - Y_ABORT_UNLESS(key.Tag != Max<TTag>()); + Y_ENSURE(key.Tag != Max<TTag>()); request->Record.AddKeyColumnIds(key.Tag); } @@ -246,12 +246,12 @@ public: // fill scan tags & positions in KeyOrder ScanTags = Condition->Tags(); - Y_ABORT_UNLESS(ScanTags.size() == 1, "Multi-column conditions are not supported"); + Y_ENSURE(ScanTags.size() == 1, "Multi-column conditions are not supported"); THashMap<TTag, TPos> tagToPos; for (TPos pos = 0; pos < ScanTags.size(); ++pos) { - Y_ABORT_UNLESS(tagToPos.emplace(ScanTags.at(pos), pos).second); + Y_ENSURE(tagToPos.emplace(ScanTags.at(pos), pos).second); } for (auto& key : KeyOrder) { @@ -402,8 +402,8 @@ protected: } const TColInfo* col = scheme->ColInfo(mainColumnId); - Y_ABORT_UNLESS(col); - Y_ABORT_UNLESS(col->Tag == mainColumnId); + Y_ENSURE(col); + Y_ENSURE(col->Tag == mainColumnId); keyOrder.emplace_back().Tag = col->Tag; keys.insert(col->Tag); @@ -414,7 +414,7 @@ protected: } TActorId CreateEraser() override { - Y_ABORT_UNLESS(!Eraser); + Y_ENSURE(!Eraser); Eraser = this->Register(CreateDistributedEraser(this->SelfId(), TableId, Indexes)); return Eraser; } @@ -438,8 +438,8 @@ IScan* CreateCondEraseScan( TDataShard* ds, const TActorId& replyTo, const TTableId& tableId, ui64 txId, THolder<IEraseRowsCondition> condition, const TLimits& limits, TIndexes indexes) { - Y_ABORT_UNLESS(ds); - Y_ABORT_UNLESS(condition.Get()); + Y_ENSURE(ds); + Y_ENSURE(condition.Get()); if (!indexes) { return new TCondEraseScan(ds, replyTo, tableId, txId, std::move(condition), limits); @@ -601,7 +601,7 @@ void TDataShard::Handle(TEvDataShard::TEvConditionalEraseRowsRequest::TPtr& ev, if (scan) { const ui32 localTableId = userTable->LocalTid; - Y_ABORT_UNLESS(Executor()->Scheme().GetTableInfo(localTableId)); + Y_ENSURE(Executor()->Scheme().GetTableInfo(localTableId)); auto* appData = AppData(ctx); const auto& taskName = appData->DataShardConfig.GetTtlTaskName(); diff --git a/ydb/core/tx/datashard/datashard__engine_host.cpp b/ydb/core/tx/datashard/datashard__engine_host.cpp index c0ca5b925d..0782fe99c5 100644 --- a/ydb/core/tx/datashard/datashard__engine_host.cpp +++ b/ydb/core/tx/datashard/datashard__engine_host.cpp @@ -76,7 +76,7 @@ struct TRowResultInfo { ui32 colId = literal->AsValue().Get<ui32>(); const TSysTables::TTableColumnInfo * colInfo = columns.FindPtr(colId); - Y_ABORT_UNLESS(colInfo && (colInfo->Id == colId), "No column info for column"); + Y_ENSURE(colInfo && (colInfo->Id == colId), "No column info for column"); ItemInfos.emplace_back(ItemInfo(colId, colInfo->PType, optType)); } } @@ -86,7 +86,7 @@ struct TRowResultInfo { return NUdf::TUnboxedValuePod(); } - Y_ABORT_UNLESS(inRow.size() >= ItemInfos.size()); + Y_ENSURE(inRow.size() >= ItemInfos.size()); // reorder columns TVector<TCell> outRow(Reserve(ItemInfos.size())); @@ -130,12 +130,12 @@ public: TRowResultInfo result(columnIds, Columns, returnType); auto lock = Self->SysLocksTable().GetLock(row); - Y_ABORT_UNLESS(!lock.IsError()); + Y_ENSURE(!lock.IsError()); if (TableId.PathId.LocalPathId == TSysTables::SysTableLocks2) { return result.CreateResult(lock.MakeRow(true), holderFactory); } - Y_ABORT_UNLESS(TableId.PathId.LocalPathId == TSysTables::SysTableLocks); + Y_ENSURE(TableId.PathId.LocalPathId == TSysTables::SysTableLocks); return result.CreateResult(lock.MakeRow(false), holderFactory); } @@ -184,7 +184,7 @@ public: if (tableId.PathId.LocalPathId == TSysTables::SysTableLocks) return Locks; - Y_ABORT("unexpected sys table id"); + Y_ENSURE(false, "unexpected sys table id"); } }; @@ -238,7 +238,7 @@ public: TRowVersion GetWriteVersion(const TTableId& tableId) const override { Y_UNUSED(tableId); - Y_ABORT_UNLESS(!UserDb.GetWriteVersion().IsMax(), "Cannot perform writes without WriteVersion set"); + Y_ENSURE(!UserDb.GetWriteVersion().IsMax(), "Cannot perform writes without WriteVersion set"); return UserDb.GetWriteVersion(); } @@ -248,7 +248,7 @@ public: TRowVersion GetReadVersion(const TTableId& tableId) const override { Y_UNUSED(tableId); - Y_ABORT_UNLESS(!UserDb.GetReadVersion().IsMin(), "Cannot perform reads without ReadVersion set"); + Y_ENSURE(!UserDb.GetReadVersion().IsMin(), "Cannot perform reads without ReadVersion set"); return UserDb.GetReadVersion(); } @@ -343,7 +343,7 @@ public: const TReadTarget& readTarget, ui64 itemsLimit, ui64 bytesLimit, bool reverse, std::pair<const TListLiteral*, const TListLiteral*> forbidNullArgs, const THolderFactory& holderFactory) override { - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId), "SelectRange no system table is not supported"); + Y_ENSURE(!TSysTables::IsSystemTable(tableId), "SelectRange no system table is not supported"); if (UserDb.GetLockTxId()) { Self->SysLocksTable().SetLock(tableId, range); @@ -563,7 +563,7 @@ TEngineBay::~TEngineBay() { } TEngineBay::TSizes TEngineBay::CalcSizes(bool needsTotalKeysSize) const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); const auto& info = KeyValidator.GetInfo(); @@ -597,45 +597,45 @@ TEngineBay::TSizes TEngineBay::CalcSizes(bool needsTotalKeysSize) const { } void TEngineBay::SetWriteVersion(TRowVersion writeVersion) { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); host->SetWriteVersion(writeVersion); } void TEngineBay::SetReadVersion(TRowVersion readVersion) { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); host->SetReadVersion(readVersion); - Y_ABORT_UNLESS(ComputeCtx); + Y_ENSURE(ComputeCtx); ComputeCtx->SetReadVersion(readVersion); } void TEngineBay::SetVolatileTxId(ui64 txId) { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); host->SetVolatileTxId(txId); } void TEngineBay::SetIsImmediateTx() { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); host->SetIsImmediateTx(); } void TEngineBay::SetUsesMvccSnapshot() { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); host->SetUsesMvccSnapshot(); } TVector<IDataShardChangeCollector::TChange> TEngineBay::GetCollectedChanges() const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); return host->GetCollectedChanges(); @@ -647,35 +647,35 @@ void TEngineBay::ResetCollectedChanges() { } TVector<ui64> TEngineBay::GetVolatileCommitTxIds() const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); return host->GetVolatileCommitTxIds(); } const absl::flat_hash_set<ui64>& TEngineBay::GetVolatileDependencies() const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); return host->GetVolatileDependencies(); } std::optional<ui64> TEngineBay::GetVolatileChangeGroup() const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); return host->GetVolatileChangeGroup(); } bool TEngineBay::GetVolatileCommitOrdered() const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); return host->GetVolatileCommitOrdered(); } bool TEngineBay::GetPerformedUserReads() const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); return host->GetPerformedUserReads(); @@ -691,20 +691,20 @@ IEngineFlat * TEngineBay::GetEngine() { } TDataShardUserDb& TEngineBay::GetUserDb() { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); return host->GetUserDb(); } const TDataShardUserDb& TEngineBay::GetUserDb() const { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); const auto* host = static_cast<const TDataShardEngineHost*>(EngineHost.Get()); return host->GetUserDb(); } void TEngineBay::SetLockTxId(ui64 lockTxId, ui32 lockNodeId) { - Y_ABORT_UNLESS(EngineHost); + Y_ENSURE(EngineHost); auto* host = static_cast<TDataShardEngineHost*>(EngineHost.Get()); host->GetUserDb().SetLockTxId(lockTxId); @@ -727,7 +727,7 @@ NKqp::TKqpTasksRunner& TEngineBay::GetKqpTasksRunner(NKikimrTxDataShard::TKqpTra settings.OptLLVM = "OFF"; settings.TerminateOnError = false; - Y_ABORT_UNLESS(KqpAlloc); + Y_ENSURE(KqpAlloc); KqpAlloc->SetLimit(10_MB); KqpTasksRunner = NKqp::CreateKqpTasksRunner(std::move(*tx.MutableTasks()), KqpAlloc, KqpExecCtx, settings, KqpLogFunc); } @@ -736,7 +736,7 @@ NKqp::TKqpTasksRunner& TEngineBay::GetKqpTasksRunner(NKikimrTxDataShard::TKqpTra } TKqpDatashardComputeContext& TEngineBay::GetKqpComputeCtx() { - Y_ABORT_UNLESS(ComputeCtx); + Y_ENSURE(ComputeCtx); return *ComputeCtx; } diff --git a/ydb/core/tx/datashard/datashard__engine_host.h b/ydb/core/tx/datashard/datashard__engine_host.h index 3013c01cca..320ff5b0ac 100644 --- a/ydb/core/tx/datashard/datashard__engine_host.h +++ b/ydb/core/tx/datashard/datashard__engine_host.h @@ -60,13 +60,13 @@ public: EResult Validate() { if (KeyValidator.GetInfo().Loaded) return EResult::Ok; - Y_ABORT_UNLESS(Engine); + Y_ENSURE(Engine); return Engine->Validate(KeyValidator.GetInfo()); } EResult ReValidateKeys() { - Y_ABORT_UNLESS(KeyValidator.GetInfo().Loaded); - Y_ABORT_UNLESS(Engine); + Y_ENSURE(KeyValidator.GetInfo().Loaded); + Y_ENSURE(Engine); return Engine->ValidateKeys(KeyValidator.GetInfo()); } diff --git a/ydb/core/tx/datashard/datashard__init.cpp b/ydb/core/tx/datashard/datashard__init.cpp index 72a55f1f66..f3ba9f2b3f 100644 --- a/ydb/core/tx/datashard/datashard__init.cpp +++ b/ydb/core/tx/datashard/datashard__init.cpp @@ -85,11 +85,6 @@ bool TDataShard::TTxInit::Execute(TTransactionContext& txc, const TActorContext& return done; } catch (const TNotReadyTabletException &) { return false; - } catch (const TSchemeErrorTabletException &ex) { - Y_UNUSED(ex); - Y_ABORT(); - } catch (...) { - Y_ABORT("there must be no leaked exceptions"); } } @@ -288,7 +283,7 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { LOAD_SYS_BYTES(db, Schema::Sys_SubDomainInfo, rawProcessingParams); if (!rawProcessingParams.empty()) { Self->ProcessingParams.reset(new NKikimrSubDomains::TProcessingParams()); - Y_ABORT_UNLESS(Self->ProcessingParams->ParseFromString(rawProcessingParams)); + Y_ENSURE(Self->ProcessingParams->ParseFromString(rawProcessingParams)); } } @@ -310,7 +305,7 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { TString schema = rowset.GetValue<Schema::UserTables::Schema>(); NKikimrSchemeOp::TTableDescription descr; bool parseOk = ParseFromStringNoSizeLimit(descr, schema); - Y_ABORT_UNLESS(parseOk); + Y_ENSURE(parseOk); Self->AddUserTable(TPathId(Self->GetPathOwnerId(), tableId), new TUserTable(localTid, descr, shadowTid)); if (!rowset.Next()) return false; @@ -347,7 +342,7 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { TAutoPtr<NKikimrTxDataShard::TEvSplitTransferSnapshot> snapshot = new NKikimrTxDataShard::TEvSplitTransferSnapshot; bool parseOk = ParseFromStringNoSizeLimit(*snapshot, snapBody); - Y_ABORT_UNLESS(parseOk); + Y_ENSURE(parseOk); Self->SplitSrcSnapshotSender.AddDst(dstTablet); Self->SplitSrcSnapshotSender.SaveSnapshotForSending(dstTablet, snapshot); @@ -380,7 +375,7 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { if (!splitDescr.empty()) { Self->DstSplitDescription = std::make_shared<NKikimrTxDataShard::TSplitMergeDescription>(); bool parseOk = ParseFromStringNoSizeLimit(*Self->DstSplitDescription, splitDescr); - Y_ABORT_UNLESS(parseOk); + Y_ENSURE(parseOk); } LOAD_SYS_BOOL(db, Schema::Sys_DstSplitSchemaInitialized, Self->DstSplitSchemaInitialized); @@ -434,7 +429,7 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { if (!splitDescr.empty()) { Self->SrcSplitDescription = std::make_shared<NKikimrTxDataShard::TSplitMergeDescription>(); bool parseOk = ParseFromStringNoSizeLimit(*Self->SrcSplitDescription, splitDescr); - Y_ABORT_UNLESS(parseOk); + Y_ENSURE(parseOk); switch (Self->State) { case TShardState::SplitSrcWaitForNoTxInFlight: @@ -451,15 +446,13 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { } } - Y_ABORT_UNLESS(Self->State != TShardState::Unknown); + Y_ENSURE(Self->State != TShardState::Unknown); - Y_ABORT_UNLESS(Self->SplitSrcSnapshotSender.AllAcked() || Self->State == TShardState::SplitSrcSendingSnapshot, - "Unexpected state %s while having unsent split snapshots at datashard %" PRIu64, - DatashardStateName(Self->State).data(), Self->TabletID()); + Y_ENSURE(Self->SplitSrcSnapshotSender.AllAcked() || Self->State == TShardState::SplitSrcSendingSnapshot, + "Unexpected state " << DatashardStateName(Self->State) << " while having unsent split snapshots at datashard " << Self->TabletID()); - Y_ABORT_UNLESS(Self->ReceiveSnapshotsFrom.empty() || Self->State == TShardState::SplitDstReceivingSnapshot, - "Unexpected state %s while having non-received split snapshots at datashard %" PRIu64, - DatashardStateName(Self->State).data(), Self->TabletID()); + Y_ENSURE(Self->ReceiveSnapshotsFrom.empty() || Self->State == TShardState::SplitDstReceivingSnapshot, + "Unexpected state " << DatashardStateName(Self->State) << " while having non-received split snapshots at datashard " << Self->TabletID()); // Load unsent ReadSets if (!Self->OutReadSets.LoadReadSets(db)) @@ -765,7 +758,7 @@ bool TDataShard::SyncSchemeOnFollower(TTransactionContext &txc, const TActorCont } auto* userTablesSchema = scheme.GetTableInfo(Schema::UserTables::TableId); - Y_ABORT_UNLESS(userTablesSchema, "UserTables"); + Y_ENSURE(userTablesSchema, "UserTables"); // Check if tables changed since last time we synchronized them NTable::TDatabase::TChangeCounter lastSysUpdate = txc.DB.Head(Schema::Sys::TableId); @@ -852,7 +845,7 @@ bool TDataShard::SyncSchemeOnFollower(TTransactionContext &txc, const TActorCont TString schema = rowset.GetValue<Schema::UserTables::Schema>(); NKikimrSchemeOp::TTableDescription descr; bool parseOk = ParseFromStringNoSizeLimit(descr, schema); - Y_ABORT_UNLESS(parseOk); + Y_ENSURE(parseOk); tables.push_back(TRow{ TPathId(GetPathOwnerId(), tableId), new TUserTable(localTid, descr, shadowTid), @@ -875,7 +868,7 @@ bool TDataShard::SyncSchemeOnFollower(TTransactionContext &txc, const TActorCont TString schema = rowset.GetValue<Schema::UserTables::Schema>(); NKikimrSchemeOp::TTableDescription descr; bool parseOk = ParseFromStringNoSizeLimit(descr, schema); - Y_ABORT_UNLESS(parseOk); + Y_ENSURE(parseOk); tables.push_back(TRow{ TPathId(GetPathOwnerId(), tableId), new TUserTable(localTid, descr, shadowTid), diff --git a/ydb/core/tx/datashard/datashard__kqp_scan.cpp b/ydb/core/tx/datashard/datashard__kqp_scan.cpp index eecc7fc61b..b30fc64503 100644 --- a/ydb/core/tx/datashard/datashard__kqp_scan.cpp +++ b/ydb/core/tx/datashard/datashard__kqp_scan.cpp @@ -92,7 +92,7 @@ private: hFunc(TEvents::TEvUndelivered, HandleScan); hFunc(TEvents::TEvWakeup, HandleScan); default: - Y_ABORT("TKqpScan: unexpected event 0x%08" PRIx32, ev->GetTypeRewrite()); + Y_ENSURE(false, "TKqpScan: unexpected event " << Hex(ev->GetTypeRewrite())); } } @@ -184,8 +184,8 @@ private: private: TInitialState Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) final { - Y_ABORT_UNLESS(scheme); - Y_ABORT_UNLESS(driver); + Y_ENSURE(scheme); + Y_ENSURE(driver); Driver = driver; ScanActorId = TActivationContext::AsActorContext().RegisterWithSameMailbox(this); @@ -262,7 +262,7 @@ private: EScan Feed(TArrayRef<const TCell> key, const TRow& row) final { LastKey = TOwnedCellVec(key); - Y_ABORT_UNLESS(SkipNullKeys.size() <= key.size()); + Y_ENSURE(SkipNullKeys.size() <= key.size()); for (ui32 i = 0; i < SkipNullKeys.size(); ++i) { if (SkipNullKeys[i] && key[i].IsNull()) { return EScan::Feed; @@ -457,14 +457,14 @@ private: if (finish) { bool sent = Send(ComputeActorId, new TEvKqp::TEvAbortExecution(NYql::NDqProto::StatusIds::PRECONDITION_FAILED, "Query size limit exceeded.")); - Y_ABORT_UNLESS(sent); + Y_ENSURE(sent); ReportDatashardStats(); return true; } else { bool sent = Send(SelfId(), new TEvKqp::TEvAbortExecution(NYql::NDqProto::StatusIds::PRECONDITION_FAILED, "Query size limit exceeded.")); - Y_ABORT_UNLESS(sent); + Y_ENSURE(sent); ReportDatashardStats(); return false; @@ -472,7 +472,7 @@ private: } if (!finish) { - Y_ABORT_UNLESS(ChunksLimiter.Take(sendBytes)); + Y_ENSURE(ChunksLimiter.Take(sendBytes)); Result->RequestedBytesLimitReached = !ChunksLimiter.HasMore(); } @@ -598,7 +598,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvKqpScan::TPtr& ev, const TActorCont auto tableInfo = infoIt->second; // copy table info ptr here auto& tableColumns = tableInfo->Columns; - Y_ABORT_UNLESS(request.GetColumnTags().size() == request.GetColumnTypes().size()); + Y_ENSURE(request.GetColumnTags().size() == request.GetColumnTypes().size()); if (tableInfo->GetTableSchemaVersion() != 0 && request.GetSchemaVersion() != tableInfo->GetTableSchemaVersion()) diff --git a/ydb/core/tx/datashard/datashard__migrate_schemeshard.cpp b/ydb/core/tx/datashard/datashard__migrate_schemeshard.cpp index d964b72bfe..8226d1b818 100644 --- a/ydb/core/tx/datashard/datashard__migrate_schemeshard.cpp +++ b/ydb/core/tx/datashard/datashard__migrate_schemeshard.cpp @@ -61,7 +61,7 @@ bool TDataShard::TTxMigrateSchemeShard::Execute(TTransactionContext& txc, const } void TDataShard::TTxMigrateSchemeShard::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); NTabletPipe::CloseAndForgetClient(Self->SelfId(), Self->DbStatsReportPipe); diff --git a/ydb/core/tx/datashard/datashard__object_storage_listing.cpp b/ydb/core/tx/datashard/datashard__object_storage_listing.cpp index 52ece85c37..bb4b61be0d 100644 --- a/ydb/core/tx/datashard/datashard__object_storage_listing.cpp +++ b/ydb/core/tx/datashard/datashard__object_storage_listing.cpp @@ -201,7 +201,7 @@ public: TDbTupleRef currentKey = iter->GetKey(); // Check all columns that prefix columns are in the current key are equal to the specified values - Y_VERIFY(currentKey.Cells().size() > prefixColumns.GetCells().size()); + Y_ENSURE(currentKey.Cells().size() > prefixColumns.GetCells().size()); Y_VERIFY_DEBUG( 0 == CompareTypedCellVectors( prefixColumns.GetCells().data(), @@ -210,7 +210,7 @@ public: prefixColumns.GetCells().size()), "Unexpected out of range key returned from iterator"); - Y_VERIFY(currentKey.Types[pathColPos].GetTypeId() == NScheme::NTypeIds::Utf8); + Y_ENSURE(currentKey.Types[pathColPos].GetTypeId() == NScheme::NTypeIds::Utf8); const TCell& pathCell = currentKey.Cells()[pathColPos]; TString path = TString((const char*)pathCell.Data(), pathCell.Size()); @@ -240,8 +240,8 @@ public: "\"" << path << "\"" << (isLeafPath ? " -> " + DbgPrintTuple(value, *AppData(ctx)->TypeRegistry) : TString())); if (isLeafPath) { - Y_VERIFY(value.Cells()[0].Size() >= 1); - Y_VERIFY(path == TStringBuf((const char*)value.Cells()[0].Data(), value.Cells()[0].Size()), + Y_ENSURE(value.Cells()[0].Size() >= 1); + Y_ENSURE(path == TStringBuf((const char*)value.Cells()[0].Data(), value.Cells()[0].Size()), "Path column must be requested at pos 0"); TString newContentsRow = TSerializedCellVec::Serialize(value.Cells()); @@ -255,7 +255,7 @@ public: for (size_t i = 0; i < filterColumnIds.size(); i++) { auto &columnId = filterColumnIds[i]; - Y_VERIFY(columnId < value.Cells().size()); + Y_ENSURE(columnId < value.Cells().size()); NKikimrTxDataShard::TObjectStorageListingFilter_EMatchType matchType = matchTypes[i]; @@ -299,7 +299,7 @@ public: for (size_t i = 0; i < filterColumnIds.size(); i++) { auto &columnId = filterColumnIds[i]; - Y_VERIFY(columnId < value.Cells().size()); + Y_ENSURE(columnId < value.Cells().size()); NKikimrTxDataShard::TObjectStorageListingFilter_EMatchType matchType; diff --git a/ydb/core/tx/datashard/datashard__op_rows.cpp b/ydb/core/tx/datashard/datashard__op_rows.cpp index 23b9a121e1..2fb4b4b7de 100644 --- a/ydb/core/tx/datashard/datashard__op_rows.cpp +++ b/ydb/core/tx/datashard/datashard__op_rows.cpp @@ -39,7 +39,7 @@ public: Op->IncrementInProgress(); } - Y_ABORT_UNLESS(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); + Y_ENSURE(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); auto status = Self->Pipeline.RunExecutionPlan(Op, CompleteList, txc, ctx); @@ -48,7 +48,7 @@ public: return false; case EExecutionStatus::Reschedule: - Y_ABORT("Unexpected Reschedule status while handling a direct operation"); + Y_ENSURE(false, "Unexpected Reschedule status while handling a direct operation"); case EExecutionStatus::Executed: case EExecutionStatus::Continue: @@ -62,7 +62,7 @@ public: case EExecutionStatus::ExecutedNoMoreRestarts: case EExecutionStatus::DelayComplete: case EExecutionStatus::DelayCompleteNoMoreRestarts: - Y_FAIL_S("unexpected execution status " << status << " for operation " + Y_ENSURE(false, "unexpected execution status " << status << " for operation " << *Op << " " << Op->GetKind() << " at " << Self->TabletID()); } diff --git a/ydb/core/tx/datashard/datashard__plan_step.cpp b/ydb/core/tx/datashard/datashard__plan_step.cpp index a37df397df..7afbc30e9b 100644 --- a/ydb/core/tx/datashard/datashard__plan_step.cpp +++ b/ydb/core/tx/datashard/datashard__plan_step.cpp @@ -13,11 +13,11 @@ TDataShard::TTxPlanStep::TTxPlanStep(TDataShard *self, TEvTxProcessing::TEvPlanS , IsAccepted(false) , RequestStartTime(TAppData::TimeProvider->Now()) { - Y_ABORT_UNLESS(Ev); + Y_ENSURE(Ev); } bool TDataShard::TTxPlanStep::Execute(TTransactionContext &txc, const TActorContext &ctx) { - Y_ABORT_UNLESS(Ev); + Y_ENSURE(Ev); // TEvPlanStep are strictly ordered by mediator so this Tx must not be retried not to break this ordering! txc.DB.NoMoreReadsForTx(); @@ -31,7 +31,7 @@ bool TDataShard::TTxPlanStep::Execute(TTransactionContext &txc, const TActorCont TVector<ui64> txIds; txIds.reserve(Ev->Get()->Record.TransactionsSize()); for (const auto& tx : Ev->Get()->Record.GetTransactions()) { - Y_ABORT_UNLESS(tx.HasTxId()); + Y_ENSURE(tx.HasTxId()); txIds.push_back(tx.GetTxId()); @@ -82,7 +82,7 @@ bool TDataShard::TTxPlanStep::Execute(TTransactionContext &txc, const TActorCont } void TDataShard::TTxPlanStep::Complete(const TActorContext &ctx) { - Y_ABORT_UNLESS(Ev); + Y_ENSURE(Ev); ui64 step = Ev->Get()->Record.GetStep(); for (auto& kv : TxByAck) { @@ -121,7 +121,7 @@ public: if (Self->Pipeline.HasPredictedPlan()) { ui64 nextStep = Self->Pipeline.NextPredictedPlanStep(); - Y_ABORT_UNLESS(step < nextStep); + Y_ENSURE(step < nextStep); Self->WaitPredictedPlanStep(nextStep); } @@ -137,7 +137,7 @@ public: }; void TDataShard::Handle(TEvPrivate::TEvPlanPredictedTxs::TPtr&, const TActorContext& ctx) { - Y_ABORT_UNLESS(ScheduledPlanPredictedTxs); + Y_ENSURE(ScheduledPlanPredictedTxs); Execute(new TTxPlanPredictedTxs(this), ctx); } diff --git a/ydb/core/tx/datashard/datashard__progress_tx.cpp b/ydb/core/tx/datashard/datashard__progress_tx.cpp index 9e07ca1b0c..26d7ea72c1 100644 --- a/ydb/core/tx/datashard/datashard__progress_tx.cpp +++ b/ydb/core/tx/datashard/datashard__progress_tx.cpp @@ -15,107 +15,103 @@ bool TDataShard::TTxProgressTransaction::Execute(TTransactionContext &txc, const LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "TTxProgressTransaction::Execute at " << Self->TabletID()); - try { - if (!Self->IsStateActive()) { - Self->IncCounter(COUNTER_TX_PROGRESS_SHARD_INACTIVE); - LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, - "Progress tx at non-ready tablet " << Self->TabletID() << " state " << Self->State); - Y_ABORT_UNLESS(!ActiveOp, "Unexpected ActiveOp at inactive shard %" PRIu64, Self->TabletID()); - Self->PlanQueue.Reset(ctx); - return true; - } + if (!Self->IsStateActive()) { + Self->IncCounter(COUNTER_TX_PROGRESS_SHARD_INACTIVE); + LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, + "Progress tx at non-ready tablet " << Self->TabletID() << " state " << Self->State); + Y_ENSURE(!ActiveOp, "Unexpected ActiveOp at inactive shard " << Self->TabletID()); + Self->PlanQueue.Reset(ctx); + return true; + } - if (!ActiveOp) { - const bool expireSnapshotsAllowed = ( - Self->State == TShardState::Ready || - Self->State == TShardState::SplitSrcWaitForNoTxInFlight || - Self->State == TShardState::SplitSrcMakeSnapshot); + if (!ActiveOp) { + const bool expireSnapshotsAllowed = ( + Self->State == TShardState::Ready || + Self->State == TShardState::SplitSrcWaitForNoTxInFlight || + Self->State == TShardState::SplitSrcMakeSnapshot); - const bool needFutureCleanup = Self->TxInFly() > 0 || expireSnapshotsAllowed; + const bool needFutureCleanup = Self->TxInFly() > 0 || expireSnapshotsAllowed; - if (needFutureCleanup) { - Self->PlanCleanup(ctx); - } + if (needFutureCleanup) { + Self->PlanCleanup(ctx); + } - // Allow another concurrent progress tx - Self->PlanQueue.Reset(ctx); - Self->Pipeline.ActivateWaitingTxOps(ctx); + // Allow another concurrent progress tx + Self->PlanQueue.Reset(ctx); + Self->Pipeline.ActivateWaitingTxOps(ctx); - ActiveOp = Self->Pipeline.GetNextActiveOp(false); + ActiveOp = Self->Pipeline.GetNextActiveOp(false); - if (!ActiveOp) { - Self->IncCounter(COUNTER_TX_PROGRESS_IDLE); - LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, - "No tx to execute at " << Self->TabletID() << " TxInFly " << Self->TxInFly()); - return true; - } + if (!ActiveOp) { + Self->IncCounter(COUNTER_TX_PROGRESS_IDLE); + LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, + "No tx to execute at " << Self->TabletID() << " TxInFly " << Self->TxInFly()); + return true; + } - Y_VERIFY_S(!ActiveOp->IsInProgress(), - "GetNextActiveOp returned in-progress operation " - << ActiveOp->GetKind() << " " << *ActiveOp << " (unit " - << ActiveOp->GetCurrentUnit() << ") at " << Self->TabletID()); - ActiveOp->IncrementInProgress(); - - if (ActiveOp->OperationSpan) { - if (!TxSpan) { - // If Progress Tx for this operation is being executed the first time, - // it won't have a span, because we choose what operation to run in the transaction itself. - // We create transaction span and transaction execution spans here instead. - SetupTxSpan(ActiveOp->GetTraceId()); - txc.StartExecutionSpan(); - } + Y_ENSURE(!ActiveOp->IsInProgress(), + "GetNextActiveOp returned in-progress operation " + << ActiveOp->GetKind() << " " << *ActiveOp << " (unit " + << ActiveOp->GetCurrentUnit() << ") at " << Self->TabletID()); + ActiveOp->IncrementInProgress(); + + if (ActiveOp->OperationSpan) { + if (!TxSpan) { + // If Progress Tx for this operation is being executed the first time, + // it won't have a span, because we choose what operation to run in the transaction itself. + // We create transaction span and transaction execution spans here instead. + SetupTxSpan(ActiveOp->GetTraceId()); + txc.StartExecutionSpan(); } } + } - Y_ABORT_UNLESS(ActiveOp && ActiveOp->IsInProgress()); - auto status = Self->Pipeline.RunExecutionPlan(ActiveOp, CompleteList, txc, ctx); - - if (Self->Pipeline.CanRunAnotherOp()) - Self->PlanQueue.Progress(ctx); + Y_ENSURE(ActiveOp && ActiveOp->IsInProgress()); + auto status = Self->Pipeline.RunExecutionPlan(ActiveOp, CompleteList, txc, ctx); - switch (status) { - case EExecutionStatus::Restart: - // Restart even if current CompleteList is not empty - // It will be extended in subsequent iterations - return false; + if (Self->Pipeline.CanRunAnotherOp()) + Self->PlanQueue.Progress(ctx); - case EExecutionStatus::Reschedule: - // Reschedule transaction as soon as possible - if (!ActiveOp->IsExecutionPlanFinished()) { - ActiveOp->IncrementInProgress(); - Self->ExecuteProgressTx(ActiveOp, ctx); - Rescheduled = true; - } - ActiveOp->DecrementInProgress(); - break; + switch (status) { + case EExecutionStatus::Restart: + // Restart even if current CompleteList is not empty + // It will be extended in subsequent iterations + return false; - case EExecutionStatus::Executed: - case EExecutionStatus::Continue: - ActiveOp->DecrementInProgress(); - break; + case EExecutionStatus::Reschedule: + // Reschedule transaction as soon as possible + if (!ActiveOp->IsExecutionPlanFinished()) { + ActiveOp->IncrementInProgress(); + Self->ExecuteProgressTx(ActiveOp, ctx); + Rescheduled = true; + } + ActiveOp->DecrementInProgress(); + break; - case EExecutionStatus::WaitComplete: - WaitComplete = true; - break; + case EExecutionStatus::Executed: + case EExecutionStatus::Continue: + ActiveOp->DecrementInProgress(); + break; - default: - Y_FAIL_S("unexpected execution status " << status << " for operation " - << *ActiveOp << " " << ActiveOp->GetKind() << " at " << Self->TabletID()); - } + case EExecutionStatus::WaitComplete: + WaitComplete = true; + break; - if (WaitComplete || !CompleteList.empty()) { - // Keep operation active until we run the complete list - CommitStart = AppData()->TimeProvider->Now(); - } else { - // Release operation as it's no longer needed - ActiveOp = nullptr; - } + default: + Y_ENSURE(false, "unexpected execution status " << status << " for operation " + << *ActiveOp << " " << ActiveOp->GetKind() << " at " << Self->TabletID()); + } - // Commit all side effects - return true; - } catch (...) { - Y_ABORT("there must be no leaked exceptions"); + if (WaitComplete || !CompleteList.empty()) { + // Keep operation active until we run the complete list + CommitStart = AppData()->TimeProvider->Now(); + } else { + // Release operation as it's no longer needed + ActiveOp = nullptr; } + + // Commit all side effects + return true; } void TDataShard::TTxProgressTransaction::Complete(const TActorContext &ctx) { @@ -123,7 +119,7 @@ void TDataShard::TTxProgressTransaction::Complete(const TActorContext &ctx) { "TTxProgressTransaction::Complete at " << Self->TabletID()); if (ActiveOp) { - Y_ABORT_UNLESS(!ActiveOp->GetExecutionPlan().empty()); + Y_ENSURE(!ActiveOp->GetExecutionPlan().empty()); if (!CompleteList.empty()) { auto commitTime = AppData()->TimeProvider->Now() - CommitStart; ActiveOp->SetCommitTime(CompleteList.front(), commitTime); diff --git a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp index 3100d46a28..11d7346060 100644 --- a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp +++ b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp @@ -67,7 +67,7 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa } if (Ev) { - Y_ABORT_UNLESS(!Op); + Y_ENSURE(!Op); if (Self->CheckDataTxRejectAndReply(Ev, ctx)) { Ev = nullptr; @@ -79,7 +79,7 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa // Unsuccessful operation parse. if (op->IsAborted()) { LWTRACK(ProposeTransactionParsed, op->Orbit, false); - Y_ABORT_UNLESS(op->Result()); + Y_ENSURE(op->Result()); op->OperationSpan.EndError("Unsuccessful operation parse"); ctx.Send(op->GetTarget(), op->Result().Release()); return true; @@ -96,7 +96,7 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa Op->IncrementInProgress(); } - Y_ABORT_UNLESS(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); + Y_ENSURE(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); auto status = Self->Pipeline.RunExecutionPlan(Op, CompleteList, txc, ctx); @@ -126,7 +126,7 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa break; default: - Y_FAIL_S("unexpected execution status " << status << " for operation " + Y_ENSURE(false, "unexpected execution status " << status << " for operation " << *Op << " " << Op->GetKind() << " at " << Self->TabletID()); } @@ -144,15 +144,6 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "TX [" << 0 << " : " << TxId << "] can't prepare (tablet's not ready) at tablet " << Self->TabletID()); return false; - } catch (const TSchemeErrorTabletException &ex) { - Y_UNUSED(ex); - Y_ABORT(); - } catch (const TMemoryLimitExceededException &ex) { - Y_ABORT("there must be no leaked exceptions: TMemoryLimitExceededException"); - } catch (const std::exception &e) { - Y_ABORT("there must be no leaked exceptions: %s", e.what()); - } catch (...) { - Y_ABORT("there must be no leaked exceptions"); } } @@ -161,7 +152,7 @@ void TDataShard::TTxProposeTransactionBase::Complete(const TActorContext &ctx) { "TTxProposeTransactionBase::Complete at " << Self->TabletID()); if (Op) { - Y_ABORT_UNLESS(!Op->GetExecutionPlan().empty()); + Y_ENSURE(!Op->GetExecutionPlan().empty()); if (!CompleteList.empty()) { auto commitTime = AppData()->TimeProvider->Now() - CommitStart; Op->SetCommitTime(CompleteList.front(), commitTime); diff --git a/ydb/core/tx/datashard/datashard__read_columns.cpp b/ydb/core/tx/datashard/datashard__read_columns.cpp index 0ea5151e61..cef2f24878 100644 --- a/ydb/core/tx/datashard/datashard__read_columns.cpp +++ b/ydb/core/tx/datashard/datashard__read_columns.cpp @@ -96,7 +96,7 @@ public: } EScan Seek(TLead& lead, ui64 seq) override { - Y_ABORT_UNLESS(seq == 0, "Unexpected repeated Seek"); + Y_ENSURE(seq == 0, "Unexpected repeated Seek"); lead.To(ValueColumns, From.Key.GetCells(), From.Inclusive ? NTable::ESeek::Lower : NTable::ESeek::Upper); lead.Until(To.Key.GetCells(), To.Inclusive); @@ -107,8 +107,8 @@ public: EScan Feed(TArrayRef<const TCell> key, const TRow& row) override { const auto& keyTypes = Scheme->Keys->BasicTypes(); - Y_ABORT_UNLESS(key.size() == keyTypes.size()); - Y_ABORT_UNLESS((*row).size() == ValueColumnTypes.size()); + Y_ENSURE(key.size() == keyTypes.size()); + Y_ENSURE((*row).size() == ValueColumnTypes.size()); TDbTupleRef rowKey(keyTypes.data(), key.data(), keyTypes.size()); TDbTupleRef rowValues(ValueColumnTypes.data(), (*row).data(), ValueColumnTypes.size()); diff --git a/ydb/core/tx/datashard/datashard__read_iterator.cpp b/ydb/core/tx/datashard/datashard__read_iterator.cpp index 18e64550eb..c8f7b07bb9 100644 --- a/ydb/core/tx/datashard/datashard__read_iterator.cpp +++ b/ydb/core/tx/datashard/datashard__read_iterator.cpp @@ -1131,7 +1131,7 @@ private: }; void AddReadConflict(ui64 txId) { - Y_ABORT_UNLESS(State.LockId); + Y_ENSURE(State.LockId); // We have skipped uncommitted changes in txId, which would affect // the read result when it commits. Add a conflict edge that breaks // our lock when txId is committed. @@ -1186,7 +1186,7 @@ const NHPTimer::STime TReader::MaxCyclesPerIteration = } // namespace void TReadIteratorState::ForwardScanEvent(std::unique_ptr<IEventHandle>&& ev, ui64 tabletId) { - Y_ABORT_UNLESS(State == EState::Scan); + Y_ENSURE(State == EState::Scan); if (ScanActorId) { LOG_TRACE_S(*TlsActivationContext, NKikimrServices::TX_DATASHARD, tabletId << " forwarding " << ev->GetTypeName() << " to scan actor " << ScanActorId); @@ -1240,8 +1240,8 @@ private: } TInitialState Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) final { - Y_ABORT_UNLESS(driver); - Y_ABORT_UNLESS(scheme); + Y_ENSURE(driver); + Y_ENSURE(scheme); Driver = driver; TActivationContext::AsActorContext().RegisterWithSameMailbox(this); @@ -1368,7 +1368,7 @@ private: continuationToken.SetFirstUnprocessedQuery(RangeIndex); continuationToken.SetLastProcessedKey(TSerializedCellVec::Serialize(key)); bool res = continuationToken.SerializeToString(record.MutableContinuationToken()); - Y_ABORT_UNLESS(res); + Y_ENSURE(res); } ui64 blockRows = std::exchange(BlockRows, 0); @@ -1390,7 +1390,7 @@ private: break; } default: { - Y_ABORT("Unexpected format"); + Y_ENSURE(false, "Unexpected format"); } } } @@ -1527,8 +1527,8 @@ public: void BuildExecutionPlan(bool loaded) override { - Y_ABORT_UNLESS(GetExecutionPlan().empty()); - Y_ABORT_UNLESS(!loaded); + Y_ENSURE(GetExecutionPlan().empty()); + Y_ENSURE(!loaded); TVector<EExecutionUnitKind> plan; plan.push_back(EExecutionUnitKind::CheckRead); @@ -1556,7 +1556,7 @@ public: return EExecutionStatus::DelayComplete; } - Y_ABORT_UNLESS(state.State == TReadIteratorState::EState::Executing); + Y_ENSURE(state.State == TReadIteratorState::EState::Executing); auto* request = state.Request; @@ -1848,7 +1848,7 @@ public: for (ui64 txId : Reader->GetVolatileReadDependencies()) { AddVolatileDependency(txId); bool ok = Self->GetVolatileTxManager().AttachBlockedOperation(txId, GetTxId()); - Y_ABORT_UNLESS(ok, "Unexpected failure to attach a blocked operation"); + Y_ENSURE(ok, "Unexpected failure to attach a blocked operation"); } Reader.reset(); Result = MakeEvReadResult(ctx.SelfID.NodeId()); @@ -1915,7 +1915,7 @@ public: return; } auto& state = *it->second; - Y_ABORT_UNLESS(state.State == TReadIteratorState::EState::Init); + Y_ENSURE(state.State == TReadIteratorState::EState::Init); Result = MakeEvReadResult(ctx.SelfID.NodeId()); @@ -1948,16 +1948,16 @@ public: // Note: some checks already performed in TTxReadViaPipeline::Execute if (state.PathId.OwnerId != Self->TabletID()) { // owner is schemeshard, read user table - Y_ABORT_UNLESS(state.PathId.OwnerId == Self->GetPathOwnerId()); + Y_ENSURE(state.PathId.OwnerId == Self->GetPathOwnerId()); const auto tableId = state.PathId.LocalPathId; auto it = Self->TableInfos.find(tableId); - Y_ABORT_UNLESS(it != Self->TableInfos.end()); + Y_ENSURE(it != Self->TableInfos.end()); auto& userTableInfo = it->second; TableInfo = TShortTableInfo(userTableInfo); - Y_ABORT_UNLESS(!userTableInfo->IsBackup); + Y_ENSURE(!userTableInfo->IsBackup); state.SchemaVersion = userTableInfo->GetTableSchemaVersion(); if (record.GetTableId().HasSchemaVersion()) { @@ -2430,280 +2430,270 @@ public: return true; } - try { - // If tablet is in follower mode then we should sync scheme - // before we build and check operation. - if (Self->IsFollower()) { - NKikimrTxDataShard::TError::EKind status = NKikimrTxDataShard::TError::OK; - TString errMessage; + // If tablet is in follower mode then we should sync scheme + // before we build and check operation. + if (Self->IsFollower()) { + NKikimrTxDataShard::TError::EKind status = NKikimrTxDataShard::TError::OK; + TString errMessage; - if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) { - return false; + if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) { + return false; + } + + if (status != NKikimrTxDataShard::TError::OK) { + Y_DEBUG_ABORT_UNLESS(!Op); + if (Y_UNLIKELY(readIt == Self->ReadIteratorsByLocalReadId.end())) { + // iterator already aborted + return true; } + auto& state = *readIt->second; + state.EnqueuedLocalTxId = 0; + ReplyError( + Ydb::StatusIds::INTERNAL_ERROR, + TStringBuilder() << "Failed to sync follower: " << errMessage + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } + } - if (status != NKikimrTxDataShard::TError::OK) { - Y_DEBUG_ABORT_UNLESS(!Op); - if (Y_UNLIKELY(readIt == Self->ReadIteratorsByLocalReadId.end())) { - // iterator already aborted - return true; - } - auto& state = *readIt->second; - state.EnqueuedLocalTxId = 0; + if (!Op) { + // We must perform some initialization in transaction (e.g. after a follower sync), but before the operation is built + Y_ENSURE(readIt != Self->ReadIteratorsByLocalReadId.end()); + auto& state = *readIt->second; + auto* request = state.Request; + const auto& record = request->Record; + + Y_ENSURE(state.State == TReadIteratorState::EState::Init); + state.EnqueuedLocalTxId = 0; + + bool setUsingSnapshotFlag = false; + + // We assume that owner is schemeshard and it's a user table + if (state.PathId.OwnerId != Self->TabletID()) { + if (state.PathId.OwnerId != Self->GetPathOwnerId()) { ReplyError( - Ydb::StatusIds::INTERNAL_ERROR, - TStringBuilder() << "Failed to sync follower: " << errMessage + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Requesting ownerId: " << state.PathId.OwnerId + << ", tableId: " << state.PathId.LocalPathId + << ", from shard with owner: " << Self->GetPathOwnerId() << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", ctx.SelfID.NodeId(), state); return true; } - } - if (!Op) { - // We must perform some initialization in transaction (e.g. after a follower sync), but before the operation is built - Y_ABORT_UNLESS(readIt != Self->ReadIteratorsByLocalReadId.end()); - auto& state = *readIt->second; - auto* request = state.Request; - const auto& record = request->Record; + const auto tableId = state.PathId.LocalPathId; + auto it = Self->TableInfos.find(tableId); + if (it == Self->TableInfos.end()) { + ReplyError( + Ydb::StatusIds::NOT_FOUND, + TStringBuilder() << "Unknown table id: " << tableId + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } - Y_ABORT_UNLESS(state.State == TReadIteratorState::EState::Init); - state.EnqueuedLocalTxId = 0; + auto& userTableInfo = it->second; + if (userTableInfo->IsBackup) { + ReplyError( + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Can't read from a backup table" + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } - bool setUsingSnapshotFlag = false; - - // We assume that owner is schemeshard and it's a user table - if (state.PathId.OwnerId != Self->TabletID()) { - if (state.PathId.OwnerId != Self->GetPathOwnerId()) { - ReplyError( - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Requesting ownerId: " << state.PathId.OwnerId - << ", tableId: " << state.PathId.LocalPathId - << ", from shard with owner: " << Self->GetPathOwnerId() - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; + if (state.IsHeadRead) { + // We want to try and choose a more specific non-repeatable snapshot + if (Self->IsFollower()) { + auto [followerEdge, followerRepeatable] = Self->GetSnapshotManager().GetFollowerReadEdge(); + // Note: during transition follower edge may be unitialized or lag behind + // We assume we can use it when it's not before low watermark + auto maxRepeatable = !followerEdge || followerRepeatable ? followerEdge : followerEdge.Prev(); + if (maxRepeatable >= Self->GetSnapshotManager().GetLowWatermark()) { + state.ReadVersion = followerEdge; + state.IsHeadRead = !followerRepeatable; + } + } else { + state.ReadVersion = Self->GetMvccTxVersion(EMvccTxMode::ReadOnly); } - - const auto tableId = state.PathId.LocalPathId; - auto it = Self->TableInfos.find(tableId); - if (it == Self->TableInfos.end()) { - ReplyError( - Ydb::StatusIds::NOT_FOUND, - TStringBuilder() << "Unknown table id: " << tableId - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; + if (!state.ReadVersion.IsMax()) { + LOG_TRACE_S(ctx, NKikimrServices::TX_DATASHARD, + Self->TabletID() << " changed HEAD read to " + << (state.IsHeadRead ? "non-repeatable" : "repeatable") + << " " << state.ReadVersion); } + } else { + bool snapshotFound = false; - auto& userTableInfo = it->second; - if (userTableInfo->IsBackup) { - ReplyError( - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Can't read from a backup table" - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; + const ui64 ownerId = state.PathId.OwnerId; + TSnapshotKey snapshotKey( + ownerId, + tableId, + state.ReadVersion.Step, + state.ReadVersion.TxId); + + if (Self->GetSnapshotManager().FindAvailable(snapshotKey)) { + // TODO: do we need to acquire? + setUsingSnapshotFlag = true; + snapshotFound = true; } - if (state.IsHeadRead) { - // We want to try and choose a more specific non-repeatable snapshot + if (!snapshotFound) { + bool snapshotUnavailable = false; + + if (state.ReadVersion < Self->GetSnapshotManager().GetLowWatermark() || state.ReadVersion.Step == Max<ui64>()) { + snapshotUnavailable = true; + } + if (Self->IsFollower()) { auto [followerEdge, followerRepeatable] = Self->GetSnapshotManager().GetFollowerReadEdge(); - // Note: during transition follower edge may be unitialized or lag behind - // We assume we can use it when it's not before low watermark auto maxRepeatable = !followerEdge || followerRepeatable ? followerEdge : followerEdge.Prev(); - if (maxRepeatable >= Self->GetSnapshotManager().GetLowWatermark()) { - state.ReadVersion = followerEdge; - state.IsHeadRead = !followerRepeatable; - } - } else { - state.ReadVersion = Self->GetMvccTxVersion(EMvccTxMode::ReadOnly); - } - if (!state.ReadVersion.IsMax()) { - LOG_TRACE_S(ctx, NKikimrServices::TX_DATASHARD, - Self->TabletID() << " changed HEAD read to " - << (state.IsHeadRead ? "non-repeatable" : "repeatable") - << " " << state.ReadVersion); - } - } else { - bool snapshotFound = false; - - const ui64 ownerId = state.PathId.OwnerId; - TSnapshotKey snapshotKey( - ownerId, - tableId, - state.ReadVersion.Step, - state.ReadVersion.TxId); - - if (Self->GetSnapshotManager().FindAvailable(snapshotKey)) { - // TODO: do we need to acquire? - setUsingSnapshotFlag = true; - snapshotFound = true; - } - - if (!snapshotFound) { - bool snapshotUnavailable = false; - - if (state.ReadVersion < Self->GetSnapshotManager().GetLowWatermark() || state.ReadVersion.Step == Max<ui64>()) { + if (state.ReadVersion > maxRepeatable) { snapshotUnavailable = true; } - - if (Self->IsFollower()) { - auto [followerEdge, followerRepeatable] = Self->GetSnapshotManager().GetFollowerReadEdge(); - auto maxRepeatable = !followerEdge || followerRepeatable ? followerEdge : followerEdge.Prev(); - if (state.ReadVersion > maxRepeatable) { - snapshotUnavailable = true; - } - } else { - TRowVersion unreadableEdge = Self->Pipeline.GetUnreadableEdge(); - if (state.ReadVersion >= unreadableEdge) { - LWTRACK(ReadWaitSnapshot, request->Orbit, state.ReadVersion.Step, state.ReadVersion.TxId); - Self->Pipeline.AddWaitingReadIterator(state.ReadVersion, std::move(state.Ev), ctx); - Self->DeleteReadIterator(readIt); - return true; - } - } - - if (snapshotUnavailable) { - ReplyError( - Ydb::StatusIds::PRECONDITION_FAILED, - TStringBuilder() << "Table id " << tableId << " has no snapshot at " - << state.ReadVersion << " shard " << Self->TabletID() - << " with lowWatermark " << Self->GetSnapshotManager().GetLowWatermark() - << (Self->IsFollower() ? " RO replica" : "") - << " (node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); + } else { + TRowVersion unreadableEdge = Self->Pipeline.GetUnreadableEdge(); + if (state.ReadVersion >= unreadableEdge) { + LWTRACK(ReadWaitSnapshot, request->Orbit, state.ReadVersion.Step, state.ReadVersion.TxId); + Self->Pipeline.AddWaitingReadIterator(state.ReadVersion, std::move(state.Ev), ctx); + Self->DeleteReadIterator(readIt); return true; } } - } - } else { - // Handle system table reads - if (Self->IsFollower()) { - ReplyError( - Ydb::StatusIds::UNSUPPORTED, - TStringBuilder() << "Followers don't support system table reads" - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; - } - if (!state.IsHeadRead) { - ReplyError( - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Cannot read system table using snapshot " << state.ReadVersion - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; - } - if (record.GetTableId().GetTableId() >= TDataShard::Schema::MinLocalTid) { - ReplyError( - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Cannot read from user tables using system tables" - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; - } - if (record.GetResultFormat() != NKikimrDataEvents::FORMAT_CELLVEC) { - ReplyError( - Ydb::StatusIds::UNSUPPORTED, - TStringBuilder() << "Unsupported result format " - << (int)record.GetResultFormat() << " when reading from system tables" - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; - } - if (record.GetTableId().HasSchemaVersion()) { - ReplyError( - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Cannot request system table at shard " << record.GetTableId().GetOwnerId() - << ", localTid: " << record.GetTableId().GetTableId() - << ", with schema: " << record.GetTableId().GetSchemaVersion() - << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", - ctx.SelfID.NodeId(), - state); - return true; - } - // We don't want this read to interact with other operations - setUsingSnapshotFlag = true; + if (snapshotUnavailable) { + ReplyError( + Ydb::StatusIds::PRECONDITION_FAILED, + TStringBuilder() << "Table id " << tableId << " has no snapshot at " + << state.ReadVersion << " shard " << Self->TabletID() + << " with lowWatermark " << Self->GetSnapshotManager().GetLowWatermark() + << (Self->IsFollower() ? " RO replica" : "") + << " (node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } + } + } + } else { + // Handle system table reads + if (Self->IsFollower()) { + ReplyError( + Ydb::StatusIds::UNSUPPORTED, + TStringBuilder() << "Followers don't support system table reads" + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } + if (!state.IsHeadRead) { + ReplyError( + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Cannot read system table using snapshot " << state.ReadVersion + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } + if (record.GetTableId().GetTableId() >= TDataShard::Schema::MinLocalTid) { + ReplyError( + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Cannot read from user tables using system tables" + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } + if (record.GetResultFormat() != NKikimrDataEvents::FORMAT_CELLVEC) { + ReplyError( + Ydb::StatusIds::UNSUPPORTED, + TStringBuilder() << "Unsupported result format " + << (int)record.GetResultFormat() << " when reading from system tables" + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; + } + if (record.GetTableId().HasSchemaVersion()) { + ReplyError( + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Cannot request system table at shard " << record.GetTableId().GetOwnerId() + << ", localTid: " << record.GetTableId().GetTableId() + << ", with schema: " << record.GetTableId().GetSchemaVersion() + << " (shard# " << Self->TabletID() << " node# " << ctx.SelfID.NodeId() << " state# " << DatashardStateName(Self->State) << ")", + ctx.SelfID.NodeId(), + state); + return true; } - Op = new TReadOperation(Self, ctx.Now(), LocalReadId); + // We don't want this read to interact with other operations + setUsingSnapshotFlag = true; + } - Op->BuildExecutionPlan(false); - Self->Pipeline.GetExecutionUnit(Op->GetCurrentUnit()).AddOperation(Op); + Op = new TReadOperation(Self, ctx.Now(), LocalReadId); - if (!state.ReadVersion.IsMax()) { - Op->SetMvccSnapshot( - TRowVersion(state.ReadVersion.Step, state.ReadVersion.TxId), - /* repeatable = */ state.IsHeadRead ? false : true); - } - if (setUsingSnapshotFlag) { - Op->SetUsingSnapshotFlag(); - } + Op->BuildExecutionPlan(false); + Self->Pipeline.GetExecutionUnit(Op->GetCurrentUnit()).AddOperation(Op); - Op->IncrementInProgress(); + if (!state.ReadVersion.IsMax()) { + Op->SetMvccSnapshot( + TRowVersion(state.ReadVersion.Step, state.ReadVersion.TxId), + /* repeatable = */ state.IsHeadRead ? false : true); + } + if (setUsingSnapshotFlag) { + Op->SetUsingSnapshotFlag(); } - Y_ABORT_UNLESS(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); + Op->IncrementInProgress(); + } - auto status = Self->Pipeline.RunExecutionPlan(Op, CompleteList, txc, ctx); + Y_ENSURE(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); - LOG_TRACE_S(ctx, NKikimrServices::TX_DATASHARD, "TTxReadViaPipeline(" << GetTxType() - << ") Execute with status# " << status << " at tablet# " << Self->TabletID()); + auto status = Self->Pipeline.RunExecutionPlan(Op, CompleteList, txc, ctx); - switch (status) { - case EExecutionStatus::Restart: - return false; - - case EExecutionStatus::Reschedule: - // Reschedule transaction as soon as possible - if (!Op->IsExecutionPlanFinished()) { - Op->IncrementInProgress(); - Self->ExecuteProgressTx(Op, ctx); - } - Op->DecrementInProgress(); - break; + LOG_TRACE_S(ctx, NKikimrServices::TX_DATASHARD, "TTxReadViaPipeline(" << GetTxType() + << ") Execute with status# " << status << " at tablet# " << Self->TabletID()); - case EExecutionStatus::Executed: - case EExecutionStatus::Continue: - Op->DecrementInProgress(); - break; + switch (status) { + case EExecutionStatus::Restart: + return false; - case EExecutionStatus::WaitComplete: - WaitComplete = true; - break; + case EExecutionStatus::Reschedule: + // Reschedule transaction as soon as possible + if (!Op->IsExecutionPlanFinished()) { + Op->IncrementInProgress(); + Self->ExecuteProgressTx(Op, ctx); + } + Op->DecrementInProgress(); + break; - default: - Y_FAIL_S("unexpected execution status " << status << " for operation " - << *Op << " " << Op->GetKind() << " at " << Self->TabletID()); - } + case EExecutionStatus::Executed: + case EExecutionStatus::Continue: + Op->DecrementInProgress(); + break; - if (WaitComplete || !CompleteList.empty()) { - // Keep operation active until we run the complete list - } else { - // Release operation as it's no longer needed - Op = nullptr; - } + case EExecutionStatus::WaitComplete: + WaitComplete = true; + break; - return true; - } catch (const TSchemeErrorTabletException&) { - Y_ABORT(); - } catch (const TMemoryLimitExceededException&) { - Y_ABORT("there must be no leaked exceptions: TMemoryLimitExceededException"); - } catch (const std::exception &e) { - Y_ABORT("there must be no leaked exceptions: %s", e.what()); - } catch (...) { - Y_ABORT("there must be no leaked exceptions"); + default: + Y_ENSURE(false, "unexpected execution status " << status << " for operation " + << *Op << " " << Op->GetKind() << " at " << Self->TabletID()); + } + + if (WaitComplete || !CompleteList.empty()) { + // Keep operation active until we run the complete list + } else { + // Release operation as it's no longer needed + Op = nullptr; } + + return true; } void ReplyError(Ydb::StatusIds::StatusCode code, const TString& message, ui32 nodeId, TReadIteratorState& state) { @@ -2719,7 +2709,7 @@ public: << ": at tablet# " << Self->TabletID()); if (Reply) { - Y_ABORT_UNLESS(!Op); + Y_ENSURE(!Op); auto it = Self->ReadIteratorsByLocalReadId.find(LocalReadId); if (it != Self->ReadIteratorsByLocalReadId.end()) { auto& state = *it->second; @@ -2733,7 +2723,7 @@ public: if (!Op) return; - Y_ABORT_UNLESS(!Op->GetExecutionPlan().empty()); + Y_ENSURE(!Op->GetExecutionPlan().empty()); if (!CompleteList.empty()) { Self->Pipeline.RunCompleteList(Op, CompleteList, ctx); } @@ -2963,7 +2953,7 @@ public: void ApplyLocks(const TActorContext& ctx) { auto it = Self->ReadIteratorsByLocalReadId.find(LocalReadId); - Y_ABORT_UNLESS(it != Self->ReadIteratorsByLocalReadId.end()); + Y_ENSURE(it != Self->ReadIteratorsByLocalReadId.end()); auto& state = *it->second; if (!Result) { @@ -2984,7 +2974,7 @@ public: if (!isBroken && (Reader->HadInvisibleRowSkips() || Reader->HadInconsistentResult())) { sysLocks.BreakLock(state.Lock->GetLockId()); sysLocks.ApplyLocks(); - Y_ABORT_UNLESS(state.Lock->IsBroken()); + Y_ENSURE(state.Lock->IsBroken()); isBroken = true; } @@ -3010,14 +3000,14 @@ public: } else { // Lock valid, apply conflict changes auto [locks, _] = sysLocks.ApplyLocks(); - Y_ABORT_UNLESS(locks.empty(), "ApplyLocks acquired unexpected locks"); + Y_ENSURE(locks.empty(), "ApplyLocks acquired unexpected locks"); } } } void SendResult(const TActorContext& ctx) { auto it = Self->ReadIteratorsByLocalReadId.find(LocalReadId); - Y_ABORT_UNLESS(it != Self->ReadIteratorsByLocalReadId.end()); + Y_ENSURE(it != Self->ReadIteratorsByLocalReadId.end()); auto& state = *it->second; state.ReadContinuePending = false; @@ -3262,7 +3252,7 @@ void TDataShard::Handle(TEvDataShard::TEvRead::TPtr& ev, const TActorContext& ct readId, localReadId, TPathId(record.GetTableId().GetOwnerId(), record.GetTableId().GetTableId()), sessionId, readVersion, isHeadRead, AppData()->MonotonicTimeProvider->Now())); - Y_ABORT_UNLESS(pr.second); + Y_ENSURE(pr.second); auto& state = pr.first->second; state.Ev = std::move(ev); @@ -3393,7 +3383,7 @@ void TDataShard::Handle(TEvDataShard::TEvReadCancel::TPtr& ev, const TActorConte TReadIteratorId readId(ev->Sender, record.GetReadId()); if (Pipeline.CancelWaitingReadIterator(readId)) { - Y_ABORT_UNLESS(!ReadIterators.contains(readId)); + Y_ENSURE(!ReadIterators.contains(readId)); return; } @@ -3517,7 +3507,7 @@ void TDataShard::DeleteReadIterator(TReadIteratorsMap::iterator it) { void TDataShard::DeleteReadIterator(TReadIteratorsLocalMap::iterator localIt) { auto readIt = ReadIterators.find(localIt->second->ReadId); - Y_ABORT_UNLESS(readIt != ReadIterators.end()); + Y_ENSURE(readIt != ReadIterators.end()); DeleteReadIterator(readIt); } diff --git a/ydb/core/tx/datashard/datashard__readset.cpp b/ydb/core/tx/datashard/datashard__readset.cpp index 6fea5c1056..e8d454582f 100644 --- a/ydb/core/tx/datashard/datashard__readset.cpp +++ b/ydb/core/tx/datashard/datashard__readset.cpp @@ -31,10 +31,10 @@ namespace NKikimr::NDataShard { void TDataShard::TTxReadSet::DoExecute(TTransactionContext &txc, const TActorContext &ctx) { auto state = Self->State; - Y_ABORT_UNLESS(state != TShardState::Unknown + Y_ENSURE(state != TShardState::Unknown && state != TShardState::Uninitialized && state != TShardState::Readonly, - "State %" PRIu32 " event %s", state, Ev->Get()->ToString().data()); + "State " << state << " event " << Ev->Get()->ToString()); const auto& msg = *Ev->Get(); const auto& record = msg.Record; @@ -65,7 +65,7 @@ namespace NKikimr::NDataShard { bool saved = Self->Pipeline.SaveInReadSet(msg, Ack, txc, ctx); if (!saved) { // delayed. Do not ack - Y_ABORT_UNLESS(!Ack); + Y_ENSURE(!Ack); } } diff --git a/ydb/core/tx/datashard/datashard__s3_download_txs.cpp b/ydb/core/tx/datashard/datashard__s3_download_txs.cpp index 8d9410fd13..e96e8369e0 100644 --- a/ydb/core/tx/datashard/datashard__s3_download_txs.cpp +++ b/ydb/core/tx/datashard/datashard__s3_download_txs.cpp @@ -27,7 +27,7 @@ bool TDataShard::TTxGetS3DownloadInfo::Execute(TTransactionContext& txc, const T } void TDataShard::TTxGetS3DownloadInfo::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); ctx.Send(Ev->Sender, Reply.Release(), 0, Ev->Cookie); } @@ -50,7 +50,7 @@ bool TDataShard::TTxStoreS3DownloadInfo::Execute(TTransactionContext& txc, const } void TDataShard::TTxStoreS3DownloadInfo::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); ctx.Send(Ev->Sender, Reply.Release(), 0, Ev->Cookie); } diff --git a/ydb/core/tx/datashard/datashard__s3_upload_txs.cpp b/ydb/core/tx/datashard/datashard__s3_upload_txs.cpp index 812342a71c..fd22e43e9b 100644 --- a/ydb/core/tx/datashard/datashard__s3_upload_txs.cpp +++ b/ydb/core/tx/datashard/datashard__s3_upload_txs.cpp @@ -26,7 +26,7 @@ bool TDataShard::TTxGetS3Upload::Execute(TTransactionContext& txc, const TActorC } void TDataShard::TTxGetS3Upload::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); ctx.Send(Ev->Get()->ReplyTo, Reply.Release(), 0, Ev->Cookie); } @@ -49,7 +49,7 @@ bool TDataShard::TTxStoreS3UploadId::Execute(TTransactionContext& txc, const TAc } void TDataShard::TTxStoreS3UploadId::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); ctx.Send(Ev->Get()->ReplyTo, Reply.Release(), 0, Ev->Cookie); } @@ -72,7 +72,7 @@ bool TDataShard::TTxChangeS3UploadStatus::Execute(TTransactionContext& txc, cons } void TDataShard::TTxChangeS3UploadStatus::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); ctx.Send(Ev->Get()->ReplyTo, Reply.Release(), 0, Ev->Cookie); } diff --git a/ydb/core/tx/datashard/datashard__snapshot_txs.cpp b/ydb/core/tx/datashard/datashard__snapshot_txs.cpp index 53c08a0ac3..f390671b43 100644 --- a/ydb/core/tx/datashard/datashard__snapshot_txs.cpp +++ b/ydb/core/tx/datashard/datashard__snapshot_txs.cpp @@ -69,7 +69,7 @@ bool TDataShard::TTxRefreshVolatileSnapshot::Execute(TTransactionContext&, const } void TDataShard::TTxRefreshVolatileSnapshot::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); ctx.Send(Ev->Sender, Reply.Release(), 0, Ev->Cookie); } @@ -140,7 +140,7 @@ bool TDataShard::TTxDiscardVolatileSnapshot::Execute(TTransactionContext& txc, c } void TDataShard::TTxDiscardVolatileSnapshot::Complete(const TActorContext& ctx) { - Y_ABORT_UNLESS(Reply); + Y_ENSURE(Reply); ctx.Send(Ev->Sender, Reply.Release(), 0, Ev->Cookie); } diff --git a/ydb/core/tx/datashard/datashard__stats.cpp b/ydb/core/tx/datashard/datashard__stats.cpp index d04fc66564..c422a32230 100644 --- a/ydb/core/tx/datashard/datashard__stats.cpp +++ b/ydb/core/tx/datashard/datashard__stats.cpp @@ -81,20 +81,20 @@ public: } TResult Locate(const TMemTable*, ui64, ui32) override { - Y_ABORT("IPages::Locate(TMemTable*, ...) shouldn't be used here"); + Y_ENSURE(false, "IPages::Locate(TMemTable*, ...) shouldn't be used here"); } TResult Locate(const TPart*, ui64, ELargeObj) override { - Y_ABORT("IPages::Locate(TPart*, ...) shouldn't be used here"); + Y_ENSURE(false, "IPages::Locate(TPart*, ...) shouldn't be used here"); } const TSharedData* TryGetPage(const TPart* part, TPageId pageId, TGroupId groupId) override { - Y_ABORT_UNLESS(groupId.IsMain(), "Unsupported column group"); + Y_ENSURE(groupId.IsMain(), "Unsupported column group"); auto partStore = CheckedCast<const TPartStore*>(part); auto info = partStore->PageCollections.at(groupId.Index).Get(); auto type = info->GetPageType(pageId); - Y_ABORT_UNLESS(type == EPage::FlatIndex || type == EPage::BTreeIndex); + Y_ENSURE(type == EPage::FlatIndex || type == EPage::BTreeIndex); auto& partPages = Pages[part]; auto page = partPages.FindPtr(pageId); @@ -127,7 +127,7 @@ public: } page = partPages.FindPtr(pageId); - Y_ABORT_UNLESS(page != nullptr); + Y_ENSURE(page != nullptr); return page; } @@ -231,8 +231,8 @@ private: auto ev = WaitForSpecificEvent<TEvResourceBroker::TEvResourceAllocated>(&TTableStatsCoroBuilder::ProcessUnexpectedEvent); auto msg = ev->Get(); - Y_ABORT_UNLESS(!msg->Cookie.Get(), "Unexpected cookie in TEvResourceAllocated"); - Y_ABORT_UNLESS(msg->TaskId == 1, "Unexpected task id in TEvResourceAllocated"); + Y_ENSURE(!msg->Cookie.Get(), "Unexpected cookie in TEvResourceAllocated"); + Y_ENSURE(msg->TaskId == 1, "Unexpected task id in TEvResourceAllocated"); CoroutineDeadline = GetCycleCountFast() + DurationToCycles(MaxCoroutineExecutionTime); } diff --git a/ydb/core/tx/datashard/datashard__store_table_path.cpp b/ydb/core/tx/datashard/datashard__store_table_path.cpp index f1c8983ac1..c8be5fded0 100644 --- a/ydb/core/tx/datashard/datashard__store_table_path.cpp +++ b/ydb/core/tx/datashard/datashard__store_table_path.cpp @@ -19,7 +19,7 @@ bool TDataShard::TTxStoreTablePath::Execute(TTransactionContext &txc, const TAct LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "TTxStoreTablePath::Execute at " << Self->TabletID()); - Y_ABORT_UNLESS(Self->TableInfos.contains(PathId)); + Y_ENSURE(Self->TableInfos.contains(PathId)); txc.DB.NoMoreReadsForTx(); diff --git a/ydb/core/tx/datashard/datashard__write.cpp b/ydb/core/tx/datashard/datashard__write.cpp index 56615033cd..2e751e5d4b 100644 --- a/ydb/core/tx/datashard/datashard__write.cpp +++ b/ydb/core/tx/datashard/datashard__write.cpp @@ -65,7 +65,7 @@ bool TDataShard::TTxWrite::Execute(TTransactionContext& txc, const TActorContext } if (Ev) { - Y_ABORT_UNLESS(!Op); + Y_ENSURE(!Op); if (Self->CheckDataTxRejectAndReply(Ev, ctx)) { Ev = nullptr; @@ -73,14 +73,14 @@ bool TDataShard::TTxWrite::Execute(TTransactionContext& txc, const TActorContext } TOperation::TPtr op = Self->Pipeline.BuildOperation(std::move(Ev), ReceivedAt, TieBreakerIndex, txc, std::move(DatashardTransactionSpan)); - Y_ABORT_UNLESS(!Ev); + Y_ENSURE(!Ev); TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op); // Unsuccessful operation parse. if (op->IsAborted()) { LWTRACK(ProposeTransactionParsed, op->Orbit, false); - Y_ABORT_UNLESS(writeOp->GetWriteResult()); + Y_ENSURE(writeOp->GetWriteResult()); op->OperationSpan.EndError("Unsuccessful operation parse"); ctx.Send(op->GetTarget(), writeOp->ReleaseWriteResult().release()); return true; @@ -95,7 +95,7 @@ bool TDataShard::TTxWrite::Execute(TTransactionContext& txc, const TActorContext Op->IncrementInProgress(); } - Y_ABORT_UNLESS(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); + Y_ENSURE(Op && Op->IsInProgress() && !Op->GetExecutionPlan().empty()); auto status = Self->Pipeline.RunExecutionPlan(Op, CompleteList, txc, ctx); @@ -125,7 +125,7 @@ bool TDataShard::TTxWrite::Execute(TTransactionContext& txc, const TActorContext break; default: - Y_FAIL_S("unexpected execution status " << status << " for operation " << *Op << " " << Op->GetKind() << " at " << Self->TabletID()); + Y_ENSURE(false, "unexpected execution status " << status << " for operation " << *Op << " " << Op->GetKind() << " at " << Self->TabletID()); } if (WaitComplete || !CompleteList.empty()) { @@ -141,15 +141,6 @@ bool TDataShard::TTxWrite::Execute(TTransactionContext& txc, const TActorContext } catch (const TNotReadyTabletException&) { LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "TX [" << 0 << " : " << TxId << "] can't prepare (tablet's not ready) at tablet " << Self->TabletID()); return false; - } catch (const TSchemeErrorTabletException& ex) { - Y_UNUSED(ex); - Y_ABORT(); - } catch (const TMemoryLimitExceededException& ex) { - Y_ABORT("there must be no leaked exceptions: TMemoryLimitExceededException"); - } catch (const std::exception& e) { - Y_ABORT("there must be no leaked exceptions: %s", e.what()); - } catch (...) { - Y_ABORT("there must be no leaked exceptions"); } return true; @@ -159,7 +150,7 @@ void TDataShard::TTxWrite::Complete(const TActorContext& ctx) { LOG_TRACE_S(ctx, NKikimrServices::TX_DATASHARD, "TTxWrite complete: at tablet# " << Self->TabletID()); if (Op) { - Y_ABORT_UNLESS(!Op->GetExecutionPlan().empty()); + Y_ENSURE(!Op->GetExecutionPlan().empty()); if (!CompleteList.empty()) { auto commitTime = AppData()->TimeProvider->Now() - CommitStart; Op->SetCommitTime(CompleteList.front(), commitTime); @@ -225,7 +216,7 @@ void TDataShard::Handle(NEvents::TDataEvents::TEvWrite::TPtr& ev, const TActorCo UpdateProposeQueueSize(); return; } else { - Y_ABORT("Unexpected failure to add a waiting unrejected tx"); + Y_ENSURE(false, "Unexpected failure to add a waiting unrejected tx"); } } @@ -241,7 +232,7 @@ ui64 NEvWrite::TConvertor::GetTxId(const TAutoPtr<IEventHandle>& ev) { case NEvents::TDataEvents::TEvWrite::EventType: return ev->Get<NEvents::TDataEvents::TEvWrite>()->GetTxId(); default: - Y_FAIL_S("Unexpected event type " << ev->GetTypeRewrite()); + Y_ENSURE(false, "Unexpected event type " << ev->GetTypeRewrite()); } } @@ -254,7 +245,7 @@ ui64 NEvWrite::TConvertor::GetProposeFlags(NKikimrDataEvents::TEvWrite::ETxMode case NKikimrDataEvents::TEvWrite::MODE_IMMEDIATE: return TTxFlags::Immediate; default: - Y_FAIL_S("Unexpected tx mode " << txMode); + Y_ENSURE(false, "Unexpected tx mode " << txMode); } } @@ -314,7 +305,7 @@ TOperation::TPtr NEvWrite::TConvertor::MakeOperation(EOperationKind kind, const case EOperationKind::DirectTx: case EOperationKind::ReadTx: case EOperationKind::Unknown: - Y_ABORT("Unsupported"); + Y_ENSURE(false, "Unsupported"); } } } diff --git a/ydb/core/tx/datashard/datashard_active_transaction.cpp b/ydb/core/tx/datashard/datashard_active_transaction.cpp index aeffe7ef4b..391ebe0b4a 100644 --- a/ydb/core/tx/datashard/datashard_active_transaction.cpp +++ b/ydb/core/tx/datashard/datashard_active_transaction.cpp @@ -45,7 +45,7 @@ TValidatedDataTx::TValidatedDataTx(TDataShard *self, ComputeTxSize(); NActors::NMemory::TLabel<MemoryLabelValidatedDataTx>::Add(TxSize); - Y_ABORT_UNLESS(Tx.HasMiniKQL() || Tx.HasReadTableTransaction() || Tx.HasKqpTransaction(), + Y_ENSURE(Tx.HasMiniKQL() || Tx.HasReadTableTransaction() || Tx.HasKqpTransaction(), "One of the fields should be set: MiniKQL, ReadTableTransaction, KqpTransaction"); if (Tx.GetLockTxId()) @@ -61,7 +61,7 @@ TValidatedDataTx::TValidatedDataTx(TDataShard *self, auto &tx = Tx.GetReadTableTransaction(); if (self->TableInfos.contains(tx.GetTableId().GetTableId())) { auto* info = self->TableInfos[tx.GetTableId().GetTableId()].Get(); - Y_ABORT_UNLESS(info, "Unexpected missing table info"); + Y_ENSURE(info, "Unexpected missing table info"); TSerializedTableRange range(tx.GetRange()); EngineBay.GetKeyValidator().AddReadRange(TTableId(tx.GetTableId().GetOwnerId(), tx.GetTableId().GetTableId()), @@ -179,7 +179,7 @@ TValidatedDataTx::TValidatedDataTx(TDataShard *self, return; } } else { - Y_ABORT_UNLESS(Tx.HasMiniKQL()); + Y_ENSURE(Tx.HasMiniKQL()); if (Tx.GetLlvmRuntime()) { LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Using LLVM runtime to execute transaction: " << StepTxId_.TxId); @@ -224,7 +224,7 @@ ui32 TValidatedDataTx::ExtractKeys(bool allowErrors) return 0; } } else { - Y_ABORT_UNLESS(result == EResult::Ok, "Engine errors: %s", EngineBay.GetEngine()->GetErrors().data()); + Y_ENSURE(result == EResult::Ok, "Engine errors: " << EngineBay.GetEngine()->GetErrors()); } return KeysCount(); } @@ -328,8 +328,8 @@ TActiveTransaction::~TActiveTransaction() void TActiveTransaction::FillTxData(TValidatedDataTx::TPtr dataTx) { - Y_ABORT_UNLESS(!DataTx); - Y_ABORT_UNLESS(TxBody.empty() || HasVolatilePrepareFlag()); + Y_ENSURE(!DataTx); + Y_ENSURE(TxBody.empty() || HasVolatilePrepareFlag()); Target = dataTx->GetSource(); DataTx = dataTx; @@ -348,8 +348,8 @@ void TActiveTransaction::FillTxData(TDataShard *self, { UntrackMemory(); - Y_ABORT_UNLESS(!DataTx); - Y_ABORT_UNLESS(TxBody.empty()); + Y_ENSURE(!DataTx); + Y_ENSURE(TxBody.empty()); Target = target; TxBody = txBody; @@ -359,9 +359,9 @@ void TActiveTransaction::FillTxData(TDataShard *self, } ArtifactFlags = artifactFlags; if (IsDataTx() || IsReadTable()) { - Y_ABORT_UNLESS(!DataTx); + Y_ENSURE(!DataTx); BuildDataTx(self, txc, ctx); - Y_ABORT_UNLESS(DataTx->Ready()); + Y_ENSURE(DataTx->Ready()); if (DataTx->HasStreamResponse()) SetStreamSink(DataTx->GetSink()); @@ -384,19 +384,19 @@ void TActiveTransaction::FillVolatileTxData(TDataShard *self, { UntrackMemory(); - Y_ABORT_UNLESS(!DataTx); - Y_ABORT_UNLESS(!TxBody.empty()); + Y_ENSURE(!DataTx); + Y_ENSURE(!TxBody.empty()); if (IsDataTx() || IsReadTable()) { BuildDataTx(self, txc, ctx); - Y_ABORT_UNLESS(DataTx->Ready()); + Y_ENSURE(DataTx->Ready()); if (DataTx->HasStreamResponse()) SetStreamSink(DataTx->GetSink()); } else if (IsSnapshotTx()) { BuildSnapshotTx(); } else { - Y_ABORT("Unexpected FillVolatileTxData call"); + Y_ENSURE(false, "Unexpected FillVolatileTxData call"); } TrackMemory(); @@ -406,9 +406,9 @@ TValidatedDataTx::TPtr TActiveTransaction::BuildDataTx(TDataShard *self, TTransactionContext &txc, const TActorContext &ctx) { - Y_ABORT_UNLESS(IsDataTx() || IsReadTable()); + Y_ENSURE(IsDataTx() || IsReadTable()); if (!DataTx) { - Y_ABORT_UNLESS(TxBody); + Y_ENSURE(TxBody); DataTx = std::make_shared<TValidatedDataTx>(self, txc, ctx, GetStepOrder(), GetReceivedAt(), TxBody, IsMvccSnapshotRead()); if (DataTx->HasStreamResponse()) @@ -419,7 +419,7 @@ TValidatedDataTx::TPtr TActiveTransaction::BuildDataTx(TDataShard *self, bool TActiveTransaction::BuildSchemeTx() { - Y_ABORT_UNLESS(TxBody); + Y_ENSURE(TxBody); SchemeTx.Reset(new NKikimrTxDataShard::TFlatSchemeTransaction); bool res = SchemeTx->ParseFromArray(TxBody.data(), TxBody.size()); if (!res) @@ -491,7 +491,7 @@ bool TActiveTransaction::BuildSchemeTx() bool TActiveTransaction::BuildSnapshotTx() { - Y_ABORT_UNLESS(TxBody); + Y_ENSURE(TxBody); SnapshotTx.Reset(new NKikimrTxDataShard::TSnapshotTransaction); if (!SnapshotTx->ParseFromArray(TxBody.data(), TxBody.size())) { return false; @@ -516,7 +516,7 @@ bool TDistributedEraseTx::TryParse(const TString& serialized) { } bool TActiveTransaction::BuildDistributedEraseTx() { - Y_ABORT_UNLESS(TxBody); + Y_ENSURE(TxBody); DistributedEraseTx.Reset(new TDistributedEraseTx); return DistributedEraseTx->TryParse(TxBody); } @@ -532,7 +532,7 @@ bool TCommitWritesTx::TryParse(const TString& serialized) { } bool TActiveTransaction::BuildCommitWritesTx() { - Y_ABORT_UNLESS(TxBody); + Y_ENSURE(TxBody); CommitWritesTx.Reset(new TCommitWritesTx); return CommitWritesTx->TryParse(TxBody); } @@ -636,7 +636,7 @@ ERestoreDataStatus TActiveTransaction::RestoreTxData( return ERestoreDataStatus::Restart; } } else { - Y_ABORT_UNLESS(TxBody); + Y_ENSURE(TxBody); } TrackMemory(); @@ -665,9 +665,9 @@ ERestoreDataStatus TActiveTransaction::RestoreTxData( void TActiveTransaction::FinalizeDataTxPlan() { - Y_ABORT_UNLESS(IsDataTx()); - Y_ABORT_UNLESS(!IsImmediate()); - Y_ABORT_UNLESS(!IsKqpScanTransaction()); + Y_ENSURE(IsDataTx()); + Y_ENSURE(!IsImmediate()); + Y_ENSURE(!IsKqpScanTransaction()); TVector<EExecutionUnitKind> plan; @@ -694,13 +694,13 @@ void TActiveTransaction::FinalizeDataTxPlan() void TActiveTransaction::BuildExecutionPlan(bool loaded) { - Y_ABORT_UNLESS(GetExecutionPlan().empty()); - Y_ABORT_UNLESS(!IsKqpScanTransaction()); + Y_ENSURE(GetExecutionPlan().empty()); + Y_ENSURE(!IsKqpScanTransaction()); TVector<EExecutionUnitKind> plan; if (IsDataTx()) { if (IsImmediate()) { - Y_ABORT_UNLESS(!loaded); + Y_ENSURE(!loaded); plan.push_back(EExecutionUnitKind::CheckDataTx); plan.push_back(EExecutionUnitKind::BuildAndWaitDependencies); if (IsKqpDataTransaction()) { @@ -711,16 +711,16 @@ void TActiveTransaction::BuildExecutionPlan(bool loaded) plan.push_back(EExecutionUnitKind::FinishPropose); plan.push_back(EExecutionUnitKind::CompletedOperations); } else if (HasVolatilePrepareFlag()) { - Y_ABORT_UNLESS(!loaded); + Y_ENSURE(!loaded); plan.push_back(EExecutionUnitKind::CheckDataTx); plan.push_back(EExecutionUnitKind::StoreDataTx); // note: stores in memory plan.push_back(EExecutionUnitKind::FinishPropose); - Y_ABORT_UNLESS(!GetStep()); + Y_ENSURE(!GetStep()); plan.push_back(EExecutionUnitKind::WaitForPlan); plan.push_back(EExecutionUnitKind::PlanQueue); plan.push_back(EExecutionUnitKind::LoadTxDetails); // note: reloads from memory plan.push_back(EExecutionUnitKind::BuildAndWaitDependencies); - Y_ABORT_UNLESS(IsKqpDataTransaction()); + Y_ENSURE(IsKqpDataTransaction()); // Note: execute will also prepare and send readsets plan.push_back(EExecutionUnitKind::ExecuteKqpDataTx); // Note: it is important that plan here is the same as regular @@ -809,7 +809,7 @@ void TActiveTransaction::BuildExecutionPlan(bool loaded) plan.push_back(EExecutionUnitKind::CompletedOperations); } else if (IsCommitWritesTx()) { if (IsImmediate()) { - Y_ABORT_UNLESS(!loaded); + Y_ENSURE(!loaded); plan.push_back(EExecutionUnitKind::CheckCommitWritesTx); plan.push_back(EExecutionUnitKind::BuildAndWaitDependencies); plan.push_back(EExecutionUnitKind::ExecuteCommitWritesTx); @@ -869,7 +869,7 @@ void TActiveTransaction::BuildExecutionPlan(bool loaded) plan.push_back(EExecutionUnitKind::CompleteOperation); plan.push_back(EExecutionUnitKind::CompletedOperations); } else { - Y_FAIL_S("unknown operation kind " << GetKind()); + Y_ENSURE(false, "unknown operation kind " << GetKind()); } RewriteExecutionPlan(plan); diff --git a/ydb/core/tx/datashard/datashard_active_transaction.h b/ydb/core/tx/datashard/datashard_active_transaction.h index d53b94cc0f..655c9e0b36 100644 --- a/ydb/core/tx/datashard/datashard_active_transaction.h +++ b/ydb/core/tx/datashard/datashard_active_transaction.h @@ -213,34 +213,34 @@ public: } bool GetUseGenericReadSets() const { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); return Tx.GetKqpTransaction().GetUseGenericReadSets(); } inline const ::NKikimrDataEvents::TKqpLocks& GetKqpLocks() const { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); return Tx.GetKqpTransaction().GetLocks(); } inline bool HasKqpLocks() const { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); return Tx.GetKqpTransaction().HasLocks(); } inline bool HasKqpSnapshot() const { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); return Tx.GetKqpTransaction().HasSnapshot(); } inline const ::NKikimrKqp::TKqpSnapshot& GetKqpSnapshot() const { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); return Tx.GetKqpTransaction().GetSnapshot(); } inline const ::google::protobuf::RepeatedPtrField<::NYql::NDqProto::TDqTask>& GetTasks() const { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); // ensure that GetTasks is not called after task runner is built - Y_ABORT_UNLESS(!BuiltTaskRunner); + Y_ENSURE(!BuiltTaskRunner); return Tx.GetKqpTransaction().GetTasks(); } @@ -254,17 +254,17 @@ public: } NKqp::TKqpTasksRunner& GetKqpTasksRunner() { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); BuiltTaskRunner = true; return EngineBay.GetKqpTasksRunner(*Tx.MutableKqpTransaction()); } ::NYql::NDqProto::EDqStatsMode GetKqpStatsMode() const { - Y_ABORT_UNLESS(IsKqpDataTx()); + Y_ENSURE(IsKqpDataTx()); return Tx.GetKqpTransaction().GetRuntimeSettings().GetStatsMode(); } - NMiniKQL::TKqpDatashardComputeContext& GetKqpComputeCtx() { Y_ABORT_UNLESS(IsKqpDataTx()); return EngineBay.GetKqpComputeCtx(); } + NMiniKQL::TKqpDatashardComputeContext& GetKqpComputeCtx() { Y_ENSURE(IsKqpDataTx()); return EngineBay.GetKqpComputeCtx(); } bool HasStreamResponse() const { return Tx.GetStreamResponse(); } TActorId GetSink() const { return ActorIdFromProto(Tx.GetSink()); } @@ -437,7 +437,7 @@ public: const NKikimrTxDataShard::TFlatSchemeTransaction &GetSchemeTx() const { - Y_VERIFY_S(SchemeTx, "No ptr"); + Y_ENSURE(SchemeTx, "No ptr"); return *SchemeTx; } bool BuildSchemeTx(); @@ -519,7 +519,7 @@ public: ui64 GetMemoryConsumption() const; ui64 GetRequiredMemory() const { - Y_ABORT_UNLESS(!GetTxCacheUsage() || !IsTxDataReleased()); + Y_ENSURE(!GetTxCacheUsage() || !IsTxDataReleased()); ui64 requiredMem = GetTxCacheUsage() + GetReleasedTxDataSize(); if (!requiredMem) requiredMem = GetMemoryConsumption(); @@ -545,7 +545,7 @@ public: const NMiniKQL::IEngineFlat::TValidationInfo &GetKeysInfo() const override { if (DataTx) { - Y_ABORT_UNLESS(DataTx->TxInfo().Loaded); + Y_ENSURE(DataTx->TxInfo().Loaded); return DataTx->TxInfo(); } Y_DEBUG_ABORT_UNLESS(IsSchemeTx() || IsSnapshotTx() || IsDistributedEraseTx() || IsCommitWritesTx(), diff --git a/ydb/core/tx/datashard/datashard_change_receiving.cpp b/ydb/core/tx/datashard/datashard_change_receiving.cpp index a1937880cf..a60b1755bb 100644 --- a/ydb/core/tx/datashard/datashard_change_receiving.cpp +++ b/ydb/core/tx/datashard/datashard_change_receiving.cpp @@ -44,7 +44,7 @@ public: const auto& [sender, req] = Self->PendingChangeExchangeHandshakes.front(); auto& [_, resp] = Statuses.emplace_back(sender, MakeHolder<TEvChangeExchange::TEvStatus>()); - Y_ABORT_UNLESS(ExecuteHandshake(db, req, resp->Record)); + Y_ENSURE(ExecuteHandshake(db, req, resp->Record)); Self->PendingChangeExchangeHandshakes.pop_front(); } @@ -137,7 +137,7 @@ class TDataShard::TTxApplyChangeRecords: public TTransactionBase<TDataShard> { case NKikimrChangeExchange::TDataChange::kReset: return record.GetReset(); default: - Y_FAIL_S("Unexpected row operation: " << static_cast<ui32>(record.GetRowOperationCase())); + Y_ENSURE(false, "Unexpected row operation: " << static_cast<ui32>(record.GetRowOperationCase())); } } @@ -406,7 +406,7 @@ public: } void Complete(const TActorContext& ctx) override { - Y_ABORT_UNLESS(Status); + Y_ENSURE(Status); if (MvccReadWriteVersion) { Pipeline.RemoveCommittingOp(*MvccReadWriteVersion); diff --git a/ydb/core/tx/datashard/datashard_change_sending.cpp b/ydb/core/tx/datashard/datashard_change_sending.cpp index aa1838362c..cb6a3922da 100644 --- a/ydb/core/tx/datashard/datashard_change_sending.cpp +++ b/ydb/core/tx/datashard/datashard_change_sending.cpp @@ -78,7 +78,7 @@ class TDataShard::TTxRequestChangeRecords: public TTransactionBase<TDataShard> { return NTable::EReady::Gone; } - Y_VERIFY_S(basic.IsValid() && details.IsValid(), "Inconsistent basic and details" + Y_ENSURE(basic.IsValid() && details.IsValid(), "Inconsistent basic and details" << ", basic.IsValid: " << basic.IsValid() << ", details.IsValid: " << details.IsValid() << ", order: " << order); @@ -115,13 +115,13 @@ class TDataShard::TTxRequestChangeRecords: public TTransactionBase<TDataShard> { .WithSource(source); if constexpr (HaveLock) { - Y_ABORT_UNLESS(commited); + Y_ENSURE(commited); builder .WithGroup(commited->Group) .WithStep(commited->Step) .WithTxId(commited->TxId); } else { - Y_ABORT_UNLESS(!commited); + Y_ENSURE(!commited); builder .WithGroup(basic.template GetValue<typename TBasicTable::Group>()) .WithStep(basic.template GetValue<typename TBasicTable::PlanStep>()) @@ -375,10 +375,10 @@ public: LOG_NOTICE_S(ctx, NKikimrServices::TX_DATASHARD, "TTxChangeExchangeSplitAck Execute" << ", at tablet# " << Self->TabletID()); - Y_ABORT_UNLESS(!Self->ChangesQueue); + Y_ENSURE(!Self->ChangesQueue); Self->ChangeExchangeSplitter.Ack(); - Y_ABORT_UNLESS(Self->ChangeExchangeSplitter.Done()); + Y_ENSURE(Self->ChangeExchangeSplitter.Done()); for (const auto dstTabletId : Self->ChangeSenderActivator.GetDstSet()) { if (Self->SplitSrcSnapshotSender.Acked(dstTabletId) && !Self->ChangeSenderActivator.Acked(dstTabletId)) { diff --git a/ydb/core/tx/datashard/datashard_common_upload.cpp b/ydb/core/tx/datashard/datashard_common_upload.cpp index 84933653af..c3b35762f0 100644 --- a/ydb/core/tx/datashard/datashard_common_upload.cpp +++ b/ydb/core/tx/datashard/datashard_common_upload.cpp @@ -36,8 +36,8 @@ bool TCommonUploadOps<TEvRequest, TEvResponse>::Execute(TDataShard* self, TTrans const ui64 shadowTableId = self->GetShadowTableId(fullTableId); const TUserTable& tableInfo = *self->GetUserTables().at(tableId); /// ... find - Y_ABORT_UNLESS(tableInfo.LocalTid == localTableId); - Y_ABORT_UNLESS(tableInfo.ShadowTid == shadowTableId); + Y_ENSURE(tableInfo.LocalTid == localTableId); + Y_ENSURE(tableInfo.ShadowTid == shadowTableId); // Check schemas if (record.GetRowScheme().KeyColumnIdsSize() != tableInfo.KeyColumnIds.size()) { @@ -221,7 +221,7 @@ bool TCommonUploadOps<TEvRequest, TEvResponse>::Execute(TDataShard* self, TTrans } if (ChangeCollector) { - Y_ABORT_UNLESS(CollectChanges); + Y_ENSURE(CollectChanges); if (!volatileDependencies.empty()) { if (!globalTxId) { @@ -297,7 +297,7 @@ bool TCommonUploadOps<TEvRequest, TEvResponse>::Execute(TDataShard* self, TTrans template <typename TEvRequest, typename TEvResponse> void TCommonUploadOps<TEvRequest, TEvResponse>::GetResult(TDataShard* self, TActorId& target, THolder<IEventBase>& event, ui64& cookie) { - Y_ABORT_UNLESS(Result); + Y_ENSURE(Result); if (Result->Record.GetStatus() == NKikimrTxDataShard::TError::OK) { self->IncCounter(COUNTER_BULK_UPSERT_SUCCESS); @@ -317,7 +317,7 @@ const TEvRequest* TCommonUploadOps<TEvRequest, TEvResponse>::GetRequest() const template <typename TEvRequest, typename TEvResponse> TEvResponse* TCommonUploadOps<TEvRequest, TEvResponse>::GetResult() { - Y_ABORT_UNLESS(Result); + Y_ENSURE(Result); return Result.Get(); } diff --git a/ydb/core/tx/datashard/datashard_dep_tracker.cpp b/ydb/core/tx/datashard/datashard_dep_tracker.cpp index 796650485a..9cd982c990 100644 --- a/ydb/core/tx/datashard/datashard_dep_tracker.cpp +++ b/ydb/core/tx/datashard/datashard_dep_tracker.cpp @@ -74,7 +74,7 @@ void TDependencyTracker::ClearTmpWrite() { void TDependencyTracker::AddPlannedReads(const TOperation::TPtr& op, const TKeys& reads) { for (const auto& read : reads) { auto it = Tables.find(read.TableId); - Y_ABORT_UNLESS(it != Tables.end()); + Y_ENSURE(it != Tables.end()); auto ownedRange = MakeOwnedRange(read.Key); it->second.PlannedReads.AddRange(std::move(ownedRange), op); } @@ -83,7 +83,7 @@ void TDependencyTracker::AddPlannedReads(const TOperation::TPtr& op, const TKeys void TDependencyTracker::AddPlannedWrites(const TOperation::TPtr& op, const TKeys& writes) { for (const auto& write : writes) { auto it = Tables.find(write.TableId); - Y_ABORT_UNLESS(it != Tables.end()); + Y_ENSURE(it != Tables.end()); auto ownedRange = MakeOwnedRange(write.Key); it->second.PlannedWrites.AddRange(std::move(ownedRange), op); } @@ -92,7 +92,7 @@ void TDependencyTracker::AddPlannedWrites(const TOperation::TPtr& op, const TKey void TDependencyTracker::AddImmediateReads(const TOperation::TPtr& op, const TKeys& reads) { for (const auto& read : reads) { auto it = Tables.find(read.TableId); - Y_ABORT_UNLESS(it != Tables.end()); + Y_ENSURE(it != Tables.end()); auto ownedRange = MakeOwnedRange(read.Key); it->second.ImmediateReads.AddRange(std::move(ownedRange), op); } @@ -101,7 +101,7 @@ void TDependencyTracker::AddImmediateReads(const TOperation::TPtr& op, const TKe void TDependencyTracker::AddImmediateWrites(const TOperation::TPtr& op, const TKeys& writes) { for (const auto& write : writes) { auto it = Tables.find(write.TableId); - Y_ABORT_UNLESS(it != Tables.end()); + Y_ENSURE(it != Tables.end()); auto ownedRange = MakeOwnedRange(write.Key); it->second.ImmediateWrites.AddRange(std::move(ownedRange), op); } @@ -215,7 +215,7 @@ void TDependencyTracker::TMvccDependencyTrackingLogic::AddOperation(const TOpera } } } else if (TSysTables::IsLocksTable(k.TableId)) { - Y_ABORT_UNLESS(k.Range.Point, "Unexpected non-point read from the locks table"); + Y_ENSURE(k.Range.Point, "Unexpected non-point read from the locks table"); const ui64 lockTxId = Parent.Self->SysLocksTable().ExtractLockTxId(k.Range.From); // Add hard dependency on all operations that worked with the same lock @@ -342,7 +342,7 @@ void TDependencyTracker::TMvccDependencyTrackingLogic::AddOperation(const TOpera // Locking writes are uncommitted, not externally visible and behave like reads if (isLocking) { - Y_ABORT_UNLESS(!haveWrites); + Y_ENSURE(!haveWrites); if (isGlobalWriter) { isGlobalWriter = false; isGlobalReader = true; @@ -358,7 +358,7 @@ void TDependencyTracker::TMvccDependencyTrackingLogic::AddOperation(const TOpera } auto onImmediateConflict = [&](TOperation& conflict) { - Y_ABORT_UNLESS(!conflict.IsImmediate()); + Y_ENSURE(!conflict.IsImmediate()); if (snapshot.IsMax()) { conflict.AddImmediateConflict(op); } else if (IsLess(conflict, snapshot)) { diff --git a/ydb/core/tx/datashard/datashard_direct_erase.cpp b/ydb/core/tx/datashard/datashard_direct_erase.cpp index 143589c8e3..88458bda53 100644 --- a/ydb/core/tx/datashard/datashard_direct_erase.cpp +++ b/ydb/core/tx/datashard/datashard_direct_erase.cpp @@ -31,7 +31,7 @@ TDirectTxErase::EStatus TDirectTxErase::CheckedExecute( } const TUserTable& tableInfo = *self->GetUserTables().at(tableId); - Y_ABORT_UNLESS(tableInfo.LocalTid == localTableId); + Y_ENSURE(tableInfo.LocalTid == localTableId); if (request.GetSchemaVersion() && tableInfo.GetTableSchemaVersion() && request.GetSchemaVersion() != tableInfo.GetTableSchemaVersion()) { @@ -226,7 +226,7 @@ bool TDirectTxErase::CheckRequest(TDataShard* self, const NKikimrTxDataShard::TE case EStatus::Error: return false; case EStatus::PageFault: - Y_ABORT("Unexpected"); + Y_ENSURE(false, "Unexpected"); } } @@ -265,7 +265,7 @@ bool TDirectTxErase::Execute(TDataShard* self, TTransactionContext& txc, } TDirectTxResult TDirectTxErase::GetResult(TDataShard* self) { - Y_ABORT_UNLESS(Result); + Y_ENSURE(Result); if (Result->Record.GetStatus() == NKikimrTxDataShard::TEvEraseRowsResponse::OK) { self->IncCounter(COUNTER_ERASE_ROWS_SUCCESS); diff --git a/ydb/core/tx/datashard/datashard_direct_erase.h b/ydb/core/tx/datashard/datashard_direct_erase.h index 583834287f..cd2f566a6f 100644 --- a/ydb/core/tx/datashard/datashard_direct_erase.h +++ b/ydb/core/tx/datashard/datashard_direct_erase.h @@ -50,7 +50,7 @@ class TDirectTxErase : public IDirectTx { explicit operator bool() const { if (!Tx || !Txc) { - Y_ABORT_UNLESS(!Tx && !Txc); + Y_ENSURE(!Tx && !Txc); return false; } diff --git a/ydb/core/tx/datashard/datashard_direct_transaction.cpp b/ydb/core/tx/datashard/datashard_direct_transaction.cpp index d4c5f6d231..df604b7caf 100644 --- a/ydb/core/tx/datashard/datashard_direct_transaction.cpp +++ b/ydb/core/tx/datashard/datashard_direct_transaction.cpp @@ -19,8 +19,8 @@ TDirectTransaction::TDirectTransaction(TInstant receivedAt, ui64 tieBreakerIndex void TDirectTransaction::BuildExecutionPlan(bool loaded) { - Y_ABORT_UNLESS(GetExecutionPlan().empty()); - Y_ABORT_UNLESS(!loaded); + Y_ENSURE(GetExecutionPlan().empty()); + Y_ENSURE(!loaded); TVector<EExecutionUnitKind> plan; plan.push_back(EExecutionUnitKind::BuildAndWaitDependencies); @@ -40,7 +40,7 @@ bool TDirectTransaction::Execute(TDataShard* self, TTransactionContext& txc) { for (ui64 txId : volatileReadDependencies) { AddVolatileDependency(txId); bool ok = self->GetVolatileTxManager().AttachBlockedOperation(txId, GetTxId()); - Y_VERIFY_S(ok, "Unexpected failure to attach " << *static_cast<TOperation*>(this) << " to volatile tx " << txId); + Y_ENSURE(ok, "Unexpected failure to attach " << *static_cast<TOperation*>(this) << " to volatile tx " << txId); } } return false; diff --git a/ydb/core/tx/datashard/datashard_distributed_erase.cpp b/ydb/core/tx/datashard/datashard_distributed_erase.cpp index 6a53f7f020..1f8708d9a4 100644 --- a/ydb/core/tx/datashard/datashard_distributed_erase.cpp +++ b/ydb/core/tx/datashard/datashard_distributed_erase.cpp @@ -270,8 +270,8 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { } static ui64 GetShardId(const TTableRange& range, const TKeyDesc* keyDesc) { - Y_ABORT_UNLESS(range.Point); - Y_ABORT_UNLESS(!keyDesc->GetPartitions().empty()); + Y_ENSURE(range.Point); + Y_ENSURE(!keyDesc->GetPartitions().empty()); TVector<TKeyDesc::TPartitionInfo>::const_iterator it = LowerBound( keyDesc->GetPartitions().begin(), keyDesc->GetPartitions().end(), true, @@ -286,7 +286,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { } ); - Y_ABORT_UNLESS(it != keyDesc->GetPartitions().end()); + Y_ENSURE(it != keyDesc->GetPartitions().end()); return it->ShardId; } @@ -479,7 +479,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { } } - Y_ABORT_UNLESS(TxId); + Y_ENSURE(TxId); SelectedCoordinator = domainInfo->Coordinators.Select(TxId); ResolveKeys(); @@ -491,7 +491,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { LOG_D("Resolve keys" << ": txId# " << TxId); - Y_ABORT_UNLESS(!TableInfos.empty()); + Y_ENSURE(!TableInfos.empty()); auto request = MakeHolder<TResolve>(); for (auto& [_, info] : TableInfos) { @@ -592,7 +592,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { TVector<ui32> indexColumnIds; { - Y_ABORT_UNLESS(TableInfos.contains(MainTableId)); + Y_ENSURE(TableInfos.contains(MainTableId)); const auto& mainTableInfo = TableInfos.at(MainTableId); THashSet<ui32> mainTableKeys; @@ -648,7 +648,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { TVector<TCell> indexCells(Reserve(indexColumnIds.size())); for (const auto& id : indexColumnIds) { - Y_ABORT_UNLESS(keyColumnIdToIdx.contains(id)); + Y_ENSURE(keyColumnIdToIdx.contains(id)); indexCells.push_back(keyCells.GetCells()[keyColumnIdToIdx.at(id)]); } @@ -656,7 +656,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { } } - Y_ABORT_UNLESS(keys.contains(MainTableId)); + Y_ENSURE(keys.contains(MainTableId)); if (keys.at(MainTableId).size() > 1) { return ExecError(TStringBuilder() << "Too many main table's shards" << ": tableId# " << MainTableId @@ -680,7 +680,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { }; for (auto& [tableId, data] : keys) { - Y_ABORT_UNLESS(TableInfos.contains(tableId)); + Y_ENSURE(TableInfos.contains(tableId)); const auto& keyMap = TableInfos.at(tableId).GetKeyMap(); for (auto& kv : data) { @@ -697,7 +697,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { request.AddKeyColumnIds(id); } - Y_VERIFY_S(shardKeys.GetKeys().size() == shardKeys.GetPresentRows().Count(), "Rows count mismatch" + Y_ENSURE(shardKeys.GetKeys().size() == shardKeys.GetPresentRows().Count(), "Rows count mismatch" << ": expected# " << shardKeys.GetKeys().size() << ", actual# " << shardKeys.GetPresentRows().Count()); @@ -710,7 +710,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { request.MutableExpiration()->CopyFrom(record.GetExpiration()); break; default: - Y_FAIL_S("Unknown condition: " << static_cast<ui32>(record.GetConditionCase())); + Y_ENSURE(false, "Unknown condition: " << static_cast<ui32>(record.GetConditionCase())); } if (tableId == MainTableId) { @@ -727,7 +727,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { tx.AddIndexColumns(std::move(value)); } } else { - Y_ABORT_UNLESS(keys.contains(MainTableId)); + Y_ENSURE(keys.contains(MainTableId)); auto& dependency = *tx.AddDependencies(); dependency.SetShardId(keys.at(MainTableId).begin()->first); @@ -893,7 +893,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { /// Plan void RegisterPlan() { - Y_ABORT_UNLESS(SelectedCoordinator); + Y_ENSURE(SelectedCoordinator); LOG_D("Register plan" << ": txId# " << TxId diff --git a/ydb/core/tx/datashard/datashard_impl.h b/ydb/core/tx/datashard/datashard_impl.h index c0d4b61c19..ff0d851b29 100644 --- a/ydb/core/tx/datashard/datashard_impl.h +++ b/ydb/core/tx/datashard/datashard_impl.h @@ -1210,7 +1210,7 @@ class TDataShard return false; if (rowset.IsValid()) { ui64 val = rowset.GetValue<Schema::Sys::Uint64>(); - Y_ABORT_UNLESS(val <= std::numeric_limits<ui32>::max()); + Y_ENSURE(val <= std::numeric_limits<ui32>::max()); value = static_cast<ui32>(val); } return true; @@ -1222,7 +1222,7 @@ class TDataShard return false; if (rowset.IsValid()) { ui64 val = rowset.GetValue<Schema::Sys::Uint64>(); - Y_ABORT_UNLESS(val <= 1, "Unexpected bool value %" PRIu64, val); + Y_ENSURE(val <= 1, "Unexpected bool value " << val); value = (val != 0); } return true; @@ -1632,7 +1632,7 @@ public: } bool CanDrop() const { - Y_ABORT_UNLESS(State != TShardState::Offline, "Unexpexted repeated drop"); + Y_ENSURE(State != TShardState::Offline, "Unexpexted repeated drop"); // FIXME: why are we waiting for OutReadSets.Empty()? return (TxInFly() == 1) && OutReadSets.Empty() && (State != TShardState::PreOffline); } @@ -1691,13 +1691,13 @@ public: const THashMap<ui64, TUserTable::TCPtr> &GetUserTables() const { return TableInfos; } ui64 GetLocalTableId(const TTableId& tableId) const { - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); auto it = TableInfos.find(tableId.PathId.LocalPathId); return it == TableInfos.end() ? 0 : it->second->LocalTid; } ui64 GetShadowTableId(const TTableId& tableId) const { - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); auto it = TableInfos.find(tableId.PathId.LocalPathId); return it == TableInfos.end() ? 0 : it->second->ShadowTid; } @@ -2172,7 +2172,7 @@ public: }; TTrivialLogThrottler& GetLogThrottler(ELogThrottlerType type) { - Y_ABORT_UNLESS(type != ELogThrottlerType::LAST); + Y_ENSURE(type != ELogThrottlerType::LAST); return LogThrottlers[type]; }; @@ -2220,7 +2220,7 @@ private: for (const auto& partMeta : partMetaVec) { auto it = LoanOwners.find(partMeta); if (it != LoanOwners.end()) { - Y_ABORT_UNLESS(it->second == ownerTabletId, + Y_ENSURE(it->second == ownerTabletId, "Part is already registered with a different owner"); } else { LoanOwners[partMeta] = ownerTabletId; @@ -2305,12 +2305,12 @@ private: } void SaveSnapshotForSending(ui64 dstTabletId, TAutoPtr<NKikimrTxDataShard::TEvSplitTransferSnapshot> snapshot) { - Y_ABORT_UNLESS(Dst.contains(dstTabletId)); + Y_ENSURE(Dst.contains(dstTabletId)); DataToSend[dstTabletId] = snapshot; } void DoSend(const TActorContext &ctx) { - Y_ABORT_UNLESS(Dst.size() == DataToSend.size()); + Y_ENSURE(Dst.size() == DataToSend.size()); for (const auto& ds : DataToSend) { ui64 dstTablet = ds.first; DoSend(dstTablet, ctx); @@ -2318,7 +2318,7 @@ private: } void DoSend(ui64 dstTabletId, const TActorContext &ctx) { - Y_ABORT_UNLESS(Dst.contains(dstTabletId)); + Y_ENSURE(Dst.contains(dstTabletId)); NTabletPipe::TClientConfig clientConfig; PipesToDstShards[dstTabletId] = ctx.Register(NTabletPipe::CreateClient(ctx.SelfID, dstTabletId, clientConfig)); @@ -2399,7 +2399,7 @@ private: } void DoSend(ui64 dstTabletId, const TActorContext& ctx) { - Y_ABORT_UNLESS(Dst.contains(dstTabletId)); + Y_ENSURE(Dst.contains(dstTabletId)); NTabletPipe::TClientConfig clientConfig; clientConfig.CheckAliveness = true; clientConfig.RetryPolicy = PipeRetryPolicy; @@ -2484,7 +2484,7 @@ private: } void DoSplit(const TActorContext& ctx) { - Y_ABORT_UNLESS(DstTabletIds); + Y_ENSURE(DstTabletIds); Worker = ctx.Register(CreateChangeExchangeSplit(Self, TVector<ui64>(DstTabletIds.begin(), DstTabletIds.end()))); Acked = false; } @@ -2597,8 +2597,8 @@ private: const ui64 txId = NEvWrite::TConvertor::GetTxId(first->Event); auto it = TxIds.find(txId); - Y_ABORT_UNLESS(it != TxIds.end() && it->second.First == first, - "Consistency check: proposed txId %" PRIu64 " in deque, but not in hashmap", txId); + Y_ENSURE(it != TxIds.end() && it->second.First == first, + "Consistency check: proposed txId " << txId << " in deque, but not in hashmap"); // N.B. there should almost always be exactly one propose per txId it->second.First = first->Next; @@ -3292,8 +3292,8 @@ protected: void Die(const TActorContext &ctx) override; void SendViaSchemeshardPipe(const TActorContext &ctx, ui64 tabletId, THolder<TEvDataShard::TEvSchemaChanged> event) { - Y_ABORT_UNLESS(tabletId); - Y_ABORT_UNLESS(CurrentSchemeShardId == tabletId); + Y_ENSURE(tabletId); + Y_ENSURE(CurrentSchemeShardId == tabletId); if (!SchemeShardPipe) { NTabletPipe::TClientConfig clientConfig; @@ -3305,8 +3305,8 @@ protected: void ReportState(const TActorContext &ctx, ui32 state) { LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " Reporting state " << DatashardStateName(State) << " to schemeshard " << CurrentSchemeShardId); - Y_ABORT_UNLESS(state != TShardState::Offline || !HasSharedBlobs(), - "Datashard %" PRIu64 " tried to go offline while having shared blobs", TabletID()); + Y_ENSURE(state != TShardState::Offline || !HasSharedBlobs(), + "Datashard " << TabletID() << " tried to go offline while having shared blobs"); if (!StateReportPipe) { NTabletPipe::TClientConfig clientConfig; clientConfig.RetryPolicy = SchemeShardPipeRetryPolicy; diff --git a/ydb/core/tx/datashard/datashard_kqp.cpp b/ydb/core/tx/datashard/datashard_kqp.cpp index 887fbf5174..aac5907eb0 100644 --- a/ydb/core/tx/datashard/datashard_kqp.cpp +++ b/ydb/core/tx/datashard/datashard_kqp.cpp @@ -121,11 +121,11 @@ NDq::ERunStatus RunKqpTransactionInternal(const TActorContext& ctx, ui64 txId, c if (useGenericReadSets) { NKikimrTx::TReadSetData genericData; bool ok = genericData.ParseFromString(data.Body); - Y_ABORT_UNLESS(ok, "Failed to parse generic readset data from %" PRIu64 " to %" PRIu64 " origin %" PRIu64, source, target, data.Origin); + Y_ENSURE(ok, "Failed to parse generic readset data from " << source << " to " << target << " origin " << data.Origin); if (genericData.HasData()) { ok = genericData.GetData().UnpackTo(&kqpReadset); - Y_ABORT_UNLESS(ok, "Failed to parse kqp readset data from %" PRIu64 " to %" PRIu64 " origin %" PRIu64, source, target, data.Origin); + Y_ENSURE(ok, "Failed to parse kqp readset data from " << source << " to " << target << " origin " << data.Origin); } } else { Y_PROTOBUF_SUPPRESS_NODISCARD kqpReadset.ParseFromString(data.Body); @@ -339,9 +339,9 @@ template <bool Read> void KqpSetTxKeysImpl(ui64 tabletId, ui64 taskId, const TTableId& tableId, const TUserTable* tableInfo, const NKikimrTxDataShard::TKqpTransaction_TDataTaskMeta_TKeyRange& rangeKind, const TReadOpMeta* readMeta, const TWriteOpMeta* writeMeta, const NScheme::TTypeRegistry& typeRegistry, const TActorContext& ctx, TKeyValidator& keyValidator) { if (Read) { - Y_ABORT_UNLESS(readMeta); + Y_ENSURE(readMeta); } else { - Y_ABORT_UNLESS(writeMeta); + Y_ENSURE(writeMeta); } switch (rangeKind.Kind_case()) { @@ -610,7 +610,7 @@ void KqpFillOutReadSets(TOutputOpData::TOutReadSets& outReadSets, const NKikimrD if (useGenericReadSets) { for (const auto& [key, data] : readsetData) { bool ok = genericData[key].MutableData()->PackFrom(data); - Y_ABORT_UNLESS(ok, "Failed to pack readset data from %" PRIu64 " to %" PRIu64, key.first, key.second); + Y_ENSURE(ok, "Failed to pack readset data from " << key.first << " to " << key.second); } for (auto& [key, data] : genericData) { @@ -620,7 +620,7 @@ void KqpFillOutReadSets(TOutputOpData::TOutReadSets& outReadSets, const NKikimrD TString bodyStr; bool ok = data.SerializeToString(&bodyStr); - Y_ABORT_UNLESS(ok, "Failed to serialize readset from %" PRIu64 " to %" PRIu64, key.first, key.second); + Y_ENSURE(ok, "Failed to serialize readset from " << key.first << " to " << key.second); outReadSets[key] = std::move(bodyStr); } @@ -655,7 +655,7 @@ std::tuple<bool, TVector<NKikimrDataEvents::TLock>> KqpValidateLocks(ui64 origin if (useGenericReadSets) { NKikimrTx::TReadSetData genericData; bool ok = genericData.ParseFromString(data.Body); - Y_ABORT_UNLESS(ok, "Failed to parse generic readset from %" PRIu64 " to %" PRIu64 " tabletId %" PRIu64, readSet.first.first, readSet.first.second, data.Origin); + Y_ENSURE(ok, "Failed to parse generic readset from " << readSet.first.first << " to " << readSet.first.second << " tabletId " << data.Origin); if (genericData.GetDecision() != NKikimrTx::TReadSetData::DECISION_COMMIT) { // Note: we don't know details on what failed at that shard @@ -699,8 +699,8 @@ std::tuple<bool, TVector<NKikimrDataEvents::TLock>> KqpValidateVolatileTx(ui64 o // We may have some stale data since before the restart // We expect all stale data to be cleared on restarts - Y_ABORT_UNLESS(outReadSets.empty()); - Y_ABORT_UNLESS(awaitingDecisions.empty()); + Y_ENSURE(outReadSets.empty()); + Y_ENSURE(awaitingDecisions.empty()); const bool hasArbiter = KqpLocksHasArbiter(kqpLocks); const bool isArbiter = KqpLocksIsArbiter(origin, kqpLocks); @@ -736,12 +736,12 @@ std::tuple<bool, TVector<NKikimrDataEvents::TLock>> KqpValidateVolatileTx(ui64 o TString bodyStr; bool ok = data.SerializeToString(&bodyStr); - Y_ABORT_UNLESS(ok, "Failed to serialize readset from %" PRIu64 " to %" PRIu64, key.first, key.second); + Y_ENSURE(ok, "Failed to serialize readset from " << key.first << " to " << key.second); outReadSets[key] = std::move(bodyStr); } } else { - Y_ABORT_UNLESS(!isArbiter, "Arbiter is not in the sending shards set"); + Y_ENSURE(!isArbiter, "Arbiter is not in the sending shards set"); } bool receiveLocks = ReceiveLocks(*kqpLocks, origin); @@ -778,7 +778,7 @@ std::tuple<bool, TVector<NKikimrDataEvents::TLock>> KqpValidateVolatileTx(ui64 o } if (record.GetFlags() & NKikimrTx::TEvReadSet::FLAG_NO_DATA) { - Y_ABORT_UNLESS(!(record.GetFlags() & NKikimrTx::TEvReadSet::FLAG_EXPECT_READSET), "Unexpected FLAG_EXPECT_READSET + FLAG_NO_DATA in delayed readsets"); + Y_ENSURE(!(record.GetFlags() & NKikimrTx::TEvReadSet::FLAG_EXPECT_READSET), "Unexpected FLAG_EXPECT_READSET + FLAG_NO_DATA in delayed readsets"); // No readset data: participant aborted the transaction LOG_TRACE_S(*TlsActivationContext, NKikimrServices::TX_DATASHARD, "Processed readset without data from" << srcTabletId << " to " << dstTabletId << " will abort txId# " << txId); @@ -788,7 +788,7 @@ std::tuple<bool, TVector<NKikimrDataEvents::TLock>> KqpValidateVolatileTx(ui64 o NKikimrTx::TReadSetData data; bool ok = data.ParseFromString(record.GetReadSet()); - Y_ABORT_UNLESS(ok, "Failed to parse readset from %" PRIu64 " to %" PRIu64, srcTabletId, dstTabletId); + Y_ENSURE(ok, "Failed to parse readset from " << srcTabletId << " to " << dstTabletId); if (data.GetDecision() != NKikimrTx::TReadSetData::DECISION_COMMIT) { // Explicit decision that is not a commit, need to abort @@ -805,7 +805,7 @@ std::tuple<bool, TVector<NKikimrDataEvents::TLock>> KqpValidateVolatileTx(ui64 o return {false, {}}; } } else { - Y_ABORT_UNLESS(!isArbiter, "Arbiter is not in the receiving shards set"); + Y_ENSURE(!isArbiter, "Arbiter is not in the receiving shards set"); } return {true, {}}; @@ -911,7 +911,7 @@ void KqpFillTxStats(TDataShard& dataShard, const NMiniKQL::TEngineHostCounters& { auto& perTable = *stats.AddTableAccessStats(); perTable.MutableTableInfo()->SetSchemeshardId(dataShard.GetPathOwnerId()); - Y_ABORT_UNLESS(dataShard.GetUserTables().size() == 1, "TODO: Fix handling of collocated tables"); + Y_ENSURE(dataShard.GetUserTables().size() == 1, "TODO: Fix handling of collocated tables"); auto tableInfo = dataShard.GetUserTables().begin(); perTable.MutableTableInfo()->SetPathId(tableInfo->first); perTable.MutableTableInfo()->SetName(tableInfo->second->Path); @@ -939,7 +939,7 @@ void KqpFillTxStats(TDataShard& dataShard, const NMiniKQL::TEngineHostCounters& void KqpFillStats(TDataShard& dataShard, const NKqp::TKqpTasksRunner& tasksRunner, NMiniKQL::TKqpDatashardComputeContext& computeCtx, const NYql::NDqProto::EDqStatsMode& statsMode, TEvDataShard::TEvProposeTransactionResult& result) { - Y_ABORT_UNLESS(dataShard.GetUserTables().size() == 1, "TODO: Fix handling of collocated tables"); + Y_ENSURE(dataShard.GetUserTables().size() == 1, "TODO: Fix handling of collocated tables"); auto tableInfo = dataShard.GetUserTables().begin(); auto& computeActorStats = *result.Record.MutableComputeActorStats(); diff --git a/ydb/core/tx/datashard/datashard_kqp_compute.cpp b/ydb/core/tx/datashard/datashard_kqp_compute.cpp index 788e3b4fe1..ed5efbdb38 100644 --- a/ydb/core/tx/datashard/datashard_kqp_compute.cpp +++ b/ydb/core/tx/datashard/datashard_kqp_compute.cpp @@ -177,7 +177,7 @@ void TKqpDatashardComputeContext::SetReadVersion(TRowVersion readVersion) { } TRowVersion TKqpDatashardComputeContext::GetReadVersion() const { - Y_ABORT_UNLESS(!UserDb.GetReadVersion().IsMin(), "Cannot perform reads without ReadVersion set"); + Y_ENSURE(!UserDb.GetReadVersion().IsMin(), "Cannot perform reads without ReadVersion set"); return UserDb.GetReadVersion(); } @@ -253,7 +253,7 @@ bool TKqpDatashardComputeContext::PinPages(const TVector<IEngineFlat::TValidated } ui64 localTid = GetLocalTableId(key.TableId); - Y_ABORT_UNLESS(localTid, "table not exist"); + Y_ENSURE(localTid, "table not exist"); auto* tableInfo = scheme.GetTableInfo(localTid); TSmallVec<TRawTypeValue> from; diff --git a/ydb/core/tx/datashard/datashard_kqp_delete_rows.cpp b/ydb/core/tx/datashard/datashard_kqp_delete_rows.cpp index b5a4ec1146..54d1fac765 100644 --- a/ydb/core/tx/datashard/datashard_kqp_delete_rows.cpp +++ b/ydb/core/tx/datashard/datashard_kqp_delete_rows.cpp @@ -47,8 +47,8 @@ public: if (!engineCtx.Host->IsMyKey(Owner.TableId, keyTuple)) { return; } - Y_ABORT_UNLESS(engineCtx.ShardTableStats); - Y_ABORT_UNLESS(engineCtx.TaskTableStats); + Y_ENSURE(engineCtx.ShardTableStats); + Y_ENSURE(engineCtx.TaskTableStats); ui64 nEraseRow = engineCtx.ShardTableStats->NEraseRow; diff --git a/ydb/core/tx/datashard/datashard_kqp_read_table.cpp b/ydb/core/tx/datashard/datashard_kqp_read_table.cpp index 2e536bb358..91463f8c7b 100644 --- a/ydb/core/tx/datashard/datashard_kqp_read_table.cpp +++ b/ydb/core/tx/datashard/datashard_kqp_read_table.cpp @@ -193,7 +193,7 @@ public: #ifndef MKQL_DISABLE_CODEGEN ICodegeneratorInlineWideNode::TGenerateResult DoGenGetValues(const TCodegenContext& ctx, BasicBlock*& block) const { Y_UNUSED(ctx, block); - Y_ABORT("LLVM compilation is not implemented for OLTP-workload"); + Y_ENSURE(false, "LLVM compilation is not implemented for OLTP-workload"); } #endif diff --git a/ydb/core/tx/datashard/datashard_kqp_upsert_rows.cpp b/ydb/core/tx/datashard/datashard_kqp_upsert_rows.cpp index 1d6766d189..ee618526ee 100644 --- a/ydb/core/tx/datashard/datashard_kqp_upsert_rows.cpp +++ b/ydb/core/tx/datashard/datashard_kqp_upsert_rows.cpp @@ -88,8 +88,8 @@ public: commands.emplace_back(std::move(command)); } - Y_ABORT_UNLESS(dsApplyCtx.ShardTableStats); - Y_ABORT_UNLESS(dsApplyCtx.TaskTableStats); + Y_ENSURE(dsApplyCtx.ShardTableStats); + Y_ENSURE(dsApplyCtx.TaskTableStats); ui64 nUpdateRow = dsApplyCtx.ShardTableStats->NUpdateRow; ui64 updateRowBytes = dsApplyCtx.ShardTableStats->UpdateRowBytes; diff --git a/ydb/core/tx/datashard/datashard_loans.cpp b/ydb/core/tx/datashard/datashard_loans.cpp index e1b982b23f..aa51dd39c4 100644 --- a/ydb/core/tx/datashard/datashard_loans.cpp +++ b/ydb/core/tx/datashard/datashard_loans.cpp @@ -51,7 +51,7 @@ NTabletFlatExecutor::ITransaction* TDataShard::CreateTxInitiateBorrowedPartsRetu void TDataShard::CompletedLoansChanged(const TActorContext &ctx) { LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " CompletedLoansChanged"); - Y_ABORT_UNLESS(Executor()->GetStats().CompactedPartLoans); + Y_ENSURE(Executor()->GetStats().CompactedPartLoans); CheckInitiateBorrowedPartsReturn(ctx); } @@ -144,7 +144,7 @@ void TDataShard::Handle(TEvDataShard::TEvReturnBorrowedPartAck::TPtr& ev, const bool TDataShard::HasSharedBlobs() const { const bool* hasSharedBlobsPtr = Executor()->GetStats().HasSharedBlobs; if (!hasSharedBlobsPtr) { - Y_ABORT_UNLESS(IsFollower()); + Y_ENSURE(IsFollower()); return false; } return *hasSharedBlobsPtr; @@ -166,12 +166,12 @@ public: if (Self->State == TShardState::Offline) return true; - Y_ABORT_UNLESS(Self->State == TShardState::PreOffline, "Unexpected state %s tabletId %" PRIu64, - DatashardStateName(Self->State).data(), Self->TabletID()); - Y_ABORT_UNLESS(!Self->HasSharedBlobs(), "Cannot go offline while there are shared blobs at tablet %" PRIu64, Self->TabletID()); - Y_ABORT_UNLESS(!Self->TransQueue.TxInFly(), "Cannot go offline while there is a Tx in flight at tablet %" PRIu64, Self->TabletID()); - Y_ABORT_UNLESS(Self->OutReadSets.Empty(), "Cannot go offline while there is a non-Ack-ed readset at tablet %" PRIu64, Self->TabletID()); - Y_ABORT_UNLESS(Self->TransQueue.GetSchemaOperations().empty(), "Cannot go offline while there is a schema Tx in flight at tablet %" PRIu64, Self->TabletID()); + Y_ENSURE(Self->State == TShardState::PreOffline, "Unexpected state " << DatashardStateName(Self->State) + << " tabletId " << Self->TabletID()); + Y_ENSURE(!Self->HasSharedBlobs(), "Cannot go offline while there are shared blobs at tablet " << Self->TabletID()); + Y_ENSURE(!Self->TransQueue.TxInFly(), "Cannot go offline while there is a Tx in flight at tablet " << Self->TabletID()); + Y_ENSURE(Self->OutReadSets.Empty(), "Cannot go offline while there is a non-Ack-ed readset at tablet " << Self->TabletID()); + Y_ENSURE(Self->TransQueue.GetSchemaOperations().empty(), "Cannot go offline while there is a schema Tx in flight at tablet " << Self->TabletID()); LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() << " Initiating switch from " << DatashardStateName(Self->State) << " to Offline state"); @@ -226,7 +226,7 @@ void TDataShard::CheckStateChange(const TActorContext& ctx) { const bool mustActivateOthers = !ChangeSenderActivator.AllAcked(); if (!hasSharedBlobs && !hasSchemaOps && !hasOutRs && !hasChangeRecords && !mustActivateOthers) { - Y_ABORT_UNLESS(!TxInFly()); + Y_ENSURE(!TxInFly()); Execute(new TTxGoOffline(this), ctx); } } diff --git a/ydb/core/tx/datashard/datashard_outreadset.cpp b/ydb/core/tx/datashard/datashard_outreadset.cpp index d19885027b..70ea233133 100644 --- a/ydb/core/tx/datashard/datashard_outreadset.cpp +++ b/ydb/core/tx/datashard/datashard_outreadset.cpp @@ -47,8 +47,8 @@ bool TOutReadSets::LoadReadSets(NIceDb::TNiceDb& db) { // Cache it regardless of size, since we're going to send it soon rsInfo.Body = std::move(body); - Y_ABORT_UNLESS(!CurrentReadSets.contains(seqNo)); - Y_ABORT_UNLESS(!CurrentReadSetKeys.contains(rsInfo)); + Y_ENSURE(!CurrentReadSets.contains(seqNo)); + Y_ENSURE(!CurrentReadSetKeys.contains(rsInfo)); CurrentReadSetKeys[rsInfo] = seqNo; CurrentReadSets[seqNo] = std::move(rsInfo); @@ -64,8 +64,8 @@ bool TOutReadSets::LoadReadSets(NIceDb::TNiceDb& db) { void TOutReadSets::SaveReadSet(NIceDb::TNiceDb& db, ui64 seqNo, ui64 step, const TReadSetKey& rsKey, const TString& body) { using Schema = TDataShard::Schema; - Y_ABORT_UNLESS(!CurrentReadSets.contains(seqNo)); - Y_ABORT_UNLESS(!CurrentReadSetKeys.contains(rsKey)); + Y_ENSURE(!CurrentReadSets.contains(seqNo)); + Y_ENSURE(!CurrentReadSetKeys.contains(rsKey)); TReadSetInfo rsInfo(rsKey); rsInfo.Step = step; @@ -153,7 +153,7 @@ void TOutReadSets::SaveAck(const TActorContext &ctx, TAutoPtr<TEvTxProcessing::T if (CurrentReadSets.contains(seqno)) { TReadSetKey rsKey(txId, Self->TabletID(), sender, dest); - Y_ABORT_UNLESS(CurrentReadSetKeys[rsKey] == seqno); + Y_ENSURE(CurrentReadSetKeys[rsKey] == seqno); CurrentReadSetKeys.erase(rsKey); CurrentReadSets.erase(seqno); diff --git a/ydb/core/tx/datashard/datashard_pipeline.cpp b/ydb/core/tx/datashard/datashard_pipeline.cpp index 7dc0d1b774..99854e3ee2 100644 --- a/ydb/core/tx/datashard/datashard_pipeline.cpp +++ b/ydb/core/tx/datashard/datashard_pipeline.cpp @@ -73,7 +73,7 @@ void TPipeline::Reset() { bool TPipeline::Load(NIceDb::TNiceDb& db) { using Schema = TDataShard::Schema; - Y_ABORT_UNLESS(!SchemaTx); + Y_ENSURE(!SchemaTx); bool ready = true; ready &= Self->SysGetUi64(db, Schema::Sys_LastPlannedStep, LastPlannedTx.Step); @@ -184,9 +184,8 @@ ECleanupStatus TPipeline::Cleanup(NIceDb::TNiceDb& db, const TActorContext& ctx, << Self->TabletID()); ui64 lastStep = LastPlannedTx.Step; - Y_ABORT_UNLESS(lastStep >= step, - "TX [%" PRIu64 ":%" PRIu64 "] is unknown while LastPlannedStep is %" PRIu64 " at tablet %" PRIu64, - step, txId, lastStep, Self->TabletID()); + Y_ENSURE(lastStep >= step, + "TX [" << step << ":" << txId << "] is unknown while LastPlannedStep is " << lastStep << " at tablet " << Self->TabletID()); Self->TransQueue.ForgetPlannedTx(db, step, txId); db.NoMoreReadsForTx(); @@ -352,7 +351,7 @@ TOperation::TPtr TPipeline::GetNextActiveOp(bool dryRun) // mode just fail. for (auto &pr : ActiveOps) { const TOperation::TPtr &op = pr.second; - Y_ABORT_UNLESS(!op->IsExecutionPlanFinished()); + Y_ENSURE(!op->IsExecutionPlanFinished()); if (checkedOps.contains(op) || op->IsInProgress()) continue; @@ -448,8 +447,8 @@ void TPipeline::AddActiveOp(TOperation::TPtr op) } } auto pr = ActivePlannedOps.emplace(op->GetStepOrder(), op); - Y_ABORT_UNLESS(pr.second, "AddActiveOp must never add duplicate transactions"); - Y_ABORT_UNLESS(pr.first == std::prev(ActivePlannedOps.end()), "AddActiveOp must always add transactions in order"); + Y_ENSURE(pr.second, "AddActiveOp must never add duplicate transactions"); + Y_ENSURE(pr.first == std::prev(ActivePlannedOps.end()), "AddActiveOp must always add transactions in order"); bool isComplete = op->HasFlag(TTxFlags::BlockingImmediateOps); if (ActivePlannedOpsLogicallyCompleteEnd == ActivePlannedOps.end() && !isComplete) { LOG_TRACE_S(*TlsActivationContext, NKikimrServices::TX_DATASHARD, @@ -467,7 +466,7 @@ void TPipeline::AddActiveOp(TOperation::TPtr op) if (op->IsSchemeTx()) { if (!SchemaTx) SchemaTx = Self->TransQueue.FindSchemaTx(op->GetTxId()); - Y_VERIFY_S(SchemaTx && SchemaTx->TxId == op->GetTxId(), + Y_ENSURE(SchemaTx && SchemaTx->TxId == op->GetTxId(), "Multiple schema operations at " << Self->TabletID() << ": got " << op->GetKind() << " operation " << *op << " with " << SchemaTx->Type << " operation [" @@ -476,7 +475,7 @@ void TPipeline::AddActiveOp(TOperation::TPtr op) } auto inserted = ActiveOps.emplace(op->GetStepOrder(), op); - Y_VERIFY_S(inserted.second, + Y_ENSURE(inserted.second, " cannot activate " << op->GetKind() << " operation " << *op << " at " << Self->TabletID() << " because it is already active"); @@ -495,7 +494,7 @@ void TPipeline::RemoveActiveOp(TOperation::TPtr op) RemoveImmediateOp(op); } else { auto it = ActivePlannedOps.find(op->GetStepOrder()); - Y_ABORT_UNLESS(it != ActivePlannedOps.end()); + Y_ENSURE(it != ActivePlannedOps.end()); auto next = std::next(it); if (ActivePlannedOpsLogicallyIncompleteEnd == it) { ActivePlannedOpsLogicallyIncompleteEnd = next; @@ -517,7 +516,7 @@ void TPipeline::UnblockNormalDependencies(const TOperation::TPtr &op) // wait for their Dependencies, never for their Depenents for (auto &dep : op->GetDependents()) { if (dep->GetDependencies().size() == 1) { - Y_ABORT_UNLESS(op == *dep->GetDependencies().begin()); + Y_ENSURE(op == *dep->GetDependencies().begin()); if (dep->GetSpecialDependencies().empty()) { AddCandidateOp(dep); } @@ -537,7 +536,7 @@ void TPipeline::UnblockSpecialDependencies(const TOperation::TPtr &op) { for (auto &dep : op->GetSpecialDependents()) { if (dep->GetSpecialDependencies().size() == 1) { - Y_ABORT_UNLESS(op == *dep->GetSpecialDependencies().begin()); + Y_ENSURE(op == *dep->GetSpecialDependencies().begin()); if (dep->GetDependencies().empty()) { AddCandidateOp(dep); } @@ -583,7 +582,7 @@ bool TPipeline::LoadTxDetails(TTransactionContext &txc, auto it = DataTxCache.find(tx->GetTxId()); if (it != DataTxCache.end()) { auto baseTx = it->second; - Y_ABORT_UNLESS(baseTx->GetType() == TValidatedTx::EType::DataTx, "Wrong tx type in cache"); + Y_ENSURE(baseTx->GetType() == TValidatedTx::EType::DataTx, "Wrong tx type in cache"); TValidatedDataTx::TPtr dataTx = std::static_pointer_cast<TValidatedDataTx>(baseTx); dataTx->SetStep(tx->GetStep()); @@ -643,7 +642,7 @@ bool TPipeline::LoadWriteDetails(TTransactionContext& txc, const TActorContext& auto it = DataTxCache.find(writeOp->GetTxId()); if (it != DataTxCache.end()) { auto baseTx = it->second; - Y_ABORT_UNLESS(baseTx->GetType() == TValidatedTx::EType::WriteTx, "Wrong writeOp type in cache"); + Y_ENSURE(baseTx->GetType() == TValidatedTx::EType::WriteTx, "Wrong writeOp type in cache"); TValidatedWriteTx::TPtr writeTx = std::static_pointer_cast<TValidatedWriteTx>(baseTx); writeOp->FillTxData(writeTx); @@ -873,7 +872,7 @@ bool TPipeline::LoadInReadSets(TOperation::TPtr op, // Parse track NKikimrTx::TBalanceTrackList balanceTrackList; bool success = balanceTrackList.ParseFromArray(track.data(), track.size()); - Y_ABORT_UNLESS(success); + Y_ENSURE(success); TReadSetKey rsKey(op->GetTxId(), origin, from, to); loadedReadSets.insert(rsKey); @@ -935,13 +934,13 @@ const TSchemaOperation* TPipeline::FindSchemaTx(ui64 txId) const { } void TPipeline::CompleteSchemaTx(NIceDb::TNiceDb& db, ui64 txId) { - Y_ABORT_UNLESS(txId); + Y_ENSURE(txId); TSchemaOperation * op = Self->TransQueue.FindSchemaTx(txId); if (!op) return; - Y_ABORT_UNLESS(txId == op->TxId); - Y_ABORT_UNLESS(op->Done); + Y_ENSURE(txId == op->TxId); + Y_ENSURE(op->Done); Self->TransQueue.RemoveScanProgress(db, txId); Self->TransQueue.RemoveSchemaOperation(db, txId); @@ -954,7 +953,7 @@ bool TPipeline::PlanTxs(ui64 step, Sort(txIds.begin(), txIds.end()); // check uniqueness for (ui32 i = 1; i < txIds.size(); ++i) { - Y_ABORT_UNLESS(txIds[i - 1] < txIds[i]); + Y_ENSURE(txIds[i - 1] < txIds[i]); } if (step <= LastPlannedTx.Step) @@ -1062,7 +1061,7 @@ void TPipeline::PlanTxImpl(ui64 step, ui64 txId, TTransactionContext &txc, const // queue as 'wait for plan' time. if (op->GetCurrentUnit() == EExecutionUnitKind::WaitForPlan) { auto status = RunExecutionUnit(op, txc, ctx); - Y_ABORT_UNLESS(status == EExecutionStatus::Executed); + Y_ENSURE(status == EExecutionStatus::Executed); } } @@ -1104,7 +1103,7 @@ void TPipeline::CompleteTx(const TOperation::TPtr op, TTransactionContext& txc, MarkPlannedLogicallyCompleteUpTo(TRowVersion(op->GetStep(), op->GetTxId()), txc); Self->PromoteCompleteEdge(op.Get(), txc); - Y_ABORT_UNLESS(ActivePlannedOps); + Y_ENSURE(ActivePlannedOps); if (ActivePlannedOps.begin()->first == op->GetStepOrder()) { LastCompleteTx = op->GetStepOrder(); if (LastCompleteTx < UtmostCompleteTx && ActivePlannedOps.size() == 1) { @@ -1395,7 +1394,7 @@ ui64 TPipeline::GetInactiveTxSize() const { } bool TPipeline::SaveForPropose(TValidatedTx::TPtr tx) { - Y_ABORT_UNLESS(tx && tx->GetTxId()); + Y_ENSURE(tx && tx->GetTxId()); if (DataTxCache.size() >= Config.LimitDataTxCache) return false; @@ -1440,7 +1439,7 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: const TActorContext &ctx, NWilson::TSpan &&operationSpan) { auto &rec = ev->Get()->Record; - Y_ABORT_UNLESS(!(rec.GetFlags() & TTxFlags::PrivateFlagsMask)); + Y_ENSURE(!(rec.GetFlags() & TTxFlags::PrivateFlagsMask)); TBasicOpInfo info(rec.GetTxId(), static_cast<EOperationKind>(rec.GetTxKind()), rec.GetFlags(), 0, @@ -1482,10 +1481,10 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: }; if (tx->IsSchemeTx()) { - Y_ABORT_UNLESS(!tx->HasVolatilePrepareFlag(), "Volatile scheme transactions not supported"); + Y_ENSURE(!tx->HasVolatilePrepareFlag(), "Volatile scheme transactions not supported"); - Y_ABORT_UNLESS(rec.HasSchemeShardId()); - Y_ABORT_UNLESS(rec.HasProcessingParams()); + Y_ENSURE(rec.HasSchemeShardId()); + Y_ENSURE(rec.HasProcessingParams()); tx->SetSchemeShardId(rec.GetSchemeShardId()); tx->SetSubDomainPathId(rec.GetSubDomainPathId()); @@ -1553,7 +1552,7 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: tx->SetGlobalWriterFlag(); } else { - Y_ABORT_UNLESS(tx->IsReadTable() || tx->IsDataTx()); + Y_ENSURE(tx->IsReadTable() || tx->IsDataTx()); auto dataTx = tx->BuildDataTx(Self, txc, ctx); if (dataTx->Ready() && (dataTx->ProgramSize() || dataTx->IsKqpDataTx())) dataTx->ExtractKeys(true); @@ -1613,7 +1612,7 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: return tx; } - Y_ABORT_UNLESS(!tx->IsImmediate(), "Sanity check failed: volatile tx cannot be immediate"); + Y_ENSURE(!tx->IsImmediate(), "Sanity check failed: volatile tx cannot be immediate"); } // Make config checks for immediate tx. @@ -1693,7 +1692,7 @@ TOperation::TPtr TPipeline::BuildOperation(NEvents::TDataEvents::TEvWrite::TPtr& auto writeOp = MakeIntrusive<TWriteOperation>(info, std::move(ev), Self); writeOp->OperationSpan = std::move(operationSpan); auto writeTx = writeOp->GetWriteTx(); - Y_ABORT_UNLESS(writeTx); + Y_ENSURE(writeTx); auto badRequest = [&](NKikimrDataEvents::TEvWriteResult::EStatus status, const TString& error) { writeOp->SetError(status, TStringBuilder() << error << " at tablet# " << Self->TabletID()); @@ -1749,7 +1748,7 @@ TOperation::TPtr TPipeline::BuildOperation(NEvents::TDataEvents::TEvWrite::TPtr& void TPipeline::BuildDataTx(TActiveTransaction *tx, TTransactionContext &txc, const TActorContext &ctx) { auto dataTx = tx->BuildDataTx(Self, txc, ctx); - Y_ABORT_UNLESS(dataTx->Ready()); + Y_ENSURE(dataTx->Ready()); // TODO: we should have no requirement to have keys // for restarted immediate tx. if (dataTx->ProgramSize() || dataTx->IsKqpDataTx()) @@ -1783,7 +1782,7 @@ void TPipeline::RegisterDistributedWrites(const TOperation::TPtr& op, NTable::TD EExecutionStatus TPipeline::RunExecutionUnit(TOperation::TPtr op, TTransactionContext &txc, const TActorContext &ctx) { - Y_ABORT_UNLESS(!op->IsExecutionPlanFinished()); + Y_ENSURE(!op->IsExecutionPlanFinished()); auto &unit = GetExecutionUnit(op->GetCurrentUnit()); LOG_TRACE_S(ctx, NKikimrServices::TX_DATASHARD, @@ -1878,7 +1877,7 @@ EExecutionStatus TPipeline::RunExecutionPlan(TOperation::TPtr op, completeList.push_back(unit.GetKind()); MoveToNextUnit(op); } else { - Y_VERIFY_S(status == EExecutionStatus::Restart + Y_ENSURE(status == EExecutionStatus::Restart || status == EExecutionStatus::Continue || status == EExecutionStatus::Reschedule, "Unexpected execution status " << status); @@ -1888,7 +1887,7 @@ EExecutionStatus TPipeline::RunExecutionPlan(TOperation::TPtr op, "Unexpected execution status " << status << " from unit " << unit.GetKind() << " not marked as restartable"); - Y_VERIFY_S(canRestart, + Y_ENSURE(canRestart, "Unexpected execution status " << status << " from unit " << unit.GetKind() << " when restarts are not allowed"); @@ -1903,7 +1902,7 @@ EExecutionStatus TPipeline::RunExecutionPlan(TOperation::TPtr op, void TPipeline::MoveToNextUnit(TOperation::TPtr op) { - Y_ABORT_UNLESS(!op->IsExecutionPlanFinished()); + Y_ENSURE(!op->IsExecutionPlanFinished()); GetExecutionUnit(op->GetCurrentUnit()).RemoveOperation(op); LOG_TRACE_S(TActivationContext::AsActorContext(), NKikimrServices::TX_DATASHARD, @@ -1938,7 +1937,7 @@ void TPipeline::RunCompleteList(TOperation::TPtr op, op->SetCompleteTime(kind, AppData()->TimeProvider->Now() - start); if (!op->IsExecutionPlanFinished() && op->GetCurrentUnit() == kind) { - Y_ABORT_UNLESS(completeList.back() == kind); + Y_ENSURE(completeList.back() == kind); MoveToNextUnit(op); } } @@ -1989,7 +1988,7 @@ bool TPipeline::AddWaitingSchemeOp(const TOperation::TPtr& op) { auto itOrder = WaitingSchemeOpsOrder.insert(WaitingSchemeOpsOrder.end(), op); auto res = WaitingSchemeOps.emplace(op, itOrder); - Y_ABORT_UNLESS(res.second, "Unexpected duplicate when inserting op into THashMap"); + Y_ENSURE(res.second, "Unexpected duplicate when inserting op into THashMap"); return true; } @@ -2192,7 +2191,7 @@ bool TPipeline::CancelWaitingReadIterator(const TReadIteratorId& readId) { void TPipeline::RegisterWaitingReadIterator(const TReadIteratorId& readId, TEvDataShard::TEvRead* event) { auto res = WaitingReadIteratorsById.emplace(readId, event); - Y_ABORT_UNLESS(res.second); + Y_ENSURE(res.second); } bool TPipeline::HandleWaitingReadIterator(const TReadIteratorId& readId, TEvDataShard::TEvRead* event) { @@ -2280,7 +2279,7 @@ void TPipeline::AddCommittingOp(const TOperation::TPtr& op) { if (op->IsReadOnly()) return; - Y_VERIFY_S(!op->GetCommittingOpsVersion(), + Y_ENSURE(!op->GetCommittingOpsVersion(), "Trying to AddCommittingOp " << *op << " more than once"); TRowVersion version = Self->GetReadWriteVersions(op.Get()).WriteVersion; @@ -2417,14 +2416,14 @@ bool TPipeline::AddLockDependencies(const TOperation::TPtr& op, TLocksUpdate& gu } void TPipeline::ProvideGlobalTxId(const TOperation::TPtr& op, ui64 globalTxId) { - Y_ABORT_UNLESS(op->HasWaitingForGlobalTxIdFlag()); + Y_ENSURE(op->HasWaitingForGlobalTxIdFlag()); ui64 localTxId = op->GetTxId(); auto itImmediate = ImmediateOps.find(localTxId); - Y_ABORT_UNLESS(itImmediate != ImmediateOps.end()); + Y_ENSURE(itImmediate != ImmediateOps.end()); ImmediateOps.erase(itImmediate); auto itActive = ActiveOps.find(op->GetStepOrder()); - Y_ABORT_UNLESS(itActive != ActiveOps.end()); + Y_ENSURE(itActive != ActiveOps.end()); ActiveOps.erase(itActive); bool removedCandidate = false; auto itCandidate = CandidateOps.find(op->GetStepOrder()); @@ -2436,12 +2435,12 @@ void TPipeline::ProvideGlobalTxId(const TOperation::TPtr& op, ui64 globalTxId) { op->SetGlobalTxId(globalTxId); op->SetWaitingForGlobalTxIdFlag(false); auto resImmediate = ImmediateOps.emplace(op->GetTxId(), op); - Y_ABORT_UNLESS(resImmediate.second); + Y_ENSURE(resImmediate.second); auto resActive = ActiveOps.emplace(op->GetStepOrder(), op); - Y_ABORT_UNLESS(resActive.second); + Y_ENSURE(resActive.second); if (removedCandidate) { auto resCandidate = CandidateOps.emplace(op->GetStepOrder(), op); - Y_ABORT_UNLESS(resCandidate.second); + Y_ENSURE(resCandidate.second); } } diff --git a/ydb/core/tx/datashard/datashard_pipeline.h b/ydb/core/tx/datashard/datashard_pipeline.h index 316610a6e1..5f5cf6b8e3 100644 --- a/ydb/core/tx/datashard/datashard_pipeline.h +++ b/ydb/core/tx/datashard/datashard_pipeline.h @@ -186,7 +186,7 @@ public: } void SetSchemaOp(TSchemaOperation * op) { - Y_ABORT_UNLESS(!SchemaTx || SchemaTx->TxId == op->TxId); + Y_ENSURE(!SchemaTx || SchemaTx->TxId == op->TxId); SchemaTx = op; } @@ -454,7 +454,7 @@ private: if (!res.second) res.first->Counter += 1; auto res2 = TxIdMap.emplace(txId, res.first); - Y_VERIFY_S(res2.second, "Unexpected duplicate immediate tx " << txId + Y_ENSURE(res2.second, "Unexpected duplicate immediate tx " << txId << " committing at " << version); res.first->TxCounter += 1; } @@ -467,11 +467,11 @@ private: inline void Remove(ui64 txId, TRowVersion version) { auto it = TxIdMap.find(txId); - Y_VERIFY_S(it != TxIdMap.end(), "Removing immediate tx " << txId << " " << version + Y_ENSURE(it != TxIdMap.end(), "Removing immediate tx " << txId << " " << version << " does not match a previous Add"); - Y_VERIFY_S(TRowVersion(it->second->Step, it->second->TxId) == version, "Removing immediate tx " << txId << " " << version + Y_ENSURE(TRowVersion(it->second->Step, it->second->TxId) == version, "Removing immediate tx " << txId << " " << version << " does not match a previous Add " << TRowVersion(it->second->Step, it->second->TxId)); - Y_VERIFY_S(it->second->TxCounter > 0, "Removing immediate tx " << txId << " " << version + Y_ENSURE(it->second->TxCounter > 0, "Removing immediate tx " << txId << " " << version << " with a mismatching TxCounter"); --it->second->TxCounter; if (--it->second->Counter == 0) @@ -481,10 +481,10 @@ private: inline void Remove(TRowVersion version) { auto it = ItemsSet.find(version); - Y_VERIFY_S(it != ItemsSet.end(), "Removing version " << version + Y_ENSURE(it != ItemsSet.end(), "Removing version " << version << " does not match a previous Add"); if (--it->Counter == 0) { - Y_VERIFY_S(it->TxCounter == 0, "Removing version " << version + Y_ENSURE(it->TxCounter == 0, "Removing version " << version << " while TxCounter has active references, possible Add/Remove mismatch"); ItemsSet.erase(it); } diff --git a/ydb/core/tx/datashard/datashard_repl_apply.cpp b/ydb/core/tx/datashard/datashard_repl_apply.cpp index c1a19939f1..7acdb5fe50 100644 --- a/ydb/core/tx/datashard/datashard_repl_apply.cpp +++ b/ydb/core/tx/datashard/datashard_repl_apply.cpp @@ -83,7 +83,7 @@ public: for (const auto& change : msg.GetChanges()) { if (!ApplyChange(txc, fullTableId, userTable, source, change)) { - Y_ABORT_UNLESS(Result); + Y_ENSURE(Result); break; } } @@ -105,7 +105,7 @@ public: TReplicationSourceState& EnsureSource(TTransactionContext& txc, const TPathId& pathId, const TString& sourceName) { TReplicationSourceOffsetsDb rdb(txc); auto* table = Self->EnsureReplicatedTable(pathId); - Y_ABORT_UNLESS(table); + Y_ENSURE(table); return table->EnsureSource(rdb, sourceName); } @@ -113,7 +113,7 @@ public: TTransactionContext& txc, const TTableId& tableId, const TUserTable& userTable, TReplicationSourceState& source, const NKikimrTxDataShard::TEvApplyReplicationChanges::TChange& change) { - Y_ABORT_UNLESS(userTable.IsReplicated() || Self->IsIncrementalRestore()); + Y_ENSURE(userTable.IsReplicated() || Self->IsIncrementalRestore()); // TODO: check source and offset, persist new values i64 sourceOffset = change.GetSourceOffset(); @@ -251,8 +251,8 @@ public: } void Complete(const TActorContext& ctx) override { - Y_ABORT_UNLESS(Ev); - Y_ABORT_UNLESS(Result); + Y_ENSURE(Ev); + Y_ENSURE(Result); if (MvccReadWriteVersion) { Pipeline.RemoveCommittingOp(*MvccReadWriteVersion); diff --git a/ydb/core/tx/datashard/datashard_repl_offsets.cpp b/ydb/core/tx/datashard/datashard_repl_offsets.cpp index f62a9d4c7a..f2fde5e2c9 100644 --- a/ydb/core/tx/datashard/datashard_repl_offsets.cpp +++ b/ydb/core/tx/datashard/datashard_repl_offsets.cpp @@ -125,8 +125,8 @@ namespace NKikimr::NDataShard { state.SplitKeyId = splitKeyId; state.SplitKey = std::move(key); auto res = Offsets.insert(&state); - Y_ABORT_UNLESS(res.second, "AddSplitKey used with a key that already exists"); - Y_ABORT_UNLESS(res.first != Offsets.begin(), "AddSplitKey somehow added split key before the first key"); + Y_ENSURE(res.second, "AddSplitKey used with a key that already exists"); + Y_ENSURE(res.first != Offsets.begin(), "AddSplitKey somehow added split key before the first key"); auto& prev = **--res.first; state.MaxOffset = prev.MaxOffset; PersistSplitKeyCreated(db, state); @@ -141,8 +141,8 @@ namespace NKikimr::NDataShard { state.SplitKey = std::move(key); state.MaxOffset = offset; auto res = Offsets.insert(&state); - Y_ABORT_UNLESS(res.second, "AddSplitKey used with a key that already exists"); - Y_ABORT_UNLESS(res.first != Offsets.begin(), "AddSplitKey somehow added split key before the first key"); + Y_ENSURE(res.second, "AddSplitKey used with a key that already exists"); + Y_ENSURE(res.first != Offsets.begin(), "AddSplitKey somehow added split key before the first key"); PersistSplitKeyCreated(db, state); AddStatBytes(state); return &state; @@ -162,7 +162,7 @@ namespace NKikimr::NDataShard { // Find the range that contains the key auto stop = Offsets.upper_bound(key); - Y_ABORT_UNLESS(stop != Offsets.begin()); + Y_ENSURE(stop != Offsets.begin()); auto start = std::prev(stop); if (offset <= (*start)->MaxOffset) { diff --git a/ydb/core/tx/datashard/datashard_repl_offsets_server.cpp b/ydb/core/tx/datashard/datashard_repl_offsets_server.cpp index c2c4d214be..486eb8c934 100644 --- a/ydb/core/tx/datashard/datashard_repl_offsets_server.cpp +++ b/ydb/core/tx/datashard/datashard_repl_offsets_server.cpp @@ -43,7 +43,7 @@ void TReplicationSourceOffsetsServer::Handle(TEvDataShard::TEvGetReplicationSour state.NextSplitKeyId = msg->Record.GetFromSplitKeyId(); if (readId.ActorId.NodeId() != SelfId().NodeId()) { - Y_ABORT_UNLESS(ev->InterconnectSession); + Y_ENSURE(ev->InterconnectSession); state.InterconnectSession = ev->InterconnectSession; auto& nodeState = Nodes[readId.ActorId.NodeId()]; auto& sessionState = Sessions[ev->InterconnectSession]; @@ -153,7 +153,7 @@ void TReplicationSourceOffsetsServer::ProcessNode(TNodeState& node) { while (node.InFlightTotal < node.WindowSize && !node.WaitingReads.empty()) { auto waitingRead = node.WaitingReads.front(); auto& waitingState = Reads.at(waitingRead); - Y_ABORT_UNLESS(waitingState.WaitingNode); + Y_ENSURE(waitingState.WaitingNode); node.WaitingReads.pop_front(); waitingState.WaitingNode = false; ProcessRead(waitingRead, waitingState); @@ -195,7 +195,7 @@ void TReplicationSourceOffsetsServer::Handle(TEvDataShard::TEvReplicationSourceO ProcessRead(readId, state); } else if (state.InFlight.empty()) { // Forget this read - Y_ABORT_UNLESS(!state.WaitingNode); + Y_ENSURE(!state.WaitingNode); if (sessionState) { sessionState->Reads.erase(readId); } @@ -234,7 +234,7 @@ void TReplicationSourceOffsetsServer::Handle(TEvDataShard::TEvReplicationSourceO nodeState->InFlightTotal -= state.InFlightTotal; } - Y_ABORT_UNLESS(!state.WaitingNode); + Y_ENSURE(!state.WaitingNode); if (sessionState) { sessionState->Reads.erase(readId); } @@ -295,7 +295,7 @@ void TReplicationSourceOffsetsServer::NodeDisconnected(const TActorId& sessionId if (node.Sessions.empty()) { // We no longer need this node - Y_ABORT_UNLESS(node.WaitingReads.empty()); + Y_ENSURE(node.WaitingReads.empty()); Nodes.erase(session.NodeId); } else { ProcessNode(node); diff --git a/ydb/core/tx/datashard/datashard_s3_downloads.cpp b/ydb/core/tx/datashard/datashard_s3_downloads.cpp index d77b418360..6bfd16f305 100644 --- a/ydb/core/tx/datashard/datashard_s3_downloads.cpp +++ b/ydb/core/tx/datashard/datashard_s3_downloads.cpp @@ -13,7 +13,7 @@ bool TS3DownloadsManager::Load(NIceDb::TNiceDb& db) { while (!rowset.EndOfSet()) { ui64 txId = rowset.GetValue<Schema::S3Downloads::TxId>(); - Y_VERIFY_S(!Downloads.contains(txId), "Unexpected duplicate s3 download: " << txId); + Y_ENSURE(!Downloads.contains(txId), "Unexpected duplicate s3 download: " << txId); auto& info = Downloads[txId]; if (rowset.HaveValue<Schema::S3Downloads::DataETag>()) { @@ -55,8 +55,8 @@ const TS3Download* TS3DownloadsManager::Find(ui64 txId) const { const TS3Download& TS3DownloadsManager::Store(NIceDb::TNiceDb& db, ui64 txId, const TS3Download& newInfo) { auto& info = Downloads[txId]; - Y_ABORT_UNLESS(newInfo.DataETag); - Y_ABORT_UNLESS(info.DataETag.GetOrElse(*newInfo.DataETag) == *newInfo.DataETag); + Y_ENSURE(newInfo.DataETag); + Y_ENSURE(info.DataETag.GetOrElse(*newInfo.DataETag) == *newInfo.DataETag); info = newInfo; using Schema = TDataShard::Schema; diff --git a/ydb/core/tx/datashard/datashard_s3_uploads.cpp b/ydb/core/tx/datashard/datashard_s3_uploads.cpp index 6b2e2f72d6..c2ef11c23d 100644 --- a/ydb/core/tx/datashard/datashard_s3_uploads.cpp +++ b/ydb/core/tx/datashard/datashard_s3_uploads.cpp @@ -18,7 +18,7 @@ bool TS3UploadsManager::Load(NIceDb::TNiceDb& db) { const TString uploadId = rowset.GetValue<Schema::S3Uploads::UploadId>(); auto res = Uploads.emplace(txId, TS3Upload(uploadId)); - Y_VERIFY_S(res.second, "Unexpected duplicate s3 upload" + Y_ENSURE(res.second, "Unexpected duplicate s3 upload" << ": txId# " << txId << ", uploadId# " << uploadId); @@ -45,7 +45,7 @@ bool TS3UploadsManager::Load(NIceDb::TNiceDb& db) { const ui64 txId = rowset.GetValue<Schema::S3UploadedParts::TxId>(); auto it = Uploads.find(txId); - Y_VERIFY_S(it != Uploads.end(), "Unknown s3 upload part" + Y_ENSURE(it != Uploads.end(), "Unknown s3 upload part" << ": txId# " << txId); auto& parts = it->second.Parts; @@ -82,7 +82,7 @@ const TS3Upload* TS3UploadsManager::Find(ui64 txId) const { const TS3Upload& TS3UploadsManager::Add(NIceDb::TNiceDb& db, ui64 txId, const TString& uploadId) { using Schema = TDataShard::Schema; - Y_ABORT_UNLESS(!Uploads.contains(txId)); + Y_ENSURE(!Uploads.contains(txId)); auto res = Uploads.emplace(txId, TS3Upload(uploadId)); db.Table<Schema::S3Uploads>().Key(txId).Update<Schema::S3Uploads::UploadId>(uploadId); @@ -96,7 +96,7 @@ const TS3Upload& TS3UploadsManager::ChangeStatus(NIceDb::TNiceDb& db, ui64 txId, using Schema = TDataShard::Schema; auto it = Uploads.find(txId); - Y_ABORT_UNLESS(it != Uploads.end()); + Y_ENSURE(it != Uploads.end()); auto& upload = it->second; upload.Status = status; diff --git a/ydb/core/tx/datashard/datashard_schema_snapshots.cpp b/ydb/core/tx/datashard/datashard_schema_snapshots.cpp index 9c56e4ad73..86281a0957 100644 --- a/ydb/core/tx/datashard/datashard_schema_snapshots.cpp +++ b/ydb/core/tx/datashard/datashard_schema_snapshots.cpp @@ -41,14 +41,14 @@ bool TSchemaSnapshotManager::Load(NIceDb::TNiceDb& db) { NKikimrSchemeOp::TTableDescription desc; const bool ok = ParseFromStringNoSizeLimit(desc, schema); - Y_ABORT_UNLESS(ok); + Y_ENSURE(ok); const auto res = Snapshots.emplace( std::piecewise_construct, std::forward_as_tuple(oid, tid, version), std::forward_as_tuple(new TUserTable(0, desc, 0), step, txId) ); - Y_VERIFY_S(res.second, "Duplicate schema snapshot: " << res.first->first); + Y_ENSURE(res.second, "Duplicate schema snapshot: " << res.first->first); if (!rowset.Next()) { return false; @@ -65,10 +65,10 @@ bool TSchemaSnapshotManager::AddSnapshot(NTable::TDatabase& db, const TSchemaSna } auto it = Self->GetUserTables().find(key.PathId); - Y_VERIFY_S(it != Self->GetUserTables().end(), "Cannot find table: " << key.PathId); + Y_ENSURE(it != Self->GetUserTables().end(), "Cannot find table: " << key.PathId); const auto res = Snapshots.emplace(key, snapshot); - Y_VERIFY_S(res.second, "Duplicate schema snapshot: " << key); + Y_ENSURE(res.second, "Duplicate schema snapshot: " << key); NIceDb::TNiceDb nicedb(db); PersistAddSnapshot(nicedb, key, snapshot); @@ -95,7 +95,7 @@ void TSchemaSnapshotManager::RemoveShapshot(NTable::TDatabase& db, const TSchema void TSchemaSnapshotManager::RenameSnapshots(NTable::TDatabase& db, const TPathId& prevTableId, const TPathId& newTableId) { - Y_VERIFY_S(prevTableId < newTableId, "New table id should be greater than previous" + Y_ENSURE(prevTableId < newTableId, "New table id should be greater than previous" << ": prev# " << prevTableId << ", new# " << newTableId); diff --git a/ydb/core/tx/datashard/datashard_snapshots.cpp b/ydb/core/tx/datashard/datashard_snapshots.cpp index b2fc9c9fbc..2f6b44fbe9 100644 --- a/ydb/core/tx/datashard/datashard_snapshots.cpp +++ b/ydb/core/tx/datashard/datashard_snapshots.cpp @@ -157,7 +157,7 @@ bool TSnapshotManager::ReloadSnapshots(NIceDb::TNiceDb& db) { std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(key, std::move(name), flags, TDuration::MilliSeconds(timeout_ms))); - Y_VERIFY_S(res.second, "Unexpected duplicate snapshot: " << key); + Y_ENSURE(res.second, "Unexpected duplicate snapshot: " << key); if (!rowset.Next()) { return false; @@ -497,9 +497,9 @@ bool TSnapshotManager::AddSnapshot(NTable::TDatabase& db, const TSnapshotKey& ke const TRowVersion newVersion(key.Step, key.TxId); // N.B. no colocated tables support for now - Y_ABORT_UNLESS(Self->GetUserTables().size() == 1, "Multiple co-located tables not supported"); + Y_ENSURE(Self->GetUserTables().size() == 1, "Multiple co-located tables not supported"); - Y_VERIFY_S(oldVersion <= newVersion, + Y_ENSURE(oldVersion <= newVersion, "DataShard " << Self->TabletID() << " adding new snapshot " << newVersion << " below previous min write version " << oldVersion); @@ -539,7 +539,7 @@ bool TSnapshotManager::RemoveSnapshot(NTable::TDatabase& db, const TSnapshotKey& void TSnapshotManager::DoRemoveSnapshot(NTable::TDatabase& db, const TSnapshotKey& key) { auto* tablePtr = Self->GetUserTables().FindPtr(key.PathId); - Y_VERIFY_S(tablePtr && *tablePtr, "DataShard " << Self->TabletID() << " missing table " << key.PathId); + Y_ENSURE(tablePtr && *tablePtr, "DataShard " << Self->TabletID() << " missing table " << key.PathId); const ui32 localTableId = (*tablePtr)->LocalTid; NIceDb::TNiceDb nicedb(db); @@ -689,7 +689,7 @@ void TSnapshotManager::PersistAddSnapshot(NIceDb::TNiceDb& db, const TSnapshotKe std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(key, name, flags, timeout)); - Y_VERIFY_S(res.second, "Unexpected duplicate snapshot: " << key); + Y_ENSURE(res.second, "Unexpected duplicate snapshot: " << key); db.Table<Schema::Snapshots>() .Key(key.OwnerId, key.PathId, key.Step, key.TxId) @@ -701,7 +701,7 @@ void TSnapshotManager::PersistRemoveSnapshot(NIceDb::TNiceDb& db, const TSnapsho using Schema = TDataShard::Schema; auto it = Snapshots.find(key); - Y_VERIFY_S(it != Snapshots.end(), "Removing unknown snapshot: " << key); + Y_ENSURE(it != Snapshots.end(), "Removing unknown snapshot: " << key); if (ExpireQueue.Has(&it->second)) { ExpireQueue.Remove(&it->second); @@ -718,7 +718,7 @@ void TSnapshotManager::PersistUpdateSnapshotFlags(NIceDb::TNiceDb& db, const TSn using Schema = TDataShard::Schema; auto it = Snapshots.find(key); - Y_VERIFY_S(it != Snapshots.end(), "Updating unknown snapshot: " << key); + Y_ENSURE(it != Snapshots.end(), "Updating unknown snapshot: " << key); if (it->second.HasFlags(TSnapshot::FlagRemoved)) { if (ExpireQueue.Has(&it->second)) { diff --git a/ydb/core/tx/datashard/datashard_split_dst.cpp b/ydb/core/tx/datashard/datashard_split_dst.cpp index 41c45727c2..c508eccd25 100644 --- a/ydb/core/tx/datashard/datashard_split_dst.cpp +++ b/ydb/core/tx/datashard/datashard_split_dst.cpp @@ -37,7 +37,7 @@ public: TPathId tableId(Self->GetPathOwnerId(), createTable.GetId_Deprecated()); if (createTable.HasPathId()) { - Y_ABORT_UNLESS(Self->GetPathOwnerId() == createTable.GetPathId().GetOwnerId() || Self->GetPathOwnerId() == INVALID_TABLET_ID); + Y_ENSURE(Self->GetPathOwnerId() == createTable.GetPathId().GetOwnerId() || Self->GetPathOwnerId() == INVALID_TABLET_ID); tableId = TPathId::FromProto(createTable.GetPathId()); } else if (tableId.OwnerId == INVALID_TABLET_ID) { // Legacy schemeshard before migrations, shouldn't be possible @@ -73,7 +73,7 @@ public: // Persist split description TString splitDescr; bool serilaizeOk = Self->DstSplitDescription->SerializeToString(&splitDescr); - Y_ABORT_UNLESS(serilaizeOk, "Failed to serialize split/merge description"); + Y_ENSURE(serilaizeOk, "Failed to serialize split/merge description"); Self->PersistSys(db, Schema::Sys_DstSplitDescription, splitDescr); if (initializeSchema) { @@ -401,14 +401,14 @@ public: } const auto& userTables = Self->GetUserTables(); - Y_ABORT_UNLESS(msg->PathId.OwnerId == Self->GetPathOwnerId()); + Y_ENSURE(msg->PathId.OwnerId == Self->GetPathOwnerId()); auto itUserTables = userTables.find(msg->PathId.LocalPathId); - Y_ABORT_UNLESS(itUserTables != userTables.end()); + Y_ENSURE(itUserTables != userTables.end()); TUserTable::TCPtr tableInfo = itUserTables->second; TConstArrayRef<NScheme::TTypeInfo> keyColumnTypes = tableInfo->KeyColumnTypes; auto* replTable = Self->EnsureReplicatedTable(msg->PathId); - Y_ABORT_UNLESS(replTable); + Y_ENSURE(replTable); if (Self->SrcTabletToRange.empty()) { for (const auto& srcRange : Self->DstSplitDescription->GetSourceRanges()) { @@ -518,7 +518,7 @@ public: // Find split keys that are in the (From, To) range auto itBegin = std::upper_bound(kvSource.second.begin(), kvSource.second.end(), range.From, leftLess); auto itEnd = std::lower_bound(kvSource.second.begin(), kvSource.second.end(), range.To, rightLess); - Y_ABORT_UNLESS(itBegin != kvSource.second.begin()); + Y_ENSURE(itBegin != kvSource.second.begin()); // Add the shard right border first if (!range.To.GetCells().empty() && !rightFull) { diff --git a/ydb/core/tx/datashard/datashard_split_src.cpp b/ydb/core/tx/datashard/datashard_split_src.cpp index d0c3afb0d5..f2ca976cb7 100644 --- a/ydb/core/tx/datashard/datashard_split_src.cpp +++ b/ydb/core/tx/datashard/datashard_split_src.cpp @@ -40,7 +40,7 @@ public: // Persist split description TString splitDescr; bool serilaizeOk = Self->SrcSplitDescription->SerializeToString(&splitDescr); - Y_ABORT_UNLESS(serilaizeOk, "Failed to serialize split/merge description"); + Y_ENSURE(serilaizeOk, "Failed to serialize split/merge description"); db.Table<Schema::Sys>().Key(Schema::Sys_SrcSplitDescription).Update(NIceDb::TUpdate<Schema::Sys::Bytes>(splitDescr)); Self->PersistSys(db, Schema::Sys_SrcSplitOpId, Self->SrcSplitOpId); @@ -59,9 +59,9 @@ public: Self->Pipeline.CleanupWaitingVolatile(ctx, Replies); } else { // Check that this is the same split request - Y_ABORT_UNLESS(opId == Self->SrcSplitOpId, - "Datashard %" PRIu64 " got unexpected split request opId %" PRIu64 " while already executing split request opId %" PRIu64, - Self->TabletID(), opId, Self->SrcSplitOpId); + Y_ENSURE(opId == Self->SrcSplitOpId, + "Datashard " << Self->TabletID() << " got unexpected split request opId " << opId + << " while already executing split request opId " << Self->SrcSplitOpId); Self->SrcAckSplitTo.insert(Ev->Sender); @@ -71,10 +71,10 @@ public: SplitAlreadyFinished = false; return true; } else if (Self->State == TShardState::SplitSrcSendingSnapshot) { - Y_ABORT_UNLESS(!Self->SplitSrcSnapshotSender.AllAcked(), "State should have changed at the moment when last ack was recevied"); + Y_ENSURE(!Self->SplitSrcSnapshotSender.AllAcked(), "State should have changed at the moment when last ack was recevied"); // Do nothing because we are still waiting for acks from DSTs } else { - Y_ABORT_UNLESS( + Y_ENSURE( Self->State == TShardState::SplitSrcWaitForPartitioningChanged || Self->State == TShardState::PreOffline || Self->State == TShardState::Offline); @@ -134,7 +134,7 @@ public: return true; } - Y_ABORT_UNLESS(Self->TxInFly() == 0, "Currently split operation shouldn't start while there are in-flight transactions"); + Y_ENSURE(Self->TxInFly() == 0, "Currently split operation shouldn't start while there are in-flight transactions"); // We need to remove all locks first, making sure persistent uncommitted // changes are not borrowed by new shards. Otherwise those will become @@ -152,7 +152,7 @@ public: } Self->SysLocksTable().ApplyLocks(); auto countAfter = Self->SysLocksTable().GetLocks().size(); - Y_ABORT_UNLESS(countAfter < countBefore, "Expected to erase at least one lock"); + Y_ENSURE(countAfter < countBefore, "Expected to erase at least one lock"); Self->Execute(Self->CreateTxStartSplit(), ctx); return true; } @@ -177,7 +177,7 @@ public: return false; \ } \ if (isStrictCheck) { \ - Y_ABORT_UNLESS(str.empty(), #table " table is not empty when starting Split at tablet %" PRIu64 " : \n%s", Self->TabletID(), str.Str().data()); \ + Y_ENSURE(str.empty(), #table " table is not empty when starting Split at tablet " << Self->TabletID() << " : \n" << str.Str()); \ } else if (!str.empty()) { \ LOG_ERROR_S(ctx, NKikimrServices::TX_DATASHARD, \ #table " table is not empty when starting Split at tablet " << Self->TabletID() << " : " << str.Str()); \ @@ -255,7 +255,7 @@ public: ui64 opId = Self->SrcSplitOpId; LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() << " snapshot complete for split OpId " << opId); - Y_ABORT_UNLESS(Self->State == TShardState::SplitSrcMakeSnapshot, "Datashard in unexpected state %s", DatashardStateName(Self->State).data()); + Y_ENSURE(Self->State == TShardState::SplitSrcMakeSnapshot, "Datashard in unexpected state " << DatashardStateName(Self->State)); txc.Env.ClearSnapshot(*SnapContext); @@ -280,7 +280,7 @@ public: snapshot->SetOperationCookie(opId); // Fill user table scheme - Y_ABORT_UNLESS(Self->TableInfos.size() == 1, "Support for more than 1 user table in a datashard is not implemented here"); + Y_ENSURE(Self->TableInfos.size() == 1, "Support for more than 1 user table in a datashard is not implemented here"); const TUserTable& tableInfo = *Self->TableInfos.begin()->second; tableInfo.GetSchema(*snapshot->MutableUserTableScheme()); @@ -506,13 +506,13 @@ public: TTxType GetTxType() const override { return TXTYPE_SPLIT_PARTITIONING_CHANGED; } bool Execute(TTransactionContext& txc, const TActorContext&) override { - Y_ABORT_UNLESS(!Self->ChangesQueue && Self->ChangeSenderActivator.AllAcked()); + Y_ENSURE(!Self->ChangesQueue && Self->ChangeSenderActivator.AllAcked()); // TODO: At this point Src should start rejecting all new Tx with SchemaChanged status if (Self->State != TShardState::SplitSrcWaitForPartitioningChanged) { - Y_ABORT_UNLESS(Self->State == TShardState::PreOffline || Self->State == TShardState::Offline, - "Unexpected TEvSplitPartitioningChanged at datashard %" PRIu64 " state %s", - Self->TabletID(), DatashardStateName(Self->State).data()); + Y_ENSURE(Self->State == TShardState::PreOffline || Self->State == TShardState::Offline, + "Unexpected TEvSplitPartitioningChanged at datashard " << Self->TabletID() + << " state " << DatashardStateName(Self->State)); return true; } diff --git a/ydb/core/tx/datashard/datashard_trans_queue.cpp b/ydb/core/tx/datashard/datashard_trans_queue.cpp index c8b60b1672..5c59073941 100644 --- a/ydb/core/tx/datashard/datashard_trans_queue.cpp +++ b/ydb/core/tx/datashard/datashard_trans_queue.cpp @@ -9,7 +9,7 @@ const TSet<TStepOrder> TTransQueue::EMPTY_PLAN; void TTransQueue::AddTxInFly(TOperation::TPtr op) { const ui64 txId = op->GetTxId(); - Y_VERIFY_S(!TxsInFly.contains(txId), "Adding duplicate txId " << txId); + Y_ENSURE(!TxsInFly.contains(txId), "Adding duplicate txId " << txId); TxsInFly[txId] = op; if (Y_LIKELY(!op->GetStep())) { ++PlanWaitingTxCount; @@ -45,12 +45,12 @@ bool TTransQueue::Load(NIceDb::TNiceDb& db) { using Schema = TDataShard::Schema; // Load must be idempotent - Y_ABORT_UNLESS(TxsInFly.empty()); - Y_ABORT_UNLESS(SchemaOps.empty()); - Y_ABORT_UNLESS(PlannedTxs.empty()); - Y_ABORT_UNLESS(DeadlineQueue.empty()); - Y_ABORT_UNLESS(ProposeDelayers.empty()); - Y_ABORT_UNLESS(PlanWaitingTxCount == 0); + Y_ENSURE(TxsInFly.empty()); + Y_ENSURE(SchemaOps.empty()); + Y_ENSURE(PlannedTxs.empty()); + Y_ENSURE(DeadlineQueue.empty()); + Y_ENSURE(ProposeDelayers.empty()); + Y_ENSURE(PlanWaitingTxCount == 0); TInstant now = AppData()->TimeProvider->Now(); @@ -200,10 +200,10 @@ void TTransQueue::ProposeSchemaTx(NIceDb::TNiceDb& db, const TSchemaOperation& o // Auto-ack previous schema operation if (!SchemaOps.empty()) { - Y_ABORT_UNLESS(SchemaOps.begin()->first != op.TxId, "Duplicate Tx %" PRIu64 " wasn't properly handled", op.TxId); - Y_ABORT_UNLESS(SchemaOps.size() == 1, "Cannot have multiple un-Ack-ed previous schema operations"); - Y_ABORT_UNLESS(SchemaOps.begin()->second.Done, - "Previous Tx %" PRIu64 " must be in state when it only waits for Ack", SchemaOps.begin()->first); + Y_ENSURE(SchemaOps.begin()->first != op.TxId, "Duplicate Tx " << op.TxId << " wasn't properly handled"); + Y_ENSURE(SchemaOps.size() == 1, "Cannot have multiple un-Ack-ed previous schema operations"); + Y_ENSURE(SchemaOps.begin()->second.Done, + "Previous Tx " << SchemaOps.begin()->first << " must be in a state where it only waits for Ack"); RemoveSchemaOperation(db, SchemaOps.begin()->second.TxId); } @@ -223,7 +223,7 @@ void TTransQueue::ProposeSchemaTx(NIceDb::TNiceDb& db, const TSchemaOperation& o NIceDb::TUpdate<Schema::SchemaOperations::Rows>(op.RowsProcessed)); TSchemaOperation * savedOp = &saved.first->second; - Y_ABORT_UNLESS(savedOp->TabletId); + Y_ENSURE(savedOp->TabletId); Self->Pipeline.SetSchemaOp(savedOp); db.NoMoreReadsForTx(); @@ -262,7 +262,7 @@ void TTransQueue::UpdateTxFlags(NIceDb::TNiceDb& db, ui64 txId, ui64 flags) { using Schema = TDataShard::Schema; auto it = TxsInFly.find(txId); - Y_ABORT_UNLESS(it != TxsInFly.end()); + Y_ENSURE(it != TxsInFly.end()); if (it->second->HasVolatilePrepareFlag()) { // We keep volatile transactions in memory and don't store anything @@ -280,9 +280,9 @@ void TTransQueue::UpdateTxBody(NIceDb::TNiceDb& db, ui64 txId, const TStringBuf& using Schema = TDataShard::Schema; auto it = TxsInFly.find(txId); - Y_ABORT_UNLESS(it != TxsInFly.end()); + Y_ENSURE(it != TxsInFly.end()); - Y_ABORT_UNLESS(!it->second->HasVolatilePrepareFlag(), "Unexpected UpdateTxBody for a volatile transaction"); + Y_ENSURE(!it->second->HasVolatilePrepareFlag(), "Unexpected UpdateTxBody for a volatile transaction"); db.Table<Schema::TxDetails>().Key(txId, Self->TabletID()) .Update<Schema::TxDetails::Body>(TString(txBody)); @@ -352,9 +352,9 @@ bool TTransQueue::LoadTxDetails(NIceDb::TNiceDb &db, using Schema = TDataShard::Schema; auto it = TxsInFly.find(txId); - Y_ABORT_UNLESS(it != TxsInFly.end()); + Y_ENSURE(it != TxsInFly.end()); - Y_ABORT_UNLESS(!it->second->HasVolatilePrepareFlag(), "Unexpected LoadTxDetails for a volatile transaction"); + Y_ENSURE(!it->second->HasVolatilePrepareFlag(), "Unexpected LoadTxDetails for a volatile transaction"); auto detailsRow = db.Table<Schema::TxDetails>().Key(txId, Self->TabletID()).Select(); auto artifactsRow = db.Table<Schema::TxArtifacts>().Key(txId).Select(); @@ -362,7 +362,7 @@ bool TTransQueue::LoadTxDetails(NIceDb::TNiceDb &db, if (!detailsRow.IsReady() || !artifactsRow.IsReady()) return false; - Y_VERIFY_S(!detailsRow.EndOfSet(), "cannot find details for tx=" << txId); + Y_ENSURE(!detailsRow.EndOfSet(), "cannot find details for tx=" << txId); txBody = detailsRow.GetValue<Schema::TxDetails::Body>(); target = detailsRow.GetValue<Schema::TxDetails::Source>(); @@ -382,7 +382,7 @@ bool TTransQueue::LoadTxDetails(NIceDb::TNiceDb &db, size_t elementSize = sizeof(TSysTables::TLocksTable::TPersistentLock); if ((data.size() % elementSize) != 0) { size_t badElementSize = elementSize + 8; - Y_VERIFY_S((data.size() % badElementSize) == 0, + Y_ENSURE((data.size() % badElementSize) == 0, "Unexpected Schema::TxArtifacts::Locks column size " << data.size() << " (expected divisible by " << elementSize << " or " << badElementSize << ")"); elementSize = badElementSize; @@ -411,7 +411,7 @@ bool TTransQueue::ClearTxDetails(NIceDb::TNiceDb& db, ui64 txId) { if (!txdRowset.IsReady()) return false; while (!txdRowset.EndOfSet()) { - Y_ABORT_UNLESS(txId == txdRowset.GetValue<Schema::TxDetails::TxId>()); + Y_ENSURE(txId == txdRowset.GetValue<Schema::TxDetails::TxId>()); ui64 origin = txdRowset.GetValue<Schema::TxDetails::Origin>(); db.Table<Schema::TxDetails>().Key(txId, origin).Delete(); if (!txdRowset.Next()) @@ -526,7 +526,7 @@ void TTransQueue::PlanTx(TOperation::TPtr op, op->SetStep(step); --PlanWaitingTxCount; } else { - Y_VERIFY_S(op->GetStep() == step, + Y_ENSURE(op->GetStep() == step, "Tx " << op->GetTxId() << " must not change step from " << op->GetStep() << " to " << step); } diff --git a/ydb/core/tx/datashard/datashard_user_db.cpp b/ydb/core/tx/datashard/datashard_user_db.cpp index c178ba6364..46d6919862 100644 --- a/ydb/core/tx/datashard/datashard_user_db.cpp +++ b/ydb/core/tx/datashard/datashard_user_db.cpp @@ -27,7 +27,7 @@ NTable::EReady TDataShardUserDb::SelectRow( const TMaybe<TRowVersion>& readVersion) { auto tid = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(tid != 0, "Unexpected SelectRow for an unknown table"); + Y_ENSURE(tid != 0, "Unexpected SelectRow for an unknown table"); SetPerformedUserReads(true); @@ -68,7 +68,7 @@ void TDataShardUserDb::UpsertRow( const TArrayRef<const NIceDb::TUpdateOp> ops) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected UpdateRow for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected UpdateRow for an unknown table"); // apply special columns if declared TUserTable::TSpecialUpdate specUpdates = Self.SpecialUpdates(Db, tableId); @@ -124,7 +124,7 @@ void TDataShardUserDb::ReplaceRow( const TArrayRef<const NIceDb::TUpdateOp> ops) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected ReplaceRow for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected ReplaceRow for an unknown table"); UpsertRowInt(NTable::ERowOp::Reset, tableId, localTableId, key, ops); @@ -137,7 +137,7 @@ void TDataShardUserDb::InsertRow( const TArrayRef<const NIceDb::TUpdateOp> ops) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected InsertRow for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected InsertRow for an unknown table"); if (RowExists(tableId, key)) throw TUniqueConstrainException(); @@ -153,7 +153,7 @@ void TDataShardUserDb::UpdateRow( const TArrayRef<const NIceDb::TUpdateOp> ops) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected UpdateRow for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected UpdateRow for an unknown table"); if (!RowExists(tableId, key)) return; @@ -168,7 +168,7 @@ void TDataShardUserDb::EraseRow( const TArrayRef<const TRawTypeValue> key) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected UpdateRow for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected UpdateRow for an unknown table"); UpsertRowInt(NTable::ERowOp::Erase, tableId, localTableId, key, {}); @@ -318,7 +318,7 @@ ui64 TDataShardUserDb::GetChangeGroup() { void TDataShardUserDb::CommitChanges(const TTableId& tableId, ui64 lockId, const TRowVersion& writeVersion) { auto localTid = Self.GetLocalTableId(tableId); - Y_VERIFY_S(localTid, "Unexpected failure to find table " << tableId << " in datashard " << Self.TabletID()); + Y_ENSURE(localTid, "Unexpected failure to find table " << tableId << " in datashard " << Self.TabletID()); if (!Db.HasOpenTx(localTid, lockId)) { if (Db.HasRemovedTx(localTid, lockId)) { @@ -540,7 +540,7 @@ private: void TDataShardUserDb::CheckWriteConflicts(const TTableId& tableId, TArrayRef<const TCell> keyCells) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected CheckWriteConflicts for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected CheckWriteConflicts for an unknown table"); // When there are uncommitted changes (write locks) we must find which // locks would break upon commit. @@ -567,9 +567,6 @@ void TDataShardUserDb::CheckWriteConflicts(const TTableId& tableId, TArrayRef<co } else if (auto* cached = Self.GetConflictsCache().GetTableCache(localTableId).FindUncommittedWrites(keyCells)) { for (ui64 txId : *cached) { BreakWriteConflict(txId); - if (NeedGlobalTxId) { - throw TNeedGlobalTxId(); - } } return; } else { @@ -587,10 +584,6 @@ void TDataShardUserDb::CheckWriteConflicts(const TTableId& tableId, TArrayRef<co nullptr, txObserver ); - if (NeedGlobalTxId) { - throw TNeedGlobalTxId(); - } - if (res.Ready == NTable::EReady::Page) { if (mustFindConflicts || LockTxId) { // We must gather all conflicts @@ -648,8 +641,7 @@ void TDataShardUserDb::BreakWriteConflict(ui64 txId) { // every sense, only persistent commit order is affected by // a dependency below. if (GlobalTxId == 0) { - NeedGlobalTxId = true; - return; + throw TNeedGlobalTxId(); } SetVolatileTxId(GlobalTxId); } @@ -680,10 +672,10 @@ TVector<ui64> TDataShardUserDb::GetVolatileCommitTxIds() const { ui64 TDataShardUserDb::GetWriteTxId(const TTableId& tableId) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected GetWriteTxId for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected GetWriteTxId for an unknown table"); if (VolatileTxId) { - Y_ABORT_UNLESS(!LockTxId); + Y_ENSURE(!LockTxId); if (VolatileCommitTxIds.insert(VolatileTxId).second) { // Update TxMap to include the new commit auto it = TxMaps.find(tableId.PathId); @@ -699,7 +691,7 @@ ui64 TDataShardUserDb::GetWriteTxId(const TTableId& tableId) { NTable::ITransactionMapPtr TDataShardUserDb::GetReadTxMap(const TTableId& tableId) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected GetReadTxMap for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected GetReadTxMap for an unknown table"); auto baseTxMap = Self.GetVolatileTxManager().GetTxMap(); @@ -738,7 +730,7 @@ NTable::ITransactionMapPtr TDataShardUserDb::GetReadTxMap(const TTableId& tableI NTable::ITransactionObserverPtr TDataShardUserDb::GetReadTxObserver(const TTableId& tableId) { auto localTableId = Self.GetLocalTableId(tableId); - Y_ABORT_UNLESS(localTableId != 0, "Unexpected GetReadTxObserver for an unknown table"); + Y_ENSURE(localTableId != 0, "Unexpected GetReadTxObserver for an unknown table"); bool needObserver = ( // We need observer when there are waiting changes in the tx map @@ -765,7 +757,7 @@ NTable::ITransactionObserverPtr TDataShardUserDb::GetReadTxObserver(const TTable } void TDataShardUserDb::AddReadConflict(ui64 txId) const { - Y_ABORT_UNLESS(LockTxId); + Y_ENSURE(LockTxId); // We have detected uncommitted changes in txId that could affect // our read result. We arrange a conflict that breaks our lock @@ -774,7 +766,7 @@ void TDataShardUserDb::AddReadConflict(ui64 txId) const { } void TDataShardUserDb::CheckReadConflict(const TRowVersion& rowVersion) const { - Y_ABORT_UNLESS(LockTxId); + Y_ENSURE(LockTxId); if (rowVersion > ReadVersion) { // We are reading from snapshot at ReadVersion and should not normally diff --git a/ydb/core/tx/datashard/datashard_user_db.h b/ydb/core/tx/datashard/datashard_user_db.h index a2daac48a0..64be2116c2 100644 --- a/ydb/core/tx/datashard/datashard_user_db.h +++ b/ydb/core/tx/datashard/datashard_user_db.h @@ -208,7 +208,6 @@ private: absl::flat_hash_set<ui64> CommittedLockChanges; absl::flat_hash_map<TPathId, TIntrusivePtr<NTable::TDynamicTransactionMap>> TxMaps; absl::flat_hash_map<TPathId, NTable::ITransactionObserverPtr> TxObservers; - bool NeedGlobalTxId = false; absl::flat_hash_set<ui64> VolatileCommitTxIds; YDB_ACCESSOR_DEF(absl::flat_hash_set<ui64>, VolatileDependencies); diff --git a/ydb/core/tx/datashard/datashard_user_table.cpp b/ydb/core/tx/datashard/datashard_user_table.cpp index 42f8ce5e1a..af04b863b6 100644 --- a/ydb/core/tx/datashard/datashard_user_table.cpp +++ b/ydb/core/tx/datashard/datashard_user_table.cpp @@ -25,7 +25,7 @@ TUserTable::TUserTable(ui32 localTid, const NKikimrSchemeOp::TTableDescription& TUserTable::TUserTable(const TUserTable& table, const NKikimrSchemeOp::TTableDescription& descr) : TUserTable(table) { - Y_VERIFY_S(Name == descr.GetName(), "Name: " << Name << " descr.Name: " << descr.GetName()); + Y_ENSURE(Name == descr.GetName(), "Name: " << Name << " descr.Name: " << descr.GetName()); ParseProto(descr); AlterSchema(); } @@ -64,7 +64,7 @@ bool TUserTable::ResetTableSchemaVersion() } void TUserTable::AddIndex(const NKikimrSchemeOp::TIndexDescription& indexDesc) { - Y_ABORT_UNLESS(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); + Y_ENSURE(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); const auto addIndexPathId = TPathId(indexDesc.GetPathOwnerId(), indexDesc.GetLocalPathId()); auto it = Indexes.lower_bound(addIndexPathId); @@ -103,7 +103,7 @@ void TUserTable::SwitchIndexState(const TPathId& indexPathId, TTableIndex::EStat } } - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } void TUserTable::DropIndex(const TPathId& indexPathId) { @@ -127,7 +127,7 @@ void TUserTable::DropIndex(const TPathId& indexPathId) { } } - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } bool TUserTable::HasAsyncIndexes() const { @@ -146,7 +146,7 @@ static bool IsJsonCdcStream(TUserTable::TCdcStream::EFormat format) { } void TUserTable::AddCdcStream(const NKikimrSchemeOp::TCdcStreamDescription& streamDesc) { - Y_ABORT_UNLESS(streamDesc.HasPathId()); + Y_ENSURE(streamDesc.HasPathId()); const auto streamPathId = TPathId::FromProto(streamDesc.GetPathId()); if (CdcStreams.contains(streamPathId)) { @@ -185,7 +185,7 @@ void TUserTable::SwitchCdcStreamState(const TPathId& streamPathId, TCdcStream::E return; } - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } void TUserTable::DropCdcStream(const TPathId& streamPathId) { @@ -211,7 +211,7 @@ void TUserTable::DropCdcStream(const TPathId& streamPathId) { return; } - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } bool TUserTable::HasCdcStreams() const { @@ -277,15 +277,15 @@ void TUserTable::ParseProto(const NKikimrSchemeOp::TTableDescription& descr) for (const auto& col : descr.GetDropColumns()) { ui32 colId = col.GetId(); auto it = Columns.find(colId); - Y_ABORT_UNLESS(it != Columns.end()); - Y_ABORT_UNLESS(!it->second.IsKey); + Y_ENSURE(it != Columns.end()); + Y_ENSURE(!it->second.IsKey); Columns.erase(it); } if (descr.KeyColumnIdsSize()) { - Y_ABORT_UNLESS(descr.KeyColumnIdsSize() >= KeyColumnIds.size()); + Y_ENSURE(descr.KeyColumnIdsSize() >= KeyColumnIds.size()); for (ui32 i = 0; i < KeyColumnIds.size(); ++i) { - Y_ABORT_UNLESS(KeyColumnIds[i] == descr.GetKeyColumnIds(i)); + Y_ENSURE(KeyColumnIds[i] == descr.GetKeyColumnIds(i)); } KeyColumnIds.clear(); @@ -296,16 +296,16 @@ void TUserTable::ParseProto(const NKikimrSchemeOp::TTableDescription& descr) KeyColumnIds.push_back(keyColId); TUserColumn * col = Columns.FindPtr(keyColId); - Y_ABORT_UNLESS(col); + Y_ENSURE(col); col->IsKey = true; KeyColumnTypes[i] = col->Type; } - Y_ABORT_UNLESS(KeyColumnIds.size() == KeyColumnTypes.size()); + Y_ENSURE(KeyColumnIds.size() == KeyColumnTypes.size()); } if (descr.HasPartitionRangeBegin()) { - Y_ABORT_UNLESS(descr.HasPartitionRangeEnd()); + Y_ENSURE(descr.HasPartitionRangeEnd()); Range = TSerializedTableRange(descr.GetPartitionRangeBegin(), descr.GetPartitionRangeEnd(), descr.GetPartitionRangeBeginIsInclusive(), @@ -320,13 +320,13 @@ void TUserTable::ParseProto(const NKikimrSchemeOp::TTableDescription& descr) CheckSpecialColumns(); for (const auto& indexDesc : descr.GetTableIndexes()) { - Y_ABORT_UNLESS(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); + Y_ENSURE(indexDesc.HasPathOwnerId() && indexDesc.HasLocalPathId()); Indexes.emplace(TPathId(indexDesc.GetPathOwnerId(), indexDesc.GetLocalPathId()), TTableIndex(indexDesc, Columns)); AsyncIndexCount += ui32(indexDesc.GetType() == TTableIndex::EType::EIndexTypeGlobalAsync); } for (const auto& streamDesc : descr.GetCdcStreams()) { - Y_ABORT_UNLESS(streamDesc.HasPathId()); + Y_ENSURE(streamDesc.HasPathId()); CdcStreams.emplace(TPathId::FromProto(streamDesc.GetPathId()), TCdcStream(streamDesc)); JsonCdcStreamCount += ui32(IsJsonCdcStream(streamDesc.GetFormat())); } @@ -426,7 +426,7 @@ void TUserTable::DoApplyCreate( { const ui32 tid = shadow ? ShadowTid : LocalTid; - Y_ABORT_UNLESS(tid != 0 && tid != Max<ui32>(), "Creating table %s with bad id %" PRIu32, tableName.c_str(), tid); + Y_ENSURE(tid != 0 && tid != Max<ui32>(), "Creating table " << tableName << " with bad id " << tid); auto &alter = txc.DB.Alter(); alter.AddTable(tableName, tid); @@ -565,9 +565,9 @@ void TUserTable::ApplyAlter( for (const auto& col : delta.GetDropColumns()) { ui32 colId = col.GetId(); const TUserTable::TUserColumn * oldCol = oldTable.Columns.FindPtr(colId); - Y_ABORT_UNLESS(oldCol); - Y_ABORT_UNLESS(oldCol->Name == col.GetName()); - Y_ABORT_UNLESS(!Columns.contains(colId)); + Y_ENSURE(oldCol); + Y_ENSURE(oldCol->Name == col.GetName()); + Y_ENSURE(!Columns.contains(colId)); for (ui32 tid : tids) { alter.DropColumn(tid, colId); diff --git a/ydb/core/tx/datashard/datashard_user_table.h b/ydb/core/tx/datashard/datashard_user_table.h index 18c01a1de8..7066a3a748 100644 --- a/ydb/core/tx/datashard/datashard_user_table.h +++ b/ydb/core/tx/datashard/datashard_user_table.h @@ -210,7 +210,7 @@ struct TUserTable : public TThrRefBase { return ECodec::LZ4; // keep no default } - Y_ABORT("unexpected"); + Y_ENSURE(false, "unexpected"); } static ECache ExtractDbCache(const NKikimrSchemeOp::TFamilyDescription& family) { @@ -229,7 +229,7 @@ struct TUserTable : public TThrRefBase { return ECache::Ever; // keep no default } - Y_ABORT("unexpected"); + Y_ENSURE(false, "unexpected"); } }; @@ -281,7 +281,7 @@ struct TUserTable : public TThrRefBase { columnIds.reserve(columnNames.size()); for (const auto& columnName : columnNames) { auto it = nameToId.find(columnName); - Y_ABORT_UNLESS(it != nameToId.end()); + Y_ENSURE(it != nameToId.end()); columnIds.push_back(it->second); } }; @@ -491,7 +491,7 @@ struct TUserTable : public TThrRefBase { void GetSchema(NKikimrSchemeOp::TTableDescription& description) const { bool ok = description.ParseFromArray(Schema.data(), Schema.size()); - Y_ABORT_UNLESS(ok); + Y_ENSURE(ok); } void SetSchema(const NKikimrSchemeOp::TTableDescription& description) { diff --git a/ydb/core/tx/datashard/datashard_ut_change_exchange.cpp b/ydb/core/tx/datashard/datashard_ut_change_exchange.cpp index d294dac0d0..c591d7c9f2 100644 --- a/ydb/core/tx/datashard/datashard_ut_change_exchange.cpp +++ b/ydb/core/tx/datashard/datashard_ut_change_exchange.cpp @@ -2168,7 +2168,7 @@ Y_UNIT_TEST_SUITE(Cdc) { TVector<NJson::TJsonValue> values; for (const auto& pr : result) { bool ok = NJson::ReadJsonTree(pr.second, &values.emplace_back()); - Y_ABORT_UNLESS(ok); + Y_ENSURE(ok); } return values; } @@ -2719,7 +2719,7 @@ Y_UNIT_TEST_SUITE(Cdc) { case TSchemeBoardEvents::EvUpdate: if (auto* msg = ev->Get<NSchemeBoard::NInternalEvents::TEvUpdate>()) { NKikimrScheme::TEvDescribeSchemeResult desc; - Y_ABORT_UNLESS(ParseFromStringNoSizeLimit(desc, *msg->GetRecord().GetDescribeSchemeResultSerialized().begin())); + Y_ENSURE(ParseFromStringNoSizeLimit(desc, *msg->GetRecord().GetDescribeSchemeResultSerialized().begin())); if (desc.GetPath() == "/Root/Table/Stream" && desc.GetPathDescription().GetSelf().GetCreateFinished()) { delayed.emplace_back(ev.Release()); return TTestActorRuntime::EEventAction::DROP; diff --git a/ydb/core/tx/datashard/datashard_ut_common_kqp.h b/ydb/core/tx/datashard/datashard_ut_common_kqp.h index 05a6d01c1f..2702db403e 100644 --- a/ydb/core/tx/datashard/datashard_ut_common_kqp.h +++ b/ydb/core/tx/datashard/datashard_ut_common_kqp.h @@ -208,19 +208,19 @@ namespace NKqpHelpers { } inline TString KqpSimpleContinue(TTestActorRuntime& runtime, const TString& sessionId, const TString& txId, const TString& query) { - Y_ABORT_UNLESS(!txId.empty(), "continue on empty transaction"); + Y_ENSURE(!txId.empty(), "continue on empty transaction"); auto response = AwaitResponse(runtime, SendRequest(runtime, MakeSimpleRequestRPC(query, sessionId, txId, false /* commitTx */))); if (response.operation().status() != Ydb::StatusIds::SUCCESS) { return TStringBuilder() << "ERROR: " << response.operation().status(); } Ydb::Table::ExecuteQueryResult result; response.operation().result().UnpackTo(&result); - Y_ABORT_UNLESS(result.tx_meta().id() == txId); + Y_ENSURE(result.tx_meta().id() == txId); return FormatResult(result); } inline auto KqpSimpleSendCommit(TTestActorRuntime& runtime, const TString& sessionId, const TString& txId, const TString& query) { - Y_ABORT_UNLESS(!txId.empty(), "commit on empty transaction"); + Y_ENSURE(!txId.empty(), "commit on empty transaction"); return SendRequest(runtime, MakeSimpleRequestRPC(query, sessionId, txId, true /* commitTx */)); } @@ -231,7 +231,7 @@ namespace NKqpHelpers { } Ydb::Table::ExecuteQueryResult result; response.operation().result().UnpackTo(&result); - Y_ABORT_UNLESS(result.tx_meta().id().empty(), "must be empty transaction"); + Y_ENSURE(result.tx_meta().id().empty(), "must be empty transaction"); return FormatResult(result); } diff --git a/ydb/core/tx/datashard/datashard_ut_incremental_restore_scan.cpp b/ydb/core/tx/datashard/datashard_ut_incremental_restore_scan.cpp index fc946c48e5..f18aee5d34 100644 --- a/ydb/core/tx/datashard/datashard_ut_incremental_restore_scan.cpp +++ b/ydb/core/tx/datashard/datashard_ut_incremental_restore_scan.cpp @@ -75,7 +75,7 @@ public: STATEFN(Serve) { switch (ev->GetTypeRewrite()) { hFunc(TEvExec, Handle); - default: Y_ABORT("unexpected"); + default: Y_ENSURE(false, "unexpected"); } } }; diff --git a/ydb/core/tx/datashard/datashard_ut_minstep.cpp b/ydb/core/tx/datashard/datashard_ut_minstep.cpp index 05ea9b267c..a9ce18b6e5 100644 --- a/ydb/core/tx/datashard/datashard_ut_minstep.cpp +++ b/ydb/core/tx/datashard/datashard_ut_minstep.cpp @@ -61,7 +61,7 @@ TAutoPtr<IEventHandle> EjectDataPropose(TServer::TPtr server, ui64 dataShard) server->GetRuntime()->DispatchEvents(options); runtime.SetObserverFunc(prevObserver); - Y_ABORT_UNLESS(proposeEvent); + Y_ENSURE(proposeEvent); return proposeEvent; } diff --git a/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp b/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp index 33ffaa6a76..19a945d3ca 100644 --- a/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp +++ b/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp @@ -736,7 +736,7 @@ struct TTestHelper { std::vector<ui32> columnIds(columnCount); std::iota(columnIds.begin(), columnIds.end(), 1); - Y_ABORT_UNLESS(values.size() == columnCount); + Y_ENSURE(values.size() == columnCount); TVector<TCell> cells; for (ui32 col = 0; col < columnCount; ++col) diff --git a/ydb/core/tx/datashard/datashard_ut_read_table.h b/ydb/core/tx/datashard/datashard_ut_read_table.h index 1733b5bb60..035cd4b3c4 100644 --- a/ydb/core/tx/datashard/datashard_ut_read_table.h +++ b/ydb/core/tx/datashard/datashard_ut_read_table.h @@ -73,7 +73,7 @@ namespace NDataShardReadTableTest { case TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecResponseData: { const auto rsData = msg->Record.GetSerializedReadTableResponse(); Ydb::ResultSet rsParsed; - Y_ABORT_UNLESS(rsParsed.ParseFromString(rsData)); + Y_ENSURE(rsParsed.ParseFromString(rsData)); NYdb::TResultSet rs(rsParsed); auto& columns = rs.GetColumnsMeta(); NYdb::TResultSetParser parser(rs); @@ -160,7 +160,7 @@ namespace NDataShardReadTableTest { break; default: - Y_ABORT("Unhandled"); + Y_ENSURE(false, "Unhandled"); } } @@ -183,7 +183,7 @@ namespace NDataShardReadTableTest { break; default: - Y_ABORT("Unhandled"); + Y_ENSURE(false, "Unhandled"); } } diff --git a/ydb/core/tx/datashard/datashard_ut_rs.cpp b/ydb/core/tx/datashard/datashard_ut_rs.cpp index e7d0c3765e..97de3a331d 100644 --- a/ydb/core/tx/datashard/datashard_ut_rs.cpp +++ b/ydb/core/tx/datashard/datashard_ut_rs.cpp @@ -380,7 +380,7 @@ Y_UNIT_TEST_SUITE(TDataShardRSTest) { break; } NKikimrTx::TReadSetData genericData; - Y_ABORT_UNLESS(genericData.ParseFromString(msg->Record.GetReadSet())); + Y_ENSURE(genericData.ParseFromString(msg->Record.GetReadSet())); Cerr << "... generic readset: " << genericData.DebugString() << Endl; UNIT_ASSERT(genericData.HasDecision()); UNIT_ASSERT(genericData.GetDecision() == NKikimrTx::TReadSetData::DECISION_COMMIT); @@ -447,7 +447,7 @@ Y_UNIT_TEST_SUITE(TDataShardRSTest) { break; } NKikimrTx::TReadSetData genericData; - Y_ABORT_UNLESS(genericData.ParseFromString(msg->Record.GetReadSet())); + Y_ENSURE(genericData.ParseFromString(msg->Record.GetReadSet())); Cerr << "... generic readset: " << genericData.DebugString() << Endl; UNIT_ASSERT(genericData.HasDecision()); UNIT_ASSERT(genericData.GetDecision() == NKikimrTx::TReadSetData::DECISION_ABORT); diff --git a/ydb/core/tx/datashard/datashard_ut_snapshot.cpp b/ydb/core/tx/datashard/datashard_ut_snapshot.cpp index 22ef09376a..0fcebdd5bd 100644 --- a/ydb/core/tx/datashard/datashard_ut_snapshot.cpp +++ b/ydb/core/tx/datashard/datashard_ut_snapshot.cpp @@ -1198,7 +1198,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { Cerr << record.DebugString() << Endl; if (record.GetTxKind() == NKikimrTxDataShard::TX_KIND_DATA) { NKikimrTxDataShard::TDataTransaction tx; - Y_ABORT_UNLESS(tx.ParseFromString(record.GetTxBody())); + Y_ENSURE(tx.ParseFromString(record.GetTxBody())); Cerr << "TxBody (original):" << Endl; Cerr << tx.DebugString() << Endl; if (tx.HasMiniKQL()) { @@ -1213,7 +1213,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { if (InjectClearTasks && tx.GetKqpTransaction().TasksSize() > 0) { tx.MutableKqpTransaction()->ClearTasks(); TString txBody; - Y_ABORT_UNLESS(tx.SerializeToString(&txBody)); + Y_ENSURE(tx.SerializeToString(&txBody)); record.SetTxBody(txBody); Cerr << "TxBody: cleared Tasks" << Endl; } @@ -1238,7 +1238,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { protoLocks->AddReceivingShards(shard); } TString txBody; - Y_ABORT_UNLESS(tx.SerializeToString(&txBody)); + Y_ENSURE(tx.SerializeToString(&txBody)); record.SetTxBody(txBody); Cerr << "TxBody: injected Locks" << Endl; } @@ -1263,7 +1263,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { tx.SetLockNodeId(Inject.LockNodeId); } TString txBody; - Y_ABORT_UNLESS(tx.SerializeToString(&txBody)); + Y_ENSURE(tx.SerializeToString(&txBody)); record.SetTxBody(txBody); Cerr << "TxBody: injected LockId" << Endl; } @@ -1446,8 +1446,8 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { // We should have been acquiring locks TLockSnapshot snapshot = observer.Last; - Y_ABORT_UNLESS(snapshot.LockId != 0); - Y_ABORT_UNLESS(snapshot.MvccSnapshot); + Y_ENSURE(snapshot.LockId != 0); + Y_ENSURE(snapshot.MvccSnapshot); // Perform an immediate write, pretending it happens as part of the above snapshot tx observer.Inject = snapshot; @@ -1543,8 +1543,8 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { // We should have been acquiring locks TLockSnapshot snapshot = observer.Last; - Y_ABORT_UNLESS(snapshot.LockId != 0); - Y_ABORT_UNLESS(snapshot.MvccSnapshot); + Y_ENSURE(snapshot.LockId != 0); + Y_ENSURE(snapshot.MvccSnapshot); // Perform an immediate write, pretending it happens as part of the above snapshot tx // We expect read lock to be upgraded to write lock and become persistent diff --git a/ydb/core/tx/datashard/datashard_ut_volatile.cpp b/ydb/core/tx/datashard/datashard_ut_volatile.cpp index 0af89d12d6..7845fba17f 100644 --- a/ydb/core/tx/datashard/datashard_ut_volatile.cpp +++ b/ydb/core/tx/datashard/datashard_ut_volatile.cpp @@ -2560,7 +2560,7 @@ Y_UNIT_TEST_SUITE(DataShardVolatile) { NKikimrTxDataShard::TDataTransaction tx; bool ok = tx.ParseFromString(msg->Record.GetTxBody()); - Y_ABORT_UNLESS(ok, "Failed to parse data transaction"); + Y_ENSURE(ok, "Failed to parse data transaction"); if (!tx.HasKqpTransaction()) { Cerr << "... skipping TEvProposeTransaction without kqp transaction" << Endl; return; @@ -2597,7 +2597,7 @@ Y_UNIT_TEST_SUITE(DataShardVolatile) { kqpLocks->SetArbiterShard(ArbiterShard); ok = tx.SerializeToString(msg->Record.MutableTxBody()); - Y_ABORT_UNLESS(ok, "Failed to serialize data transaction"); + Y_ENSURE(ok, "Failed to serialize data transaction"); ++Modified; } @@ -2683,7 +2683,7 @@ Y_UNIT_TEST_SUITE(DataShardVolatile) { NKikimrTxDataShard::TDataTransaction tx; bool ok = tx.ParseFromString(msg->Record.GetTxBody()); - Y_ABORT_UNLESS(ok, "Failed to parse data transaction"); + Y_ENSURE(ok, "Failed to parse data transaction"); if (!tx.HasKqpTransaction()) { Cerr << "... skipping TEvProposeTransaction without kqp transaction" << Endl; return; @@ -2716,7 +2716,7 @@ Y_UNIT_TEST_SUITE(DataShardVolatile) { kqpLock->SetPathId(TableId.PathId.LocalPathId); ok = tx.SerializeToString(msg->Record.MutableTxBody()); - Y_ABORT_UNLESS(ok, "Failed to serialize data transaction"); + Y_ENSURE(ok, "Failed to serialize data transaction"); ++Modified; } diff --git a/ydb/core/tx/datashard/datashard_write_operation.cpp b/ydb/core/tx/datashard/datashard_write_operation.cpp index e433b50fc3..5ee12be9ef 100644 --- a/ydb/core/tx/datashard/datashard_write_operation.cpp +++ b/ydb/core/tx/datashard/datashard_write_operation.cpp @@ -205,7 +205,7 @@ ui32 TValidatedWriteTx::ExtractKeys(const NTable::TScheme& scheme, bool allowErr return 0; } } else { - Y_ABORT_UNLESS(isValid, "Validation errors: %s", ErrStr.data()); + Y_ENSURE(isValid, "Validation errors: " << ErrStr); } return KeysCount(); @@ -263,9 +263,9 @@ void TValidatedWriteTx::ComputeTxSize() { TWriteOperation* TWriteOperation::CastWriteOperation(TOperation::TPtr op) { - Y_ABORT_UNLESS(op->IsWriteTx()); + Y_ENSURE(op->IsWriteTx()); TWriteOperation* writeOp = dynamic_cast<TWriteOperation*>(op.Get()); - Y_ABORT_UNLESS(writeOp); + Y_ENSURE(writeOp); return writeOp; } @@ -275,7 +275,7 @@ TWriteOperation* TWriteOperation::TryCastWriteOperation(TOperation::TPtr op) return nullptr; TWriteOperation* writeOp = dynamic_cast<TWriteOperation*>(op.Get()); - Y_ABORT_UNLESS(writeOp); + Y_ENSURE(writeOp); return writeOp; } @@ -316,8 +316,8 @@ TWriteOperation::~TWriteOperation() void TWriteOperation::FillTxData(TValidatedWriteTx::TPtr writeTx) { - Y_ABORT_UNLESS(!WriteTx); - Y_ABORT_UNLESS(!WriteRequest || HasVolatilePrepareFlag()); + Y_ENSURE(!WriteTx); + Y_ENSURE(!WriteRequest || HasVolatilePrepareFlag()); Target = writeTx->GetSource(); WriteTx = writeTx; @@ -327,8 +327,8 @@ void TWriteOperation::FillTxData(TDataShard* self, const TActorId& target, const { UntrackMemory(); - Y_ABORT_UNLESS(!WriteTx); - Y_ABORT_UNLESS(!WriteRequest); + Y_ENSURE(!WriteTx); + Y_ENSURE(!WriteRequest); Target = target; SetTxBody(txBody); @@ -338,9 +338,9 @@ void TWriteOperation::FillTxData(TDataShard* self, const TActorId& target, const LocksCache().Locks[lock.LockId] = lock; } ArtifactFlags = artifactFlags; - Y_ABORT_UNLESS(!WriteTx); + Y_ENSURE(!WriteTx); BuildWriteTx(self); - Y_ABORT_UNLESS(WriteTx->Ready()); + Y_ENSURE(WriteTx->Ready()); TrackMemory(); } @@ -349,22 +349,22 @@ void TWriteOperation::FillVolatileTxData(TDataShard* self) { UntrackMemory(); - Y_ABORT_UNLESS(!WriteTx); - Y_ABORT_UNLESS(WriteRequest); + Y_ENSURE(!WriteTx); + Y_ENSURE(WriteRequest); BuildWriteTx(self); - Y_ABORT_UNLESS(WriteTx->Ready()); + Y_ENSURE(WriteTx->Ready()); TrackMemory(); } TString TWriteOperation::GetTxBody() const { - Y_ABORT_UNLESS(WriteRequest); + Y_ENSURE(WriteRequest); TAllocChunkSerializer serializer; bool success = WriteRequest->SerializeToArcadiaStream(&serializer); - Y_ABORT_UNLESS(success); + Y_ENSURE(success); TEventSerializationInfo serializationInfo = WriteRequest->CreateSerializationInfo(); NKikimrTxDataShard::TSerializedEvent proto; @@ -373,23 +373,23 @@ TString TWriteOperation::GetTxBody() const { TString str; success = proto.SerializeToString(&str); - Y_ABORT_UNLESS(success); + Y_ENSURE(success); return str; } void TWriteOperation::SetTxBody(const TString& txBody) { - Y_ABORT_UNLESS(!WriteRequest); + Y_ENSURE(!WriteRequest); NKikimrTxDataShard::TSerializedEvent proto; const bool success = proto.ParseFromString(txBody); - Y_ABORT_UNLESS(success); + Y_ENSURE(success); TEventSerializationInfo serializationInfo; serializationInfo.IsExtendedFormat = proto.GetIsExtendedFormat(); TEventSerializedData buffer(proto.GetEventData(), std::move(serializationInfo)); NKikimr::NEvents::TDataEvents::TEvWrite* writeRequest = static_cast<NKikimr::NEvents::TDataEvents::TEvWrite*>(NKikimr::NEvents::TDataEvents::TEvWrite::Load(&buffer)); - Y_ABORT_UNLESS(writeRequest); + Y_ENSURE(writeRequest); WriteRequest.reset(writeRequest); } @@ -403,7 +403,7 @@ void TWriteOperation::ClearTxBody() { TValidatedWriteTx::TPtr TWriteOperation::BuildWriteTx(TDataShard* self) { if (!WriteTx) { - Y_ABORT_UNLESS(WriteRequest); + Y_ENSURE(WriteRequest); WriteTx = std::make_shared<TValidatedWriteTx>(self, GetGlobalTxId(), GetReceivedAt(), *WriteRequest, IsMvccSnapshotRead()); } return WriteTx; @@ -500,7 +500,7 @@ ERestoreDataStatus TWriteOperation::RestoreTxData(TDataShard* self, NTable::TDat SetTxBody(txBody); } else { - Y_ABORT_UNLESS(WriteRequest); + Y_ENSURE(WriteRequest); } TrackMemory(); @@ -528,24 +528,24 @@ ERestoreDataStatus TWriteOperation::RestoreTxData(TDataShard* self, NTable::TDat void TWriteOperation::BuildExecutionPlan(bool loaded) { - Y_ABORT_UNLESS(GetExecutionPlan().empty()); + Y_ENSURE(GetExecutionPlan().empty()); TVector<EExecutionUnitKind> plan; if (IsImmediate()) { - Y_ABORT_UNLESS(!loaded); + Y_ENSURE(!loaded); plan.push_back(EExecutionUnitKind::CheckWrite); plan.push_back(EExecutionUnitKind::BuildAndWaitDependencies); plan.push_back(EExecutionUnitKind::ExecuteWrite); plan.push_back(EExecutionUnitKind::FinishProposeWrite); plan.push_back(EExecutionUnitKind::CompletedOperations); } else if (HasVolatilePrepareFlag()) { - Y_ABORT_UNLESS(!loaded); + Y_ENSURE(!loaded); plan.push_back(EExecutionUnitKind::CheckWrite); plan.push_back(EExecutionUnitKind::StoreWrite); // note: stores in memory plan.push_back(EExecutionUnitKind::FinishProposeWrite); - Y_ABORT_UNLESS(!GetStep()); + Y_ENSURE(!GetStep()); plan.push_back(EExecutionUnitKind::WaitForPlan); plan.push_back(EExecutionUnitKind::PlanQueue); plan.push_back(EExecutionUnitKind::LoadWriteDetails); // note: reloads from memory diff --git a/ydb/core/tx/datashard/datashard_write_operation.h b/ydb/core/tx/datashard/datashard_write_operation.h index 9c145e262f..17498858ee 100644 --- a/ydb/core/tx/datashard/datashard_write_operation.h +++ b/ydb/core/tx/datashard/datashard_write_operation.h @@ -207,7 +207,7 @@ public: ui64 GetMemoryConsumption() const; ui64 GetRequiredMemory() const { - Y_ABORT_UNLESS(!GetTxCacheUsage() || !IsTxDataReleased()); + Y_ENSURE(!GetTxCacheUsage() || !IsTxDataReleased()); ui64 requiredMem = GetTxCacheUsage() + GetReleasedTxDataSize(); if (!requiredMem) requiredMem = GetMemoryConsumption(); @@ -226,7 +226,7 @@ public: const NMiniKQL::IEngineFlat::TValidationInfo& GetKeysInfo() const override { if (WriteTx) { - Y_ABORT_UNLESS(WriteTx->TxInfo().Loaded); + Y_ENSURE(WriteTx->TxInfo().Loaded); return WriteTx->TxInfo(); } // For scheme tx global reader and writer flags should diff --git a/ydb/core/tx/datashard/direct_tx_unit.cpp b/ydb/core/tx/datashard/direct_tx_unit.cpp index b47187c5da..5a6c78cfcd 100644 --- a/ydb/core/tx/datashard/direct_tx_unit.cpp +++ b/ydb/core/tx/datashard/direct_tx_unit.cpp @@ -38,16 +38,16 @@ public: TSetupSysLocks guardLocks(op, DataShard, &locksDb); TDirectTransaction* tx = dynamic_cast<TDirectTransaction*>(op.Get()); - Y_ABORT_UNLESS(tx != nullptr); + Y_ENSURE(tx != nullptr); try { if (!tx->Execute(&DataShard, txc)) { return EExecutionStatus::Restart; } } catch (const TNeedGlobalTxId&) { - Y_VERIFY_S(op->GetGlobalTxId() == 0, + Y_ENSURE(op->GetGlobalTxId() == 0, "Unexpected TNeedGlobalTxId exception for direct operation with TxId# " << op->GetGlobalTxId()); - Y_VERIFY_S(op->IsImmediate(), + Y_ENSURE(op->IsImmediate(), "Unexpected TNeedGlobalTxId exception for a non-immediate operation with TxId# " << op->GetTxId()); ctx.Send(MakeTxProxyID(), @@ -83,7 +83,7 @@ public: DataShard.EmitHeartbeats(); TDirectTransaction* tx = dynamic_cast<TDirectTransaction*>(op.Get()); - Y_ABORT_UNLESS(tx != nullptr); + Y_ENSURE(tx != nullptr); tx->SendResult(&DataShard, ctx); } diff --git a/ydb/core/tx/datashard/drop_cdc_stream_unit.cpp b/ydb/core/tx/datashard/drop_cdc_stream_unit.cpp index 0f484c4928..c07ec5bb17 100644 --- a/ydb/core/tx/datashard/drop_cdc_stream_unit.cpp +++ b/ydb/core/tx/datashard/drop_cdc_stream_unit.cpp @@ -20,10 +20,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasDropCdcStreamNotice()) { @@ -33,12 +33,12 @@ public: const auto& params = schemeTx.GetDropCdcStreamNotice(); const auto pathId = TPathId::FromProto(params.GetPathId()); - Y_ABORT_UNLESS(pathId.OwnerId == DataShard.GetPathOwnerId()); + Y_ENSURE(pathId.OwnerId == DataShard.GetPathOwnerId()); const auto streamPathId = TPathId::FromProto(params.GetStreamPathId()); const auto version = params.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); auto tableInfo = DataShard.AlterTableDropCdcStream(ctx, txc, pathId, version, streamPathId); TDataShardLocksDb locksDb(DataShard, txc); @@ -50,7 +50,7 @@ public: if (params.HasDropSnapshot()) { const auto& snapshot = params.GetDropSnapshot(); - Y_ABORT_UNLESS(snapshot.GetStep() != 0); + Y_ENSURE(snapshot.GetStep() != 0); const TSnapshotKey key(pathId, snapshot.GetStep(), snapshot.GetTxId()); DataShard.GetSnapshotManager().RemoveSnapshot(txc.DB, key); diff --git a/ydb/core/tx/datashard/drop_index_notice_unit.cpp b/ydb/core/tx/datashard/drop_index_notice_unit.cpp index 62c8a950e7..b6df2b5cd0 100644 --- a/ydb/core/tx/datashard/drop_index_notice_unit.cpp +++ b/ydb/core/tx/datashard/drop_index_notice_unit.cpp @@ -19,10 +19,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasDropIndexNotice()) { @@ -32,17 +32,17 @@ public: const auto& params = schemeTx.GetDropIndexNotice(); const auto pathId = TPathId::FromProto(params.GetPathId()); - Y_ABORT_UNLESS(pathId.OwnerId == DataShard.GetPathOwnerId()); + Y_ENSURE(pathId.OwnerId == DataShard.GetPathOwnerId()); const auto version = params.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); TUserTable::TPtr tableInfo; if (params.HasIndexPathId()) { const auto indexPathId = TPathId::FromProto(params.GetIndexPathId()); const auto& userTables = DataShard.GetUserTables(); - Y_ABORT_UNLESS(userTables.contains(pathId.LocalPathId)); + Y_ENSURE(userTables.contains(pathId.LocalPathId)); userTables.at(pathId.LocalPathId)->ForAsyncIndex(indexPathId, [&](const auto&) { RemoveSender.Reset(new TEvChangeExchange::TEvRemoveSender(indexPathId)); }); @@ -52,7 +52,7 @@ public: tableInfo = DataShard.AlterTableSchemaVersion(ctx, txc, pathId, version); } - Y_ABORT_UNLESS(tableInfo); + Y_ENSURE(tableInfo); TDataShardLocksDb locksDb(DataShard, txc); DataShard.AddUserTable(pathId, tableInfo, &locksDb); diff --git a/ydb/core/tx/datashard/drop_persistent_snapshot_unit.cpp b/ydb/core/tx/datashard/drop_persistent_snapshot_unit.cpp index 11aaa86e69..6a5d936727 100644 --- a/ydb/core/tx/datashard/drop_persistent_snapshot_unit.cpp +++ b/ydb/core/tx/datashard/drop_persistent_snapshot_unit.cpp @@ -16,10 +16,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext&) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasDropPersistentSnapshot()) { diff --git a/ydb/core/tx/datashard/drop_table_unit.cpp b/ydb/core/tx/datashard/drop_table_unit.cpp index 552c4574ba..386b0d727f 100644 --- a/ydb/core/tx/datashard/drop_table_unit.cpp +++ b/ydb/core/tx/datashard/drop_table_unit.cpp @@ -35,7 +35,7 @@ TDropTableUnit::~TDropTableUnit() bool TDropTableUnit::IsReadyToExecute(TOperation::TPtr op) const { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasDropTable()) @@ -52,7 +52,7 @@ bool TDropTableUnit::IsReadyToExecute(TOperation::TPtr op) const } // We shouldn't have any normal dependencies - Y_ABORT_UNLESS(op->GetDependencies().empty()); + Y_ENSURE(op->GetDependencies().empty()); return op->GetSpecialDependencies().empty(); } @@ -62,7 +62,7 @@ EExecutionStatus TDropTableUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasDropTable()) @@ -73,12 +73,12 @@ EExecutionStatus TDropTableUnit::Execute(TOperation::TPtr op, ui64 tableId = schemeTx.GetDropTable().GetId_Deprecated(); if (schemeTx.GetDropTable().HasPathId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == schemeTx.GetDropTable().GetPathId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == schemeTx.GetDropTable().GetPathId().GetOwnerId()); tableId = schemeTx.GetDropTable().GetPathId().GetLocalId(); } auto it = DataShard.GetUserTables().find(tableId); - Y_ABORT_UNLESS(it != DataShard.GetUserTables().end()); + Y_ENSURE(it != DataShard.GetUserTables().end()); { it->second->ForEachAsyncIndex([&](const auto& indexPathId, const auto&) { RemoveSenders.emplace_back(new TEvChangeExchange::TEvRemoveSender(indexPathId)); diff --git a/ydb/core/tx/datashard/drop_volatile_snapshot_unit.cpp b/ydb/core/tx/datashard/drop_volatile_snapshot_unit.cpp index 0bc0133de2..2f929f4622 100644 --- a/ydb/core/tx/datashard/drop_volatile_snapshot_unit.cpp +++ b/ydb/core/tx/datashard/drop_volatile_snapshot_unit.cpp @@ -16,10 +16,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext&) override { - Y_ABORT_UNLESS(op->IsSnapshotTx()); + Y_ENSURE(op->IsSnapshotTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); const auto& record = tx->GetSnapshotTx(); if (!record.HasDropVolatileSnapshot()) { diff --git a/ydb/core/tx/datashard/erase_rows_condition.cpp b/ydb/core/tx/datashard/erase_rows_condition.cpp index 046961c7e3..f191ca90a1 100644 --- a/ydb/core/tx/datashard/erase_rows_condition.cpp +++ b/ydb/core/tx/datashard/erase_rows_condition.cpp @@ -107,7 +107,7 @@ class TExpirationCondition: public IEraseRowsCondition { case NScheme::NTypeIds::Pg: return GetWallClockPg(); default: - Y_ABORT("Unreachable"); + Y_ENSURE(false, "Unreachable"); } } @@ -138,7 +138,7 @@ class TExpirationCondition: public IEraseRowsCondition { return false; } default: - Y_ABORT("Unreachable"); + Y_ENSURE(false, "Unreachable"); } } @@ -157,7 +157,7 @@ class TExpirationCondition: public IEraseRowsCondition { case NScheme::NTypeIds::Timestamp64: return TInstant::MicroSeconds(value) <= WallClockInstant; default: - Y_ABORT("Unreachable"); + Y_ENSURE(false, "Unreachable"); } } @@ -175,7 +175,7 @@ class TExpirationCondition: public IEraseRowsCondition { return result <= 0; } default: - Y_ABORT("Unreachable"); + Y_ENSURE(false, "Unreachable"); } } else { return false; @@ -206,17 +206,17 @@ public: void Prepare(TIntrusiveConstPtr<NTable::TRowScheme> scheme, TMaybe<NTable::TPos> remapPos) override { const auto* columnInfo = scheme->ColInfo(ColumnId); - Y_ABORT_UNLESS(columnInfo); + Y_ENSURE(columnInfo); Pos = remapPos.GetOrElse(columnInfo->Pos); - Y_ABORT_UNLESS(Pos < scheme->Tags().size()); + Y_ENSURE(Pos < scheme->Tags().size()); Type = columnInfo->TypeInfo; } bool Check(const NTable::TRowState& row) const override { - Y_ABORT_UNLESS(Pos != Max<NTable::TPos>()); - Y_ABORT_UNLESS(Pos < row.Size()); + Y_ENSURE(Pos != Max<NTable::TPos>()); + Y_ENSURE(Pos < row.Size()); const auto& cell = row.Get(Pos); if (cell.IsNull()) { diff --git a/ydb/core/tx/datashard/execute_commit_writes_tx_unit.cpp b/ydb/core/tx/datashard/execute_commit_writes_tx_unit.cpp index 635ad2f927..96bb023da3 100644 --- a/ydb/core/tx/datashard/execute_commit_writes_tx_unit.cpp +++ b/ydb/core/tx/datashard/execute_commit_writes_tx_unit.cpp @@ -25,10 +25,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsCommitWritesTx()); + Y_ENSURE(op->IsCommitWritesTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); TDataShardLocksDb locksDb(DataShard, txc); TSetupSysLocks guardLocks(op, DataShard, &locksDb); diff --git a/ydb/core/tx/datashard/execute_data_tx_unit.cpp b/ydb/core/tx/datashard/execute_data_tx_unit.cpp index 310bf3c539..53ed1eb779 100644 --- a/ydb/core/tx/datashard/execute_data_tx_unit.cpp +++ b/ydb/core/tx/datashard/execute_data_tx_unit.cpp @@ -72,7 +72,7 @@ EExecutionStatus TExecuteDataTxUnit::Execute(TOperation::TPtr op, } TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (tx->IsTxDataReleased()) { switch (Pipeline.RestoreDataTx(tx, txc, ctx)) { @@ -86,7 +86,7 @@ EExecutionStatus TExecuteDataTxUnit::Execute(TOperation::TPtr op, // For immediate transactions we want to translate this into a propose failure if (op->IsImmediate()) { const auto& dataTx = tx->GetDataTx(); - Y_ABORT_UNLESS(!dataTx->Ready()); + Y_ENSURE(!dataTx->Ready()); op->SetAbortedFlag(); BuildResult(op, NKikimrTxDataShard::TEvProposeTransactionResult::ERROR); op->Result()->SetProcessError(dataTx->Code(), dataTx->GetErrors()); @@ -94,7 +94,7 @@ EExecutionStatus TExecuteDataTxUnit::Execute(TOperation::TPtr op, } // For planned transactions errors are not expected - Y_ABORT("Failed to restore tx data: %s", tx->GetDataTx()->GetErrors().c_str()); + Y_ENSURE(false, "Failed to restore tx data: " << tx->GetDataTx()->GetErrors()); } } @@ -102,12 +102,12 @@ EExecutionStatus TExecuteDataTxUnit::Execute(TOperation::TPtr op, TSetupSysLocks guardLocks(op, DataShard, &locksDb); IEngineFlat* engine = tx->GetDataTx()->GetEngine(); - Y_VERIFY_S(engine, "missing engine for " << *op << " at " << DataShard.TabletID()); + Y_ENSURE(engine, "missing engine for " << *op << " at " << DataShard.TabletID()); if (op->IsImmediate() && !tx->ReValidateKeys(txc.DB.GetScheme())) { // Immediate transactions may be reordered with schema changes and become invalid const auto& dataTx = tx->GetDataTx(); - Y_ABORT_UNLESS(!dataTx->Ready()); + Y_ENSURE(!dataTx->Ready()); op->SetAbortedFlag(); BuildResult(op, NKikimrTxDataShard::TEvProposeTransactionResult::ERROR); op->Result()->SetProcessError(dataTx->Code(), dataTx->GetErrors()); @@ -269,14 +269,14 @@ void TExecuteDataTxUnit::ExecuteDataTx(TOperation::TPtr op, break; case IEngineFlat::EResult::Cancelled: LOG_NOTICE_S(ctx, NKikimrServices::TX_DATASHARD, errorMessage); - Y_ABORT_UNLESS(tx->GetDataTx()->CanCancel()); + Y_ENSURE(tx->GetDataTx()->CanCancel()); break; default: if (op->IsReadOnly() || op->IsImmediate()) { LOG_CRIT_S(ctx, NKikimrServices::TX_DATASHARD, errorMessage); } else { // TODO: Kill only current datashard tablet. - Y_FAIL_S("Unexpected execution error in read-write transaction: " + Y_ENSURE(false, "Unexpected execution error in read-write transaction: " << errorMessage); } break; diff --git a/ydb/core/tx/datashard/execute_distributed_erase_tx_unit.cpp b/ydb/core/tx/datashard/execute_distributed_erase_tx_unit.cpp index 226773c9db..429c9357f6 100644 --- a/ydb/core/tx/datashard/execute_distributed_erase_tx_unit.cpp +++ b/ydb/core/tx/datashard/execute_distributed_erase_tx_unit.cpp @@ -32,10 +32,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsDistributedEraseTx()); + Y_ENSURE(op->IsDistributedEraseTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); TDataShardLocksDb locksDb(DataShard, txc); TSetupSysLocks guardLocks(op, DataShard, &locksDb); @@ -61,7 +61,7 @@ public: for (ui64 txId : userDb.GetVolatileReadDependencies()) { op->AddVolatileDependency(txId); bool ok = DataShard.GetVolatileTxManager().AttachBlockedOperation(txId, op->GetTxId()); - Y_VERIFY_S(ok, "Unexpected failure to attach " << *op << " to volatile tx " << txId); + Y_ENSURE(ok, "Unexpected failure to attach " << *op << " to volatile tx " << txId); } if (txc.DB.HasChanges()) { @@ -83,15 +83,15 @@ public: } else if (eraseTx->HasDependencies()) { THashMap<ui64, TDynBitMap> presentRows; for (const auto& dependency : eraseTx->GetDependencies()) { - Y_ABORT_UNLESS(!presentRows.contains(dependency.GetShardId())); + Y_ENSURE(!presentRows.contains(dependency.GetShardId())); presentRows.emplace(dependency.GetShardId(), DeserializeBitMap<TDynBitMap>(dependency.GetPresentRows())); } for (const auto& [_, readSets] : op->InReadSets()) { for (const auto& rs : readSets) { NKikimrTxDataShard::TDistributedEraseRS body; - Y_ABORT_UNLESS(body.ParseFromArray(rs.Body.data(), rs.Body.size())); - Y_ABORT_UNLESS(presentRows.contains(rs.Origin)); + Y_ENSURE(body.ParseFromArray(rs.Body.data(), rs.Body.size())); + Y_ENSURE(presentRows.contains(rs.Origin)); auto confirmedRows = DeserializeBitMap<TDynBitMap>(body.GetConfirmedRows()); if (!Execute(txc, request, presentRows.at(rs.Origin), confirmedRows, writeVersion, op->GetGlobalTxId())) { @@ -107,7 +107,7 @@ public: return EExecutionStatus::Continue; } } else { - Y_FAIL_S("Invalid distributed erase tx: " << eraseTx->GetBody().ShortDebugString()); + Y_ENSURE(false, "Invalid distributed erase tx: " << eraseTx->GetBody().ShortDebugString()); } BuildResult(op, NKikimrTxDataShard::TEvProposeTransactionResult::COMPLETE); @@ -128,7 +128,7 @@ public: const ui64 tableId = request.GetTableId(); const TTableId fullTableId(DataShard.GetPathOwnerId(), tableId); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const TUserTable& tableInfo = *DataShard.GetUserTables().at(tableId); const bool breakWriteConflicts = DataShard.SysLocksTable().HasWriteLocks(fullTableId); @@ -148,8 +148,8 @@ public: const auto& serializedKey = request.GetKeyColumns(row++); TSerializedCellVec keyCells; - Y_ABORT_UNLESS(TSerializedCellVec::TryParse(serializedKey, keyCells)); - Y_ABORT_UNLESS(keyCells.GetCells().size() == tableInfo.KeyColumnTypes.size()); + Y_ENSURE(TSerializedCellVec::TryParse(serializedKey, keyCells)); + Y_ENSURE(keyCells.GetCells().size() == tableInfo.KeyColumnTypes.size()); TVector<TRawTypeValue> key; for (size_t ki : xrange(tableInfo.KeyColumnTypes.size())) { diff --git a/ydb/core/tx/datashard/execute_kqp_data_tx_unit.cpp b/ydb/core/tx/datashard/execute_kqp_data_tx_unit.cpp index 7e989238ab..634caeaaaf 100644 --- a/ydb/core/tx/datashard/execute_kqp_data_tx_unit.cpp +++ b/ydb/core/tx/datashard/execute_kqp_data_tx_unit.cpp @@ -74,7 +74,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio } TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); DataShard.ReleaseCache(*tx); @@ -90,7 +90,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio // For immediate transactions we want to translate this into a propose failure if (op->IsImmediate()) { const auto& dataTx = tx->GetDataTx(); - Y_ABORT_UNLESS(!dataTx->Ready()); + Y_ENSURE(!dataTx->Ready()); op->SetAbortedFlag(); BuildResult(op, NKikimrTxDataShard::TEvProposeTransactionResult::ERROR); op->Result()->SetProcessError(dataTx->Code(), dataTx->GetErrors()); @@ -98,7 +98,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio } // For planned transactions errors are not expected - Y_ABORT("Failed to restore tx data: %s", tx->GetDataTx()->GetErrors().c_str()); + Y_ENSURE(false, "Failed to restore tx data: " << tx->GetDataTx()->GetErrors()); } } @@ -110,7 +110,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio if (op->IsImmediate() && !dataTx->ReValidateKeys(txc.DB.GetScheme())) { // Immediate transactions may be reordered with schema changes and become invalid - Y_ABORT_UNLESS(!dataTx->Ready()); + Y_ENSURE(!dataTx->Ready()); op->SetAbortedFlag(); BuildResult(op, NKikimrTxDataShard::TEvProposeTransactionResult::ERROR); op->Result()->SetProcessError(dataTx->Code(), dataTx->GetErrors()); @@ -282,7 +282,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio // relevant for future multi-table shards only. // NOTE: generation may not match an existing lock, but it's not a problem. for (auto& table : guardLocks.AffectedTables) { - Y_ABORT_UNLESS(guardLocks.LockTxId); + Y_ENSURE(guardLocks.LockTxId); op->Result()->AddTxLock( guardLocks.LockTxId, DataShard.TabletID(), @@ -312,7 +312,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio for (ui64 txId : computeCtx.GetVolatileReadDependencies()) { op->AddVolatileDependency(txId); bool ok = DataShard.GetVolatileTxManager().AttachBlockedOperation(txId, op->GetTxId()); - Y_VERIFY_S(ok, "Unexpected failure to attach TxId# " << op->GetTxId() << " to volatile tx " << txId); + Y_ENSURE(ok, "Unexpected failure to attach TxId# " << op->GetTxId() << " to volatile tx " << txId); } allocGuard.Release(); @@ -339,7 +339,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio return EExecutionStatus::Continue; } - Y_ABORT_UNLESS(result); + Y_ENSURE(result); op->Result().Swap(result); op->SetKqpAttachedRSFlag(); @@ -420,7 +420,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio TStringBuilder() << "Shard " << DataShard.TabletID() << " cannot write more uncommitted changes"); for (auto& table : guardLocks.AffectedTables) { - Y_ABORT_UNLESS(guardLocks.LockTxId); + Y_ENSURE(guardLocks.LockTxId); op->Result()->AddTxLock( guardLocks.LockTxId, DataShard.TabletID(), @@ -447,7 +447,7 @@ EExecutionStatus TExecuteKqpDataTxUnit::Execute(TOperation::TPtr op, TTransactio ->AddError(NKikimrTxDataShard::TError::UNKNOWN, TStringBuilder() << "Tx was terminated: " << e.what()); return EExecutionStatus::Executed; } else { - Y_FAIL_S("Unexpected exception in KQP transaction execution: " << e.what()); + throw; } } diff --git a/ydb/core/tx/datashard/execute_write_unit.cpp b/ydb/core/tx/datashard/execute_write_unit.cpp index afa4a61724..90c26cfaf1 100644 --- a/ydb/core/tx/datashard/execute_write_unit.cpp +++ b/ydb/core/tx/datashard/execute_write_unit.cpp @@ -73,7 +73,7 @@ public: for (ui64 txId : userDb.GetVolatileReadDependencies()) { writeOp.AddVolatileDependency(txId); bool ok = DataShard.GetVolatileTxManager().AttachBlockedOperation(txId, writeOp.GetTxId()); - Y_VERIFY_S(ok, "Unexpected failure to attach TxId# " << writeOp.GetTxId() << " to volatile tx " << txId); + Y_ENSURE(ok, "Unexpected failure to attach TxId# " << writeOp.GetTxId() << " to volatile tx " << txId); } ResetChanges(userDb, writeOp, txc); @@ -119,7 +119,7 @@ public: auto fillOps = [&](ui32 rowIdx) { ops.clear(); - Y_ABORT_UNLESS(matrix.GetColCount() >= userTable.KeyColumnIds.size()); + Y_ENSURE(matrix.GetColCount() >= userTable.KeyColumnIds.size()); ops.reserve(matrix.GetColCount() - userTable.KeyColumnIds.size()); for (ui16 valueColIdx = userTable.KeyColumnIds.size(); valueColIdx < matrix.GetColCount(); ++valueColIdx) { @@ -173,7 +173,7 @@ public: } default: // Checked before in TWriteOperation - Y_FAIL_S(operationType << " operation is not supported now"); + Y_ENSURE(false, operationType << " operation is not supported now"); } } @@ -192,7 +192,7 @@ public: } default: // Checked before in TWriteOperation - Y_FAIL_S(operationType << " operation is not supported now"); + Y_ENSURE(false, operationType << " operation is not supported now"); } } @@ -230,13 +230,13 @@ public: case ERestoreDataStatus::Error: // For immediate transactions we want to translate this into a propose failure if (op->IsImmediate()) { - Y_ABORT_UNLESS(!writeTx->Ready()); + Y_ENSURE(!writeTx->Ready()); writeOp->SetError(NKikimrDataEvents::TEvWriteResult::STATUS_INTERNAL_ERROR, writeTx->GetErrStr()); return EExecutionStatus::Executed; } // For planned transactions errors are not expected - Y_ABORT("Failed to restore tx data: %s", writeTx->GetErrStr().c_str()); + Y_ENSURE(false, "Failed to restore tx data: " << writeTx->GetErrStr()); } } @@ -245,7 +245,7 @@ public: if (op->IsImmediate() && !writeOp->ReValidateKeys(txc.DB.GetScheme())) { // Immediate transactions may be reordered with schema changes and become invalid - Y_ABORT_UNLESS(!writeTx->Ready()); + Y_ENSURE(!writeTx->Ready()); writeOp->SetError(NKikimrDataEvents::TEvWriteResult::STATUS_INTERNAL_ERROR, writeTx->GetErrStr()); return EExecutionStatus::Executed; } @@ -436,9 +436,9 @@ public: KqpFillTxStats(DataShard, counters, *writeResult->Record.MutableTxStats()); } catch (const TNeedGlobalTxId&) { - Y_VERIFY_S(op->GetGlobalTxId() == 0, + Y_ENSURE(op->GetGlobalTxId() == 0, "Unexpected TNeedGlobalTxId exception for write operation with TxId# " << op->GetGlobalTxId()); - Y_VERIFY_S(op->IsImmediate(), + Y_ENSURE(op->IsImmediate(), "Unexpected TNeedGlobalTxId exception for a non-immediate write operation with TxId# " << op->GetTxId()); ctx.Send(MakeTxProxyID(), @@ -458,7 +458,7 @@ public: writeOp->SetError(NKikimrDataEvents::TEvWriteResult::STATUS_INTERNAL_ERROR, TStringBuilder() << "Shard " << tabletId << " cannot write more uncommitted changes"); for (auto& table : guardLocks.AffectedTables) { - Y_ABORT_UNLESS(guardLocks.LockTxId); + Y_ENSURE(guardLocks.LockTxId); op->Result()->AddTxLock( guardLocks.LockTxId, tabletId, diff --git a/ydb/core/tx/datashard/execution_unit.cpp b/ydb/core/tx/datashard/execution_unit.cpp index 2e7c9a78f6..7717271765 100644 --- a/ydb/core/tx/datashard/execution_unit.cpp +++ b/ydb/core/tx/datashard/execution_unit.cpp @@ -153,7 +153,7 @@ THolder<TExecutionUnit> CreateExecutionUnit(EExecutionUnitKind kind, case EExecutionUnitKind::CreateIncrementalRestoreSrc: return CreateIncrementalRestoreSrcUnit(dataShard, pipeline); default: - Y_FAIL_S("Unexpected execution kind " << kind << " (" << (ui32)kind << ")"); + Y_ENSURE(false, "Unexpected execution kind " << kind << " (" << (ui32)kind << ")"); } return nullptr; diff --git a/ydb/core/tx/datashard/execution_unit.h b/ydb/core/tx/datashard/execution_unit.h index afc1398e22..717d5e5a1c 100644 --- a/ydb/core/tx/datashard/execution_unit.h +++ b/ydb/core/tx/datashard/execution_unit.h @@ -92,7 +92,7 @@ public: virtual bool IsReadyToExecute(TOperation::TPtr op) const = 0; virtual TOperation::TPtr FindReadyOperation() const { - Y_FAIL_S("FindReadyOperation is not implemented for execution unit " << Kind); + Y_ENSURE(false, "FindReadyOperation is not implemented for execution unit " << Kind); } virtual EExecutionStatus Execute(TOperation::TPtr op, diff --git a/ydb/core/tx/datashard/export_common.cpp b/ydb/core/tx/datashard/export_common.cpp index d13f79e415..c0a1f327ed 100644 --- a/ydb/core/tx/datashard/export_common.cpp +++ b/ydb/core/tx/datashard/export_common.cpp @@ -15,12 +15,12 @@ static void ResortColumns( { THashMap<TString, ui32> nameToTag; for (const auto& [tag, column] : order) { - Y_ABORT_UNLESS(nameToTag.emplace(column.Name, tag).second); + Y_ENSURE(nameToTag.emplace(column.Name, tag).second); } SortBy(columns, [&nameToTag](const auto& column) { auto it = nameToTag.find(column.name()); - Y_ABORT_UNLESS(it != nameToTag.end()); + Y_ENSURE(it != nameToTag.end()); return it->second; }); } diff --git a/ydb/core/tx/datashard/export_s3.h b/ydb/core/tx/datashard/export_s3.h index fc6d5e3e54..d70257df69 100644 --- a/ydb/core/tx/datashard/export_s3.h +++ b/ydb/core/tx/datashard/export_s3.h @@ -18,7 +18,7 @@ public: : Task(task) , Columns(columns) { - Y_ABORT_UNLESS(task.HasS3Settings()); + Y_ENSURE(task.HasS3Settings()); } IActor* CreateUploader(const TActorId& dataShard, ui64 txId) const override; @@ -49,7 +49,7 @@ public: .WithCompression(TS3ExportBufferSettings::ZstdCompression(Task.GetCompression().GetLevel())); break; case ECompressionCodec::Invalid: - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } return CreateS3ExportBuffer(std::move(bufferSettings)); diff --git a/ydb/core/tx/datashard/export_s3_buffer.cpp b/ydb/core/tx/datashard/export_s3_buffer.cpp index fbe715090b..457717dfc0 100644 --- a/ydb/core/tx/datashard/export_s3_buffer.cpp +++ b/ydb/core/tx/datashard/export_s3_buffer.cpp @@ -141,14 +141,14 @@ TZStdCompressionProcessor* TS3Buffer::CreateCompression(const TMaybe<TS3ExportBu } void TS3Buffer::ColumnsOrder(const TVector<ui32>& tags) { - Y_ABORT_UNLESS(tags.size() == Columns.size()); + Y_ENSURE(tags.size() == Columns.size()); Indices.clear(); for (ui32 i = 0; i < tags.size(); ++i) { const ui32 tag = tags.at(i); auto it = Columns.find(tag); - Y_ABORT_UNLESS(it != Columns.end()); - Y_ABORT_UNLESS(Indices.emplace(tag, i).second); + Y_ENSURE(it != Columns.end()); + Y_ENSURE(Indices.emplace(tag, i).second); } } @@ -156,8 +156,8 @@ bool TS3Buffer::Collect(const NTable::IScan::TRow& row, IOutputStream& out) { bool needsComma = false; for (const auto& [tag, column] : Columns) { auto it = Indices.find(tag); - Y_ABORT_UNLESS(it != Indices.end()); - Y_ABORT_UNLESS(it->second < (*row).size()); + Y_ENSURE(it != Indices.end()); + Y_ENSURE(it->second < (*row).size()); const auto& cell = (*row)[it->second]; BytesRead += cell.Size(); @@ -253,7 +253,7 @@ bool TS3Buffer::Collect(const NTable::IScan::TRow& row, IOutputStream& out) { serialized = UuidToStream(cell.AsValue<std::pair<ui64, ui64>>(), out, ErrorString); break; default: - Y_ABORT("Unsupported type"); + Y_ENSURE(false, "Unsupported type"); } if (!serialized) { @@ -312,7 +312,7 @@ IEventBase* TS3Buffer::PrepareEvent(bool last, NExportScan::IBuffer::TStats& sta } void TS3Buffer::Clear() { - Y_ABORT_UNLESS(Flush(false, false)); + Y_ENSURE(Flush(false, false)); } bool TS3Buffer::IsFilled() const { diff --git a/ydb/core/tx/datashard/export_s3_uploader.cpp b/ydb/core/tx/datashard/export_s3_uploader.cpp index 5355f9daef..9a18fea8ef 100644 --- a/ydb/core/tx/datashard/export_s3_uploader.cpp +++ b/ydb/core/tx/datashard/export_s3_uploader.cpp @@ -73,7 +73,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { } TString GetResolveProxyUrl(const TS3ExternalStorageConfig& settings) const { - Y_ABORT_UNLESS(HttpResolverConfig); + Y_ENSURE(HttpResolverConfig); TStringBuilder url; switch (settings.GetConfig().scheme) { @@ -90,7 +90,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { } void ApplyProxy(TS3ExternalStorageConfig& settings, const TString& proxyHost) const { - Y_ABORT_UNLESS(HttpResolverConfig); + Y_ENSURE(HttpResolverConfig); settings.ConfigRef().proxyScheme = settings.GetConfig().scheme; settings.ConfigRef().proxyHost = proxyHost; @@ -154,7 +154,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { } void Restart() { - Y_ABORT_UNLESS(ProxyResolved); + Y_ENSURE(ProxyResolved); MultiPart = false; Last = false; @@ -211,7 +211,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { } void UploadScheme() { - Y_ABORT_UNLESS(!SchemeUploaded); + Y_ENSURE(!SchemeUploaded); if (!Scheme) { return Finish(false, "Cannot infer scheme"); @@ -224,7 +224,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { } void UploadPermissions() { - Y_ABORT_UNLESS(EnablePermissions && !PermissionsUploaded); + Y_ENSURE(EnablePermissions && !PermissionsUploaded); if (!Permissions) { return Finish(false, "Cannot infer permissions"); @@ -241,7 +241,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { } void UploadChangefeed() { - Y_ABORT_UNLESS(!ChangefeedsUploaded); + Y_ENSURE(!ChangefeedsUploaded); if (IndexExportedChangefeed == Changefeeds.size()) { ChangefeedsUploaded = true; if (Scanner) { @@ -262,7 +262,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { } void UploadMetadata() { - Y_ABORT_UNLESS(!MetadataUploaded); + Y_ENSURE(!MetadataUploaded); Buffer = std::move(Metadata); PutDataWithChecksum(std::move(Buffer), Settings.GetMetadataKey(), MetadataChecksum, &TThis::StateUploadMetadata); @@ -633,7 +633,7 @@ class TS3Uploader: public TActorBootstrapped<TS3Uploader> { UploadId.Clear(); // force getting info after restart Retry(); } else { - Y_ABORT_UNLESS(Error); + Y_ENSURE(Error); Error = TStringBuilder() << *Error << " Additionally, 'AbortMultipartUpload' has failed: " << error.GetMessage(); PassAway(); diff --git a/ydb/core/tx/datashard/export_scan.cpp b/ydb/core/tx/datashard/export_scan.cpp index 29f6db279c..f19911c9c1 100644 --- a/ydb/core/tx/datashard/export_scan.cpp +++ b/ydb/core/tx/datashard/export_scan.cpp @@ -112,7 +112,7 @@ class TExportScan: private NActors::IActorCallback, public NTable::IScan { } void Handle(TEvExportScan::TEvReset::TPtr&) { - Y_ABORT_UNLESS(IsReady()); + Y_ENSURE(IsReady()); EXPORT_LOG_D("Handle TEvExportScan::TEvReset" << ": self# " << SelfId()); @@ -124,7 +124,7 @@ class TExportScan: private NActors::IActorCallback, public NTable::IScan { } void Handle(TEvExportScan::TEvFeed::TPtr&) { - Y_ABORT_UNLESS(IsReady()); + Y_ENSURE(IsReady()); EXPORT_LOG_D("Handle TEvExportScan::TEvFeed" << ": self# " << SelfId()); @@ -137,7 +137,7 @@ class TExportScan: private NActors::IActorCallback, public NTable::IScan { } void Handle(TEvExportScan::TEvFinish::TPtr& ev) { - Y_ABORT_UNLESS(IsReady()); + Y_ENSURE(IsReady()); EXPORT_LOG_D("Handle TEvExportScan::TEvFinish" << ": self# " << SelfId() diff --git a/ydb/core/tx/datashard/finalize_build_index_unit.cpp b/ydb/core/tx/datashard/finalize_build_index_unit.cpp index 30be2cedc6..1c22b3089c 100644 --- a/ydb/core/tx/datashard/finalize_build_index_unit.cpp +++ b/ydb/core/tx/datashard/finalize_build_index_unit.cpp @@ -18,10 +18,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasFinalizeBuildIndex()) { @@ -31,10 +31,10 @@ public: const auto& params = schemeTx.GetFinalizeBuildIndex(); const auto pathId = TPathId::FromProto(params.GetPathId()); - Y_ABORT_UNLESS(pathId.OwnerId == DataShard.GetPathOwnerId()); + Y_ENSURE(pathId.OwnerId == DataShard.GetPathOwnerId()); const auto version = params.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); TUserTable::TPtr tableInfo; if (params.HasOutcome() && params.GetOutcome().HasApply()) { @@ -45,7 +45,7 @@ public: const auto indexPathId = TPathId::FromProto(params.GetOutcome().GetCancel().GetIndexPathId()); const auto& userTables = DataShard.GetUserTables(); - Y_ABORT_UNLESS(userTables.contains(pathId.LocalPathId)); + Y_ENSURE(userTables.contains(pathId.LocalPathId)); userTables.at(pathId.LocalPathId)->ForAsyncIndex(indexPathId, [&](const auto&) { RemoveSender.Reset(new TEvChangeExchange::TEvRemoveSender(indexPathId)); }); @@ -55,7 +55,7 @@ public: tableInfo = DataShard.AlterTableSchemaVersion(ctx, txc, pathId, version); } - Y_ABORT_UNLESS(tableInfo); + Y_ENSURE(tableInfo); DataShard.AddUserTable(pathId, tableInfo); if (tableInfo->NeedSchemaSnapshots()) { @@ -64,7 +64,7 @@ public: ui64 step = params.GetSnapshotStep(); ui64 txId = params.GetSnapshotTxId(); - Y_ABORT_UNLESS(step != 0); + Y_ENSURE(step != 0); if (const auto* record = DataShard.GetScanManager().Get(params.GetBuildIndexId())) { for (auto scanId : record->ScanIds) { diff --git a/ydb/core/tx/datashard/finalize_plan_tx_unit.cpp b/ydb/core/tx/datashard/finalize_plan_tx_unit.cpp index 70ccbf9a51..abbb49fe61 100644 --- a/ydb/core/tx/datashard/finalize_plan_tx_unit.cpp +++ b/ydb/core/tx/datashard/finalize_plan_tx_unit.cpp @@ -25,14 +25,14 @@ public: Y_UNUSED(ctx); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); - Y_VERIFY_S(tx->IsDataTx(), "unexpected non-data tx"); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx->IsDataTx(), "unexpected non-data tx"); if (auto& dataTx = tx->GetDataTx()) { // Restore transaction type flags if (dataTx->IsKqpDataTx() && !tx->IsKqpDataTransaction()) tx->SetKqpDataTransactionFlag(); - Y_VERIFY_S(!dataTx->IsKqpScanTx(), "unexpected kqp scan tx"); + Y_ENSURE(!dataTx->IsKqpScanTx(), "unexpected kqp scan tx"); } tx->FinalizeDataTxPlan(); diff --git a/ydb/core/tx/datashard/finish_propose_unit.cpp b/ydb/core/tx/datashard/finish_propose_unit.cpp index 4794eeec31..8202ba2f13 100644 --- a/ydb/core/tx/datashard/finish_propose_unit.cpp +++ b/ydb/core/tx/datashard/finish_propose_unit.cpp @@ -155,7 +155,7 @@ void TFinishProposeUnit::CompleteRequest(TOperation::TPtr op, const TActorContext &ctx) { auto res = std::move(op->Result()); - Y_ABORT_UNLESS(res); + Y_ENSURE(res); TDuration duration = TAppData::TimeProvider->Now() - op->GetReceivedAt(); res->Record.SetProposeLatency(duration.MilliSeconds()); @@ -226,7 +226,7 @@ void TFinishProposeUnit::UpdateCounters(TOperation::TPtr op, const TActorContext &ctx) { auto &res = op->Result(); - Y_ABORT_UNLESS(res); + Y_ENSURE(res); auto execLatency = TAppData::TimeProvider->Now() - op->GetReceivedAt(); res->Record.SetExecLatency(execLatency.MilliSeconds()); diff --git a/ydb/core/tx/datashard/follower_edge.cpp b/ydb/core/tx/datashard/follower_edge.cpp index 45e834447b..11e89c5a9f 100644 --- a/ydb/core/tx/datashard/follower_edge.cpp +++ b/ydb/core/tx/datashard/follower_edge.cpp @@ -3,7 +3,7 @@ namespace NKikimr::NDataShard { std::tuple<TRowVersion, bool, ui64> TDataShard::CalculateFollowerReadEdge() const { - Y_ABORT_UNLESS(!IsFollower()); + Y_ENSURE(!IsFollower()); TRowVersion volatileUncertain = VolatileTxManager.GetMinUncertainVersion(); @@ -47,7 +47,7 @@ std::tuple<TRowVersion, bool, ui64> TDataShard::CalculateFollowerReadEdge() cons } bool TDataShard::PromoteFollowerReadEdge(TTransactionContext& txc) { - Y_ABORT_UNLESS(!IsFollower()); + Y_ENSURE(!IsFollower()); if (HasFollowers()) { auto [version, repeatable, waitStep] = CalculateFollowerReadEdge(); @@ -73,7 +73,7 @@ public: TTxType GetTxType() const override { return TXTYPE_UPDATE_FOLLOWER_READ_EDGE; } bool Execute(TTransactionContext& txc, const TActorContext&) override { - Y_ABORT_UNLESS(Self->UpdateFollowerReadEdgePending); + Y_ENSURE(Self->UpdateFollowerReadEdgePending); Self->UpdateFollowerReadEdgePending = false; Self->PromoteFollowerReadEdge(txc); return true; @@ -85,7 +85,7 @@ public: }; bool TDataShard::PromoteFollowerReadEdge() { - Y_ABORT_UNLESS(!IsFollower()); + Y_ENSURE(!IsFollower()); if (HasFollowers()) { auto [currentEdge, currentRepeatable] = SnapshotManager.GetFollowerReadEdge(); diff --git a/ydb/core/tx/datashard/import_common.h b/ydb/core/tx/datashard/import_common.h index d400de3415..ebe5ea9ed3 100644 --- a/ydb/core/tx/datashard/import_common.h +++ b/ydb/core/tx/datashard/import_common.h @@ -58,7 +58,7 @@ class TTableInfo { auto it = info->Columns.begin(); while (it != info->Columns.end()) { - Y_ABORT_UNLESS(result.emplace(it->second.Name, it).second); + Y_ENSURE(result.emplace(it->second.Name, it).second); it++; } @@ -83,7 +83,7 @@ public: std::pair<NScheme::TTypeInfo, TString> GetColumnType(const TString& name) const { auto it = ColumnNameIndex.find(name); - Y_ABORT_UNLESS(it != ColumnNameIndex.end()); + Y_ENSURE(it != ColumnNameIndex.end()); auto& column = it->second->second; return {column.Type, column.TypeMod}; } @@ -96,7 +96,7 @@ public: TVector<ui32> result; for (const auto& name : order) { auto it = ColumnNameIndex.find(name); - Y_ABORT_UNLESS(it != ColumnNameIndex.end()); + Y_ENSURE(it != ColumnNameIndex.end()); if (it->second->second.IsKey) { continue; @@ -110,7 +110,7 @@ public: ui32 KeyOrder(const TString& name) const { auto it = ColumnNameIndex.find(name); - Y_ABORT_UNLESS(it != ColumnNameIndex.end()); + Y_ENSURE(it != ColumnNameIndex.end()); if (!it->second->second.IsKey) { return Max<ui32>(); diff --git a/ydb/core/tx/datashard/import_s3.cpp b/ydb/core/tx/datashard/import_s3.cpp index 02dc4f42dd..aa90e9da6f 100644 --- a/ydb/core/tx/datashard/import_s3.cpp +++ b/ydb/core/tx/datashard/import_s3.cpp @@ -93,8 +93,8 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { } std::pair<ui64, ui64> NextRange(ui64 contentLength, ui64 processedBytes) const override { - Y_ABORT_UNLESS(contentLength > 0); - Y_ABORT_UNLESS(processedBytes < contentLength); + Y_ENSURE(contentLength > 0); + Y_ENSURE(processedBytes < contentLength); const ui64 start = processedBytes + PendingBytes(); const ui64 end = Min(SumWithSaturation(start, RangeSize), contentLength) - 1; @@ -141,7 +141,7 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { } EDataStatus TryGetData(TStringBuf& data, TString& error) override { - Y_ABORT_UNLESS(Pos == 0); + Y_ENSURE(Pos == 0); const ui64 pos = AsStringBuf(Buffer.Size()).rfind('\n'); if (TString::npos == pos) { @@ -193,12 +193,12 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { } void Feed(TString&& portion, bool /* last */) override { - Y_ABORT_UNLESS(Portion.Empty()); + Y_ENSURE(Portion.Empty()); Portion.Assign(portion.data(), portion.size()); } EDataStatus TryGetData(TStringBuf& data, TString& error) override { - Y_ABORT_UNLESS(ReadyInputBytes == 0 && ReadyOutputPos == 0); + Y_ENSURE(ReadyInputBytes == 0 && ReadyOutputPos == 0); auto input = ZSTD_inBuffer{Portion.Data(), Portion.Size(), 0}; while (!ReadyOutputPos) { @@ -309,14 +309,14 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { TMaybe<TBuffer> block = Deserializer.GetNextBlock(); // Returns at least one encrypted block if (block) { const ui64 processedAfter = Deserializer.GetProcessedInputBytes(); - Y_ABORT_UNLESS(processedAfter - processedBefore <= FeedUnprocessedBytes); + Y_ENSURE(processedAfter - processedBefore <= FeedUnprocessedBytes); // Data is read by blocks from encrypted file. // Each block contains at least one row of data with '\n', // so we will always get some data from DataController. ReadyInputBytes += processedAfter - processedBefore; DataController->Feed(TString(block->Data(), block->Size()), Last); const EDataStatus status = DataController->TryGetData(data, error); - Y_ABORT_UNLESS(status == READY_DATA); + Y_ENSURE(status == READY_DATA); return status; } else { return NOT_ENOUGH_DATA; @@ -387,14 +387,14 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { } void AddRow(const TVector<TCell>& keys, const TVector<TCell>& values) { - Y_ABORT_UNLESS(Record); + Y_ENSURE(Record); auto& row = *Record->AddRows(); row.SetKeyColumns(TSerializedCellVec::Serialize(keys)); row.SetValueColumns(TSerializedCellVec::Serialize(values)); } const std::shared_ptr<NKikimrTxDataShard::TEvUploadRowsRequest>& GetRecord() { - Y_ABORT_UNLESS(Record); + Y_ENSURE(Record); return Record; } @@ -496,7 +496,7 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { Reader.Reset(new TReadControllerZstd(ReadBatchSize, ReadBufferSizeLimit)); break; case NBackupRestoreTraits::ECompressionCodec::Invalid: - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } ETag = result.GetResult().GetETag(); @@ -536,7 +536,7 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { IMPORT_LOG_N("Process download info at '" << marker << "'" << ": info# " << info); - Y_ABORT_UNLESS(info.DataETag); + Y_ENSURE(info.DataETag); if (!CheckETag(*info.DataETag, ETag, marker)) { return; } @@ -693,7 +693,7 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { return false; } - Y_ABORT_UNLESS(!keys.empty()); + Y_ENSURE(!keys.empty()); if (!TableInfo.IsMyKey(keys) /* TODO: maybe skip */) { Finish(false, TStringBuilder() << "Key is out of range on line: " << origLine); return false; @@ -871,7 +871,7 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader> { TAutoPtr<IDestructable> prod = new TImportJobProduct(success, error, WrittenBytes, WrittenRows); Send(DataShard, new TDataShard::TEvPrivate::TEvAsyncJobComplete(prod), 0, TxId); - Y_ABORT_UNLESS(TaskId); + Y_ENSURE(TaskId); Send(MakeResourceBrokerID(), new TEvResourceBroker::TEvFinishTask(TaskId)); PassAway(); diff --git a/ydb/core/tx/datashard/incr_restore_helpers.cpp b/ydb/core/tx/datashard/incr_restore_helpers.cpp index 11accf7c9f..2929137f5e 100644 --- a/ydb/core/tx/datashard/incr_restore_helpers.cpp +++ b/ydb/core/tx/datashard/incr_restore_helpers.cpp @@ -3,15 +3,15 @@ namespace NKikimr::NDataShard::NIncrRestoreHelpers { std::optional<TVector<TUpdateOp>> MakeRestoreUpdates(TArrayRef<const TCell> cells, TArrayRef<const TTag> tags, const TMap<ui32, TUserTable::TUserColumn>& columns) { - Y_ABORT_UNLESS(cells.size() >= 1); + Y_ENSURE(cells.size() >= 1); TVector<TUpdateOp> updates(::Reserve(cells.size() - 1)); bool foundSpecialColumn = false; - Y_ABORT_UNLESS(cells.size() == tags.size()); + Y_ENSURE(cells.size() == tags.size()); for (TPos pos = 0; pos < cells.size(); ++pos) { const auto tag = tags.at(pos); auto it = columns.find(tag); - Y_ABORT_UNLESS(it != columns.end()); + Y_ENSURE(it != columns.end()); if (it->second.Name == "__ydb_incrBackupImpl_deleted") { if (const auto& cell = cells.at(pos); !cell.IsNull() && cell.AsValue<bool>()) { return std::nullopt; @@ -21,7 +21,7 @@ std::optional<TVector<TUpdateOp>> MakeRestoreUpdates(TArrayRef<const TCell> cell } updates.emplace_back(tag, ECellOp::Set, TRawTypeValue(cells.at(pos).AsRef(), it->second.Type.GetTypeId())); } - Y_ABORT_UNLESS(foundSpecialColumn); + Y_ENSURE(foundSpecialColumn); return updates; } diff --git a/ydb/core/tx/datashard/incr_restore_scan.cpp b/ydb/core/tx/datashard/incr_restore_scan.cpp index 79552f4d23..5e9de5e7fc 100644 --- a/ydb/core/tx/datashard/incr_restore_scan.cpp +++ b/ydb/core/tx/datashard/incr_restore_scan.cpp @@ -60,7 +60,7 @@ public: {} static TVector<TTag> InitValueTags(TUserTable::TCPtr table) { - Y_VERIFY(table->Columns.size() >= 2); + Y_ENSURE(table->Columns.size() >= 2); TVector<TTag> valueTags; valueTags.reserve(table->Columns.size() - 1); bool deletedMarkerColumnFound = false; @@ -73,7 +73,7 @@ public: } } - Y_VERIFY(deletedMarkerColumnFound); + Y_ENSURE(deletedMarkerColumnFound); return valueTags; } @@ -105,7 +105,7 @@ public: for (const auto& record : ev->Get()->Records) { auto it = PendingRecords.find(record.Order); - Y_ABORT_UNLESS(it != PendingRecords.end()); + Y_ENSURE(it != PendingRecords.end()); records.emplace_back(it->second); } @@ -140,7 +140,7 @@ public: IScan::TInitialState Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) override { TlsActivationContext->AsActorContext().RegisterWithSameMailbox(this); Driver = driver; - Y_ABORT_UNLESS(!LastKey || LastKey->GetCells().size() == scheme->Tags(true).size()); + Y_ENSURE(!LastKey || LastKey->GetCells().size() == scheme->Tags(true).size()); return {EScan::Sleep, {}}; } diff --git a/ydb/core/tx/datashard/initiate_build_index_unit.cpp b/ydb/core/tx/datashard/initiate_build_index_unit.cpp index 7257c09a9f..5006c4b5a4 100644 --- a/ydb/core/tx/datashard/initiate_build_index_unit.cpp +++ b/ydb/core/tx/datashard/initiate_build_index_unit.cpp @@ -19,10 +19,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto& schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasInitiateBuildIndex()) { @@ -32,10 +32,10 @@ public: const auto& params = schemeTx.GetInitiateBuildIndex(); const auto pathId = TPathId::FromProto(params.GetPathId()); - Y_ABORT_UNLESS(pathId.OwnerId == DataShard.GetPathOwnerId()); + Y_ENSURE(pathId.OwnerId == DataShard.GetPathOwnerId()); const auto version = params.GetTableSchemaVersion(); - Y_ABORT_UNLESS(version); + Y_ENSURE(version); TUserTable::TPtr tableInfo; if (params.HasIndexDescription()) { @@ -53,7 +53,7 @@ public: tableInfo = DataShard.AlterTableSchemaVersion(ctx, txc, pathId, version); } - Y_ABORT_UNLESS(tableInfo); + Y_ENSURE(tableInfo); TDataShardLocksDb locksDb(DataShard, txc); DataShard.AddUserTable(pathId, tableInfo, &locksDb); @@ -63,7 +63,7 @@ public: ui64 step = tx->GetStep(); ui64 txId = tx->GetTxId(); - Y_ABORT_UNLESS(step != 0); + Y_ENSURE(step != 0); const TSnapshotKey key(pathId, step, txId); const ui64 flags = TSnapshot::FlagScheme; diff --git a/ydb/core/tx/datashard/key_conflicts.cpp b/ydb/core/tx/datashard/key_conflicts.cpp index bdf24c7b6d..710fc9abcc 100644 --- a/ydb/core/tx/datashard/key_conflicts.cpp +++ b/ydb/core/tx/datashard/key_conflicts.cpp @@ -18,8 +18,8 @@ bool HasKeyConflict(const TKeyDesc& aKey, bool HasKeyConflict(const TValidatedKey& a, const TValidatedKey& b) { - Y_ABORT_UNLESS(a.Key && b.Key); - Y_ABORT_UNLESS(a.IsWrite || b.IsWrite); + Y_ENSURE(a.Key && b.Key); + Y_ENSURE(a.IsWrite || b.IsWrite); const TKeyDesc& aKey = *a.Key; const TKeyDesc& bKey = *b.Key; @@ -32,10 +32,10 @@ bool HasKeyConflict(const TValidatedKey& a, using TLocksTable = TSysTables::TLocksTable; ui64 aLockId, bLockId; - Y_ABORT_UNLESS(aKey.Range.Point && bKey.Range.Point, "Unexpected non-point locks table key accesses"); + Y_ENSURE(aKey.Range.Point && bKey.Range.Point, "Unexpected non-point locks table key accesses"); bool ok = TLocksTable::ExtractKey(aKey.Range.From, TLocksTable::EColumns::LockId, aLockId) && TLocksTable::ExtractKey(bKey.Range.From, TLocksTable::EColumns::LockId, bLockId); - Y_ABORT_UNLESS(ok, "Cannot extract LockId from locks table key accesses"); + Y_ENSURE(ok, "Cannot extract LockId from locks table key accesses"); // Only conflict on the same LockId return aLockId == bLockId; diff --git a/ydb/core/tx/datashard/key_validator.cpp b/ydb/core/tx/datashard/key_validator.cpp index 78770b4361..f71b018e45 100644 --- a/ydb/core/tx/datashard/key_validator.cpp +++ b/ydb/core/tx/datashard/key_validator.cpp @@ -110,8 +110,7 @@ ui64 TKeyValidator::GetTableSchemaVersion(const TTableId& tableId) const { const auto& userTables = Self.GetUserTables(); auto it = userTables.find(tableId.PathId.LocalPathId); if (it == userTables.end()) { - Y_FAIL_S("TKeyValidator (tablet id: " << Self.TabletID() << " state: " << Self.GetState() << ") unable to find given table with id: " << tableId); - return 0; + Y_ENSURE(false, "TKeyValidator (tablet id: " << Self.TabletID() << " state: " << Self.GetState() << ") unable to find given table with id: " << tableId); } else { return it->second->GetTableSchemaVersion(); } diff --git a/ydb/core/tx/datashard/load_and_wait_in_rs_unit.cpp b/ydb/core/tx/datashard/load_and_wait_in_rs_unit.cpp index 00c8baee79..cd55ad965d 100644 --- a/ydb/core/tx/datashard/load_and_wait_in_rs_unit.cpp +++ b/ydb/core/tx/datashard/load_and_wait_in_rs_unit.cpp @@ -63,7 +63,7 @@ EExecutionStatus TLoadAndWaitInRSUnit::Execute(TOperation::TPtr op, if (!Pipeline.LoadInReadSets(op, txc, ctx)) return EExecutionStatus::Restart; - Y_ABORT_UNLESS(op->HasLoadedInRSFlag()); + Y_ENSURE(op->HasLoadedInRSFlag()); if (!IsReadyToExecute(op)) return EExecutionStatus::Continue; diff --git a/ydb/core/tx/datashard/load_tx_details_unit.cpp b/ydb/core/tx/datashard/load_tx_details_unit.cpp index 6916d8b0d5..498e7425e3 100644 --- a/ydb/core/tx/datashard/load_tx_details_unit.cpp +++ b/ydb/core/tx/datashard/load_tx_details_unit.cpp @@ -40,7 +40,7 @@ EExecutionStatus TLoadTxDetailsUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction::TPtr tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (!Pipeline.LoadTxDetails(txc, ctx, tx)) return EExecutionStatus::Restart; diff --git a/ydb/core/tx/datashard/local_kmeans.cpp b/ydb/core/tx/datashard/local_kmeans.cpp index 1954224b06..77bf0dfbc8 100644 --- a/ydb/core/tx/datashard/local_kmeans.cpp +++ b/ydb/core/tx/datashard/local_kmeans.cpp @@ -282,10 +282,10 @@ protected: << " Uploader: " << Uploader.ToString() << " ev->Sender: " << ev->Sender.ToString()); if (Uploader) { - Y_VERIFY_S(Uploader == ev->Sender, "Mismatch Uploader: " << Uploader.ToString() << " ev->Sender: " + Y_ENSURE(Uploader == ev->Sender, "Mismatch Uploader: " << Uploader.ToString() << " ev->Sender: " << ev->Sender.ToString() << Debug()); } else { - Y_ABORT_UNLESS(Driver == nullptr); + Y_ENSURE(Driver == nullptr); return; } @@ -700,7 +700,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvLocalKMeansRequest::TPtr& ev, const badRequest(TStringBuilder() << "Unknown table id: " << pathId.LocalPathId); return; } - Y_ABORT_UNLESS(*userTableIt); + Y_ENSURE(*userTableIt); const auto& userTable = **userTableIt; if (const auto* recCard = ScanManager.Get(id)) { diff --git a/ydb/core/tx/datashard/make_snapshot_unit.cpp b/ydb/core/tx/datashard/make_snapshot_unit.cpp index 10e9f364e5..901b68f855 100644 --- a/ydb/core/tx/datashard/make_snapshot_unit.cpp +++ b/ydb/core/tx/datashard/make_snapshot_unit.cpp @@ -44,7 +44,7 @@ EExecutionStatus TMakeSnapshotUnit::Execute(TOperation::TPtr op, const TActorContext &) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasSendSnapshot() && !schemeTx.HasCreateIncrementalBackupSrc()) @@ -57,10 +57,10 @@ EExecutionStatus TMakeSnapshotUnit::Execute(TOperation::TPtr op, schemeTx.GetCreateIncrementalBackupSrc().GetSendSnapshot(); ui64 tableId = snapshot.GetTableId_Deprecated(); if (snapshot.HasTableId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == snapshot.GetTableId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == snapshot.GetTableId().GetOwnerId()); tableId = snapshot.GetTableId().GetTableId(); } - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); ui32 localTableId = DataShard.GetUserTables().at(tableId)->LocalTid; const auto& openTxs = txc.DB.GetOpenTxs(localTableId); TIntrusivePtr<TTableSnapshotContext> snapContext @@ -71,7 +71,7 @@ EExecutionStatus TMakeSnapshotUnit::Execute(TOperation::TPtr op, return EExecutionStatus::Continue; } - Y_ABORT_UNLESS(!op->InputSnapshots().empty()); + Y_ENSURE(!op->InputSnapshots().empty()); op->ResetWaitingForSnapshotFlag(); return EExecutionStatus::Executed; diff --git a/ydb/core/tx/datashard/memory_state_migration.cpp b/ydb/core/tx/datashard/memory_state_migration.cpp index 49ea8f109a..f8c32d223f 100644 --- a/ydb/core/tx/datashard/memory_state_migration.cpp +++ b/ydb/core/tx/datashard/memory_state_migration.cpp @@ -49,7 +49,7 @@ private: void Restored() { auto* owner = Owner; - Y_ABORT_UNLESS(owner); + Y_ENSURE(owner); if (Locks) { owner->SysLocks.RestoreInMemoryLocks(std::move(Locks)); @@ -123,7 +123,7 @@ private: } for (size_t chunkSize : Checkpoints) { - Y_ABORT_UNLESS(chunkSize <= Buffer.size(), "Unexpected end of buffer"); + Y_ENSURE(chunkSize <= Buffer.size(), "Unexpected end of buffer"); NKikimrTxDataShard::TInMemoryState* state = google::protobuf::Arena::CreateMessage<NKikimrTxDataShard::TInMemoryState>(&Arena); { @@ -300,8 +300,8 @@ public: } void PreserveState() { - Y_ABORT_UNLESS(Owner, "Unexpected call from a detached tablet"); - Y_ABORT_UNLESS(Owner->InMemoryStateActor == this, "Unexpected call while state actor is not attached"); + Y_ENSURE(Owner, "Unexpected call from a detached tablet"); + Y_ENSURE(Owner->InMemoryStateActor == this, "Unexpected call while state actor is not attached"); auto state = Owner->PreserveInMemoryState(); @@ -367,7 +367,7 @@ public: if (msg->Record.HasContinuationToken()) { NKikimrTxDataShard::TInMemoryStateContinuationToken token; bool ok = token.ParseFromString(msg->Record.GetContinuationToken()); - Y_ABORT_UNLESS(ok, "Cannot parse continuation token"); + Y_ENSURE(ok, "Cannot parse continuation token"); nextIndex = token.GetNextIndex(); } @@ -384,7 +384,7 @@ public: NKikimrTxDataShard::TInMemoryStateContinuationToken token; token.SetNextIndex(nextIndex); bool ok = token.SerializeToString(res->Record.MutableContinuationToken()); - Y_ABORT_UNLESS(ok, "Cannot serialize continuation token"); + Y_ENSURE(ok, "Cannot serialize continuation token"); } } @@ -466,17 +466,17 @@ public: } // We should have at least 1 byte available - Y_ABORT_UNLESS(WriteIndex < Buffers.size()); + Y_ENSURE(WriteIndex < Buffers.size()); if (Buffers[WriteIndex].size() == Buffers[WriteIndex].capacity()) { ++WriteIndex; - Y_ABORT_UNLESS(WriteIndex < Buffers.size()); + Y_ENSURE(WriteIndex < Buffers.size()); } TString& buffer = Buffers[WriteIndex]; - Y_ABORT_UNLESS(buffer.size() < buffer.capacity()); + Y_ENSURE(buffer.size() < buffer.capacity()); size_t oldSize = buffer.size(); size_t newSize = buffer.capacity(); buffer.resize(newSize); - Y_ABORT_UNLESS(buffer.capacity() == newSize); + Y_ENSURE(buffer.capacity() == newSize); Written += newSize - oldSize; Reserved -= newSize - oldSize; *data = buffer.Detach() + oldSize; @@ -485,13 +485,13 @@ public: } void BackUp(int count) override { - Y_ABORT_UNLESS(count >= 0); - Y_ABORT_UNLESS(WriteIndex < Buffers.size()); + Y_ENSURE(count >= 0); + Y_ENSURE(WriteIndex < Buffers.size()); TString& buffer = Buffers[WriteIndex]; - Y_ABORT_UNLESS(buffer.size() >= (size_t)count); + Y_ENSURE(buffer.size() >= (size_t)count); size_t oldCapacity = buffer.capacity(); buffer.resize(buffer.size() - (size_t)count); - Y_ABORT_UNLESS(buffer.capacity() == oldCapacity); + Y_ENSURE(buffer.capacity() == oldCapacity); Reserved += count; Written -= count; } @@ -530,7 +530,7 @@ TDataShard::TPreservedInMemoryState TDataShard::PreserveInMemoryState() { auto flushState = [&]() { stream.Reserve(state->ByteSizeLong()); bool ok = state->SerializeToZeroCopyStream(&stream); - Y_ABORT_UNLESS(ok, "Unexpected failure to serialize in-memory state"); + Y_ENSURE(ok, "Unexpected failure to serialize in-memory state"); }; auto resetState = [&]() { diff --git a/ydb/core/tx/datashard/move_index_unit.cpp b/ydb/core/tx/datashard/move_index_unit.cpp index 683a369ad9..5b2f74f1ad 100644 --- a/ydb/core/tx/datashard/move_index_unit.cpp +++ b/ydb/core/tx/datashard/move_index_unit.cpp @@ -43,10 +43,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (tx->GetSchemeTxType() != TSchemaOperation::ETypeMoveIndex) { return EExecutionStatus::Executed; diff --git a/ydb/core/tx/datashard/move_table_unit.cpp b/ydb/core/tx/datashard/move_table_unit.cpp index 3e34394e15..360a6676ff 100644 --- a/ydb/core/tx/datashard/move_table_unit.cpp +++ b/ydb/core/tx/datashard/move_table_unit.cpp @@ -43,10 +43,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (tx->GetSchemeTxType() != TSchemaOperation::ETypeMoveTable) { return EExecutionStatus::Executed; diff --git a/ydb/core/tx/datashard/operation.cpp b/ydb/core/tx/datashard/operation.cpp index 6963a5001b..88127b2508 100644 --- a/ydb/core/tx/datashard/operation.cpp +++ b/ydb/core/tx/datashard/operation.cpp @@ -67,7 +67,7 @@ void TOperation::AddInReadSet(const TReadSetKey &rsKey, << " to=" << rsKey.To << "origin=" << rsKey.Origin); InReadSets()[it->first].emplace_back(TRSData(readSet, rsKey.Origin)); if (it->second->IsComplete()) { - Y_ABORT_UNLESS(InputDataRef().RemainReadSets > 0, "RemainReadSets counter underflow"); + Y_ENSURE(InputDataRef().RemainReadSets > 0, "RemainReadSets counter underflow"); --InputDataRef().RemainReadSets; } } @@ -79,7 +79,7 @@ void TOperation::AddInReadSet(const TReadSetKey &rsKey, } void TOperation::AddDependency(const TOperation::TPtr &op) { - Y_ABORT_UNLESS(this != op.Get()); + Y_ENSURE(this != op.Get()); if (Dependencies.insert(op).second) { op->Dependents.insert(this); @@ -87,7 +87,7 @@ void TOperation::AddDependency(const TOperation::TPtr &op) { } void TOperation::AddSpecialDependency(const TOperation::TPtr &op) { - Y_ABORT_UNLESS(this != op.Get()); + Y_ENSURE(this != op.Get()); if (SpecialDependencies.insert(op).second) { op->SpecialDependents.insert(this); @@ -95,7 +95,7 @@ void TOperation::AddSpecialDependency(const TOperation::TPtr &op) { } void TOperation::AddImmediateConflict(const TOperation::TPtr &op) { - Y_ABORT_UNLESS(this != op.Get()); + Y_ENSURE(this != op.Get()); Y_DEBUG_ABORT_UNLESS(!IsImmediate()); Y_DEBUG_ABORT_UNLESS(op->IsImmediate()); @@ -184,7 +184,7 @@ void TOperation::ClearImmediateConflicts() { } void TOperation::AddRepeatableReadConflict(const TOperation::TPtr &op) { - Y_ABORT_UNLESS(this != op.Get()); + Y_ENSURE(this != op.Get()); Y_DEBUG_ABORT_UNLESS(IsImmediate()); Y_DEBUG_ABORT_UNLESS(!op->IsImmediate()); @@ -199,7 +199,7 @@ void TOperation::AddRepeatableReadConflict(const TOperation::TPtr &op) { } void TOperation::PromoteRepeatableReadConflicts() { - Y_ABORT_UNLESS(IsImmediate()); + Y_ENSURE(IsImmediate()); for (auto& op : RepeatableReadConflicts) { Y_DEBUG_ABORT_UNLESS(op->RepeatableReadConflicts.contains(this)); @@ -279,7 +279,7 @@ void TOperation::AdvanceExecutionPlan() profile.WaitTime = now - ExecutionProfile.StartUnitAt - profile.ExecuteTime - profile.CommitTime - profile.CompleteTime - profile.DelayedCommitTime; - Y_ABORT_UNLESS(!IsExecutionPlanFinished()); + Y_ENSURE(!IsExecutionPlanFinished()); ++CurrentUnit; ExecutionProfile.StartUnitAt = now; diff --git a/ydb/core/tx/datashard/operation.h b/ydb/core/tx/datashard/operation.h index 30c2616d1f..3621d26f6f 100644 --- a/ydb/core/tx/datashard/operation.h +++ b/ydb/core/tx/datashard/operation.h @@ -74,7 +74,7 @@ struct TStepOrder { } ETxOrder CheckOrder(const TStepOrder& stepTxId) const { - Y_ABORT_UNLESS(*this != stepTxId); // avoid self checks + Y_ENSURE(*this != stepTxId); // avoid self checks if (!Step && !stepTxId.Step) // immediate vs immediate return ETxOrder::Any; if (!Step || !stepTxId.Step) // planned vs immediate @@ -261,7 +261,7 @@ public: bool HasReadOnlyFlag() const { return HasFlag(TTxFlags::ReadOnly); } void SetReadOnlyFlag(bool val = true) { - Y_ABORT_UNLESS(!val || !IsGlobalWriter()); + Y_ENSURE(!val || !IsGlobalWriter()); SetFlag(TTxFlags::ReadOnly, val); } void ResetReadOnlyFlag() { ResetFlag(TTxFlags::ReadOnly); } @@ -286,7 +286,7 @@ public: bool HasGlobalWriterFlag() const { return HasFlag(TTxFlags::GlobalWriter); } void SetGlobalWriterFlag(bool val = true) { - Y_ABORT_UNLESS(!val || !IsReadOnly()); + Y_ENSURE(!val || !IsReadOnly()); SetFlag(TTxFlags::GlobalWriter, val); } void ResetGlobalWriterFlag() { ResetFlag(TTxFlags::GlobalWriter); } diff --git a/ydb/core/tx/datashard/prefix_kmeans.cpp b/ydb/core/tx/datashard/prefix_kmeans.cpp index 49a9da4c5d..8543ab88b9 100644 --- a/ydb/core/tx/datashard/prefix_kmeans.cpp +++ b/ydb/core/tx/datashard/prefix_kmeans.cpp @@ -269,10 +269,10 @@ protected: << " Uploader: " << Uploader.ToString() << " ev->Sender: " << ev->Sender.ToString()); if (Uploader) { - Y_VERIFY_S(Uploader == ev->Sender, "Mismatch Uploader: " << Uploader.ToString() << " ev->Sender: " + Y_ENSURE(Uploader == ev->Sender, "Mismatch Uploader: " << Uploader.ToString() << " ev->Sender: " << ev->Sender.ToString() << Debug()); } else { - Y_ABORT_UNLESS(Driver == nullptr); + Y_ENSURE(Driver == nullptr); return; } @@ -715,7 +715,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvPrefixKMeansRequest::TPtr& ev, cons badRequest(TStringBuilder() << "Unknown table id: " << pathId.LocalPathId); return; } - Y_ABORT_UNLESS(*userTableIt); + Y_ENSURE(*userTableIt); const auto& userTable = **userTableIt; if (const auto* recCard = ScanManager.Get(id)) { diff --git a/ydb/core/tx/datashard/prepare_data_tx_in_rs_unit.cpp b/ydb/core/tx/datashard/prepare_data_tx_in_rs_unit.cpp index 8e3d177441..8e9894f831 100644 --- a/ydb/core/tx/datashard/prepare_data_tx_in_rs_unit.cpp +++ b/ydb/core/tx/datashard/prepare_data_tx_in_rs_unit.cpp @@ -43,7 +43,7 @@ EExecutionStatus TPrepareDataTxInRSUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (tx->IsTxDataReleased()) { switch (Pipeline.RestoreDataTx(tx, txc, ctx)) { @@ -52,12 +52,12 @@ EExecutionStatus TPrepareDataTxInRSUnit::Execute(TOperation::TPtr op, case ERestoreDataStatus::Restart: return EExecutionStatus::Restart; case ERestoreDataStatus::Error: - Y_ABORT("Failed to restore tx data: %s", tx->GetDataTx()->GetErrors().c_str()); + Y_ENSURE(false, "Failed to restore tx data: " << tx->GetDataTx()->GetErrors()); } } IEngineFlat *engine = tx->GetDataTx()->GetEngine(); - Y_VERIFY_S(engine, "missing engine for " << *op << " at " << DataShard.TabletID()); + Y_ENSURE(engine, "missing engine for " << *op << " at " << DataShard.TabletID()); // TODO: cancel tx in special execution unit. if (tx->GetDataTx()->CheckCancelled(DataShard.TabletID())) @@ -66,7 +66,7 @@ EExecutionStatus TPrepareDataTxInRSUnit::Execute(TOperation::TPtr op, try { auto &inReadSets = op->InReadSets(); auto result = engine->PrepareIncomingReadsets(); - Y_VERIFY_S(result == IEngineFlat::EResult::Ok, + Y_ENSURE(result == IEngineFlat::EResult::Ok, "Cannot prepare input RS for " << *op << " at " << DataShard.TabletID() << ": " << engine->GetErrors()); diff --git a/ydb/core/tx/datashard/prepare_distributed_erase_tx_in_rs_unit.cpp b/ydb/core/tx/datashard/prepare_distributed_erase_tx_in_rs_unit.cpp index e5d0d79bcd..1cda8c2a6e 100644 --- a/ydb/core/tx/datashard/prepare_distributed_erase_tx_in_rs_unit.cpp +++ b/ydb/core/tx/datashard/prepare_distributed_erase_tx_in_rs_unit.cpp @@ -18,10 +18,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext&, const TActorContext&) override { - Y_ABORT_UNLESS(op->IsDistributedEraseTx()); + Y_ENSURE(op->IsDistributedEraseTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); const auto& eraseTx = tx->GetDistributedEraseTx(); if (!eraseTx->HasDependencies()) { diff --git a/ydb/core/tx/datashard/prepare_kqp_data_tx_in_rs_unit.cpp b/ydb/core/tx/datashard/prepare_kqp_data_tx_in_rs_unit.cpp index 3a0ca72d5d..0e2782c827 100644 --- a/ydb/core/tx/datashard/prepare_kqp_data_tx_in_rs_unit.cpp +++ b/ydb/core/tx/datashard/prepare_kqp_data_tx_in_rs_unit.cpp @@ -32,7 +32,7 @@ EExecutionStatus TPrepareKqpDataTxInRSUnit::Execute(TOperation::TPtr op, TTransa const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (tx->IsTxDataReleased()) { switch (Pipeline.RestoreDataTx(tx, txc, ctx)) { @@ -41,7 +41,7 @@ EExecutionStatus TPrepareKqpDataTxInRSUnit::Execute(TOperation::TPtr op, TTransa case ERestoreDataStatus::Restart: return EExecutionStatus::Restart; case ERestoreDataStatus::Error: - Y_ABORT("Failed to restore tx data: %s", tx->GetDataTx()->GetErrors().c_str()); + Y_ENSURE(false, "Failed to restore tx data: " << tx->GetDataTx()->GetErrors()); } } @@ -55,14 +55,8 @@ EExecutionStatus TPrepareKqpDataTxInRSUnit::Execute(TOperation::TPtr op, TTransa return EExecutionStatus::Executed; } - try { - KqpPrepareInReadsets(op->InReadSets(), tx->GetDataTx()->GetKqpLocks(), - &tx->GetDataTx()->GetKqpTasksRunner(), DataShard.TabletID()); - } catch (const yexception& e) { - LOG_CRIT_S(ctx, NKikimrServices::TX_DATASHARD, "Exception while preparing in-readsets for KQP transaction " - << *op << " at " << DataShard.TabletID() << ": " << CurrentExceptionMessage()); - Y_FAIL_S("Unexpected exception in KQP in-readsets prepare: " << CurrentExceptionMessage()); - } + KqpPrepareInReadsets(op->InReadSets(), tx->GetDataTx()->GetKqpLocks(), + &tx->GetDataTx()->GetKqpTasksRunner(), DataShard.TabletID()); return EExecutionStatus::Executed; } diff --git a/ydb/core/tx/datashard/prepare_scheme_tx_in_rs_unit.cpp b/ydb/core/tx/datashard/prepare_scheme_tx_in_rs_unit.cpp index cc2cfeb5f1..0571ef5076 100644 --- a/ydb/core/tx/datashard/prepare_scheme_tx_in_rs_unit.cpp +++ b/ydb/core/tx/datashard/prepare_scheme_tx_in_rs_unit.cpp @@ -41,7 +41,7 @@ EExecutionStatus TPrepareSchemeTxInRSUnit::Execute(TOperation::TPtr op, const TActorContext &) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (schemeTx.HasReceiveSnapshot()) { diff --git a/ydb/core/tx/datashard/prepare_write_tx_in_rs_unit.cpp b/ydb/core/tx/datashard/prepare_write_tx_in_rs_unit.cpp index 778211aea7..38803a3e7f 100644 --- a/ydb/core/tx/datashard/prepare_write_tx_in_rs_unit.cpp +++ b/ydb/core/tx/datashard/prepare_write_tx_in_rs_unit.cpp @@ -30,7 +30,7 @@ bool TPrepareWriteTxInRSUnit::IsReadyToExecute(TOperation::TPtr) const { } EExecutionStatus TPrepareWriteTxInRSUnit::Execute(TOperation::TPtr op, TTransactionContext &txc, - const TActorContext &ctx) + const TActorContext &) { TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op); @@ -43,7 +43,7 @@ EExecutionStatus TPrepareWriteTxInRSUnit::Execute(TOperation::TPtr op, TTransact case ERestoreDataStatus::Restart: return EExecutionStatus::Restart; case ERestoreDataStatus::Error: - Y_ABORT("Failed to restore writeOp data: %s", writeTx->GetErrStr().c_str()); + Y_ENSURE(false, "Failed to restore writeOp data: " << writeTx->GetErrStr()); } } @@ -54,13 +54,7 @@ EExecutionStatus TPrepareWriteTxInRSUnit::Execute(TOperation::TPtr op, TTransact return EExecutionStatus::Executed; } - try { - KqpPrepareInReadsets(op->InReadSets(), writeTx->GetKqpLocks() ? writeTx->GetKqpLocks().value() : NKikimrDataEvents::TKqpLocks{}, nullptr, DataShard.TabletID()); - } catch (const yexception& e) { - LOG_CRIT_S(ctx, NKikimrServices::TX_DATASHARD, "Exception while preparing in-readsets for KQP transaction " - << *op << " at " << DataShard.TabletID() << ": " << CurrentExceptionMessage()); - Y_FAIL_S("Unexpected exception in KQP in-readsets prepare: " << CurrentExceptionMessage()); - } + KqpPrepareInReadsets(op->InReadSets(), writeTx->GetKqpLocks() ? writeTx->GetKqpLocks().value() : NKikimrDataEvents::TKqpLocks{}, nullptr, DataShard.TabletID()); return EExecutionStatus::Executed; } diff --git a/ydb/core/tx/datashard/protect_scheme_echoes_unit.cpp b/ydb/core/tx/datashard/protect_scheme_echoes_unit.cpp index b51e302300..898fdf8c8f 100644 --- a/ydb/core/tx/datashard/protect_scheme_echoes_unit.cpp +++ b/ydb/core/tx/datashard/protect_scheme_echoes_unit.cpp @@ -19,10 +19,10 @@ public: TTransactionContext &txc, const TActorContext &) override { - Y_ABORT_UNLESS(op->IsSchemeTx()); + Y_ENSURE(op->IsSchemeTx()); TActiveTransaction *activeTx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(activeTx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(activeTx, "cannot cast operation of kind " << op->GetKind()); const NKikimrTxDataShard::TFlatSchemeTransaction &tx = activeTx->GetSchemeTx(); TSchemeOpSeqNo seqNo(tx.GetSeqNo()); diff --git a/ydb/core/tx/datashard/range_ops.cpp b/ydb/core/tx/datashard/range_ops.cpp index 49e4124903..e9e24fbc8f 100644 --- a/ydb/core/tx/datashard/range_ops.cpp +++ b/ydb/core/tx/datashard/range_ops.cpp @@ -133,7 +133,7 @@ NKikimr::TTableRange NKikimr::Intersect(TConstArrayRef<NScheme::TTypeInfo> types return TTableRange(second.From, second.InclusiveFrom, first.To, first.InclusiveTo); } else { // if (cmpTF < 0) - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } } else if (cmpTT == 0) { //================= @@ -184,7 +184,7 @@ NKikimr::TTableRange NKikimr::Intersect(TConstArrayRef<NScheme::TTypeInfo> types second.To, second.InclusiveTo); } else { // cmpTT < 0 - Y_ABORT("unreachable"); + Y_ENSURE(false, "unreachable"); } } else { // if (cmpFT > 0) //================= @@ -224,7 +224,7 @@ TString NKikimr::DebugPrintRanges(TConstArrayRef<NScheme::TTypeInfo> types, } TString NKikimr::DebugPrintPoint(TConstArrayRef<NScheme::TTypeInfo> types, const TConstArrayRef<TCell> &point, const NScheme::TTypeRegistry& typeRegistry) { - Y_ABORT_UNLESS(types.size() >= point.size()); + Y_ENSURE(types.size() >= point.size()); TDbTupleRef pointRef(types.data(), point.data(), point.size()); return DbgPrintTuple(pointRef, typeRegistry); diff --git a/ydb/core/tx/datashard/read_iterator.h b/ydb/core/tx/datashard/read_iterator.h index 11945c89a5..0a7d62e479 100644 --- a/ydb/core/tx/datashard/read_iterator.h +++ b/ydb/core/tx/datashard/read_iterator.h @@ -99,7 +99,7 @@ struct TReadIteratorState { bool Ack(ui64 seqNo, ui64 rows, ui64 bytes) { if (LastAckSeqNo < seqNo && seqNo <= SeqNo) { size_t ackedIndex = seqNo - LastAckSeqNo - 1; - Y_ABORT_UNLESS(ackedIndex < Queue.size()); + Y_ENSURE(ackedIndex < Queue.size()); auto it = Queue.begin() + ackedIndex; diff --git a/ydb/core/tx/datashard/read_op_unit.cpp b/ydb/core/tx/datashard/read_op_unit.cpp index 584c8563a7..10220f3915 100644 --- a/ydb/core/tx/datashard/read_op_unit.cpp +++ b/ydb/core/tx/datashard/read_op_unit.cpp @@ -19,7 +19,7 @@ public: EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { IReadOperation* readOperation = dynamic_cast<IReadOperation*>(op.Get()); - Y_ABORT_UNLESS(readOperation); + Y_ENSURE(readOperation); auto status = readOperation->Execute(txc, ctx); if (status == EExecutionStatus::Restart || status == EExecutionStatus::Continue) @@ -33,7 +33,7 @@ public: void Complete(TOperation::TPtr op, const TActorContext& ctx) override { IReadOperation* readOperation = dynamic_cast<IReadOperation*>(op.Get()); - Y_ABORT_UNLESS(readOperation); + Y_ENSURE(readOperation); readOperation->Complete(ctx); } diff --git a/ydb/core/tx/datashard/read_table_scan.cpp b/ydb/core/tx/datashard/read_table_scan.cpp index 141a1b3eee..acc652ff5e 100644 --- a/ydb/core/tx/datashard/read_table_scan.cpp +++ b/ydb/core/tx/datashard/read_table_scan.cpp @@ -474,7 +474,7 @@ private: void Handle(TEvTxProcessing::TEvStreamDataAck::TPtr &, const TActorContext &ctx) { - Y_ABORT_UNLESS(PendingAcks); + Y_ENSURE(PendingAcks); --PendingAcks; LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, diff --git a/ydb/core/tx/datashard/read_table_scan_unit.cpp b/ydb/core/tx/datashard/read_table_scan_unit.cpp index 4ef0e9baea..b95e408f9e 100644 --- a/ydb/core/tx/datashard/read_table_scan_unit.cpp +++ b/ydb/core/tx/datashard/read_table_scan_unit.cpp @@ -64,7 +64,7 @@ EExecutionStatus TReadTableScanUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); // Pass aborted operations (e.g. while waiting for stream clearance, or because of a split/merge) if (op->Result() || op->HasResultSentFlag() || op->IsImmediate() && CheckRejectDataTx(op, ctx)) { @@ -96,7 +96,7 @@ EExecutionStatus TReadTableScanUnit::Execute(TOperation::TPtr op, const auto& record = tx->GetDataTx()->GetReadTableTransaction(); if (record.HasSnapshotStep() && record.HasSnapshotTxId()) { - Y_ABORT_UNLESS(op->HasAcquiredSnapshotKey(), "Missing snapshot reference in ReadTable tx"); + Y_ENSURE(op->HasAcquiredSnapshotKey(), "Missing snapshot reference in ReadTable tx"); bool wait = false; TRowVersion snapshot(record.GetSnapshotStep(), record.GetSnapshotTxId()); @@ -106,7 +106,7 @@ EExecutionStatus TReadTableScanUnit::Execute(TOperation::TPtr op, } op->AddVolatileDependency(info->TxId); bool ok = DataShard.GetVolatileTxManager().AttachWaitingRemovalOperation(info->TxId, op->GetTxId()); - Y_VERIFY_S(ok, "Unexpected failure to attach TxId# " << op->GetTxId() << " to volatile tx " << info->TxId); + Y_ENSURE(ok, "Unexpected failure to attach TxId# " << op->GetTxId() << " to volatile tx " << info->TxId); wait = true; } @@ -223,7 +223,7 @@ void TReadTableScanUnit::Abort(const TString &err, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); BuildResult(op)->AddError(NKikimrTxDataShard::TError::WRONG_SHARD_STATE, err); if (tx->GetScanSnapshotId()) { diff --git a/ydb/core/tx/datashard/receive_snapshot_cleanup_unit.cpp b/ydb/core/tx/datashard/receive_snapshot_cleanup_unit.cpp index d8f2f8e0e1..c8d6da5d7f 100644 --- a/ydb/core/tx/datashard/receive_snapshot_cleanup_unit.cpp +++ b/ydb/core/tx/datashard/receive_snapshot_cleanup_unit.cpp @@ -41,7 +41,7 @@ EExecutionStatus TReceiveSnapshotCleanupUnit::Execute(TOperation::TPtr op, const TActorContext &) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasReceiveSnapshot()) diff --git a/ydb/core/tx/datashard/receive_snapshot_unit.cpp b/ydb/core/tx/datashard/receive_snapshot_unit.cpp index 2f954ebcaf..c41c9da2f2 100644 --- a/ydb/core/tx/datashard/receive_snapshot_unit.cpp +++ b/ydb/core/tx/datashard/receive_snapshot_unit.cpp @@ -41,7 +41,7 @@ EExecutionStatus TReceiveSnapshotUnit::Execute(TOperation::TPtr op, const TActorContext &) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto &schemeTx = tx->GetSchemeTx(); if (!schemeTx.HasReceiveSnapshot()) @@ -49,18 +49,18 @@ EExecutionStatus TReceiveSnapshotUnit::Execute(TOperation::TPtr op, NIceDb::TNiceDb db(txc.DB); - Y_ABORT_UNLESS(schemeTx.HasCreateTable()); + Y_ENSURE(schemeTx.HasCreateTable()); const auto &createTableTx = schemeTx.GetCreateTable(); TPathId tableId(DataShard.GetPathOwnerId(), createTableTx.GetId_Deprecated()); if (createTableTx.HasPathId()) { - Y_ABORT_UNLESS(DataShard.GetPathOwnerId() == createTableTx.GetPathId().GetOwnerId()); + Y_ENSURE(DataShard.GetPathOwnerId() == createTableTx.GetPathId().GetOwnerId()); tableId.LocalPathId = createTableTx.GetPathId().GetLocalId(); } auto userTable = DataShard.FindUserTable(tableId); - Y_ABORT_UNLESS(userTable); + Y_ENSURE(userTable); bool hasOpenTxs = false; bool loanedTables = false; @@ -75,7 +75,7 @@ EExecutionStatus TReceiveSnapshotUnit::Execute(TOperation::TPtr op, const bool ok = rs.ParseFromArray( rsdata.Body.data() + SnapshotTransferReadSetMagic.size(), rsdata.Body.size() - SnapshotTransferReadSetMagic.size()); - Y_ABORT_UNLESS(ok, "Failed to parse snapshot transfer readset"); + Y_ENSURE(ok, "Failed to parse snapshot transfer readset"); TString compressedBody = rs.GetBorrowedSnapshot(); snapBody = NBlockCodecs::Codec("lz4fast")->Decode(compressedBody); @@ -114,7 +114,7 @@ EExecutionStatus TReceiveSnapshotUnit::Execute(TOperation::TPtr op, DataShard.PersistLastLoanTableTid(db, userTable->LocalTid); } - Y_ABORT_UNLESS(DataShard.GetSnapshotManager().GetSnapshots().empty(), + Y_ENSURE(DataShard.GetSnapshotManager().GetSnapshots().empty(), "Found unexpected persistent snapshots at CopyTable destination"); const auto minVersion = DataShard.GetSnapshotManager().GetLowWatermark(); diff --git a/ydb/core/tx/datashard/reshuffle_kmeans.cpp b/ydb/core/tx/datashard/reshuffle_kmeans.cpp index dcf2e2069b..4ea24494c1 100644 --- a/ydb/core/tx/datashard/reshuffle_kmeans.cpp +++ b/ydb/core/tx/datashard/reshuffle_kmeans.cpp @@ -214,10 +214,10 @@ protected: << " ev->Sender: " << ev->Sender.ToString()); if (Uploader) { - Y_VERIFY_S(Uploader == ev->Sender, "Mismatch Uploader: " << Uploader.ToString() << " ev->Sender: " + Y_ENSURE(Uploader == ev->Sender, "Mismatch Uploader: " << Uploader.ToString() << " ev->Sender: " << ev->Sender.ToString() << Debug()); } else { - Y_ABORT_UNLESS(Driver == nullptr); + Y_ENSURE(Driver == nullptr); return; } @@ -420,7 +420,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvReshuffleKMeansRequest::TPtr& ev, c badRequest(TStringBuilder() << "Unknown table id: " << pathId.LocalPathId); return; } - Y_ABORT_UNLESS(*userTableIt); + Y_ENSURE(*userTableIt); const auto& userTable = **userTableIt; if (const auto* recCard = ScanManager.Get(id)) { diff --git a/ydb/core/tx/datashard/restore_unit.cpp b/ydb/core/tx/datashard/restore_unit.cpp index 2652a4f981..cc3990371c 100644 --- a/ydb/core/tx/datashard/restore_unit.cpp +++ b/ydb/core/tx/datashard/restore_unit.cpp @@ -26,13 +26,13 @@ protected: bool Run(TOperation::TPtr op, TTransactionContext&, const TActorContext& ctx) override { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); - Y_ABORT_UNLESS(tx->GetSchemeTx().HasRestore()); + Y_ENSURE(tx->GetSchemeTx().HasRestore()); const auto& restore = tx->GetSchemeTx().GetRestore(); const ui64 tableId = restore.GetTableId(); - Y_ABORT_UNLESS(DataShard.GetUserTables().contains(tableId)); + Y_ENSURE(DataShard.GetUserTables().contains(tableId)); const TTableInfo tableInfo = TTableInfo(tableId, DataShard.GetUserTables().at(tableId)); @@ -62,7 +62,7 @@ protected: bool ProcessResult(TOperation::TPtr op, const TActorContext&) override { TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto* result = CheckedCast<TImportJobProduct*>(op->AsyncJobResult().Get()); auto* schemeOp = DataShard.FindSchemaTx(op->GetTxId()); diff --git a/ydb/core/tx/datashard/sample_k.cpp b/ydb/core/tx/datashard/sample_k.cpp index 2aaaf6ce93..c904dfd53e 100644 --- a/ydb/core/tx/datashard/sample_k.cpp +++ b/ydb/core/tx/datashard/sample_k.cpp @@ -97,7 +97,7 @@ public: } EScan Seek(TLead& lead, ui64 seq) final { - Y_ABORT_UNLESS(seq == 0); + Y_ENSURE(seq == 0); LOG_D("Seek " << Debug()); auto scanRange = Intersect(KeyTypes, RequestedRange.ToTableRange(), TableRange.ToTableRange()); @@ -149,7 +149,7 @@ public: } TAutoPtr<IDestructable> Finish(EAbort abort) final { - Y_ABORT_UNLESS(Response); + Y_ENSURE(Response); Response->Record.SetReadRows(ReadRows); Response->Record.SetReadBytes(ReadBytes); if (abort == EAbort::None) { @@ -273,7 +273,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvSampleKRequest::TPtr& ev, const TAc badRequest(TStringBuilder() << "Unknown table id: " << pathId.LocalPathId); return; } - Y_ABORT_UNLESS(*userTableIt); + Y_ENSURE(*userTableIt); const auto& userTable = **userTableIt; if (const auto* recCard = ScanManager.Get(id)) { diff --git a/ydb/core/tx/datashard/scan_common.h b/ydb/core/tx/datashard/scan_common.h index c035f69218..0ed5942110 100644 --- a/ydb/core/tx/datashard/scan_common.h +++ b/ydb/core/tx/datashard/scan_common.h @@ -30,24 +30,24 @@ struct TScanRecord { class TScanManager { public: const TScanRecord* Get(ui64 id) const { - Y_ABORT_UNLESS(id != 0); + Y_ENSURE(id != 0); if (Id == id) { return &Record; } - Y_ABORT_UNLESS(Id == 0); + Y_ENSURE(Id == 0); return nullptr; } TScanRecord::TScanIds& Set(ui64 id, TScanRecord::TSeqNo seqNo) { - Y_ABORT_UNLESS(id != 0); - Y_ABORT_UNLESS(Id == 0); + Y_ENSURE(id != 0); + Y_ENSURE(Id == 0); Id = id; Record.SeqNo = seqNo; return Record.ScanIds; } void Drop(ui64 id) { - Y_ABORT_UNLESS(Get(id) == &Record); + Y_ENSURE(Get(id) == &Record); Id = 0; Record = {}; } diff --git a/ydb/core/tx/datashard/store_and_send_out_rs_unit.cpp b/ydb/core/tx/datashard/store_and_send_out_rs_unit.cpp index e809c4209c..402c725093 100644 --- a/ydb/core/tx/datashard/store_and_send_out_rs_unit.cpp +++ b/ydb/core/tx/datashard/store_and_send_out_rs_unit.cpp @@ -44,7 +44,7 @@ EExecutionStatus TStoreAndSendOutRSUnit::Execute(TOperation::TPtr op, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); bool newArtifact = false; // TODO: move artifact flags into operation flags. diff --git a/ydb/core/tx/datashard/store_commit_writes_tx_unit.cpp b/ydb/core/tx/datashard/store_commit_writes_tx_unit.cpp index 4e793e9bf0..14a612de2a 100644 --- a/ydb/core/tx/datashard/store_commit_writes_tx_unit.cpp +++ b/ydb/core/tx/datashard/store_commit_writes_tx_unit.cpp @@ -17,10 +17,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsCommitWritesTx()); + Y_ENSURE(op->IsCommitWritesTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); Pipeline.ProposeTx(op, tx->GetTxBody(), txc, ctx); tx->ClearTxBody(); diff --git a/ydb/core/tx/datashard/store_data_tx_unit.cpp b/ydb/core/tx/datashard/store_data_tx_unit.cpp index e983739b37..3e98657a7f 100644 --- a/ydb/core/tx/datashard/store_data_tx_unit.cpp +++ b/ydb/core/tx/datashard/store_data_tx_unit.cpp @@ -41,13 +41,13 @@ EExecutionStatus TStoreDataTxUnit::Execute(TOperation::TPtr op, TTransactionContext &txc, const TActorContext &ctx) { - Y_ABORT_UNLESS(op->IsDataTx() || op->IsReadTable()); - Y_ABORT_UNLESS(!op->IsAborted() && !op->IsInterrupted()); + Y_ENSURE(op->IsDataTx() || op->IsReadTable()); + Y_ENSURE(!op->IsAborted() && !op->IsInterrupted()); TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); auto dataTx = tx->GetDataTx(); - Y_ABORT_UNLESS(dataTx); + Y_ENSURE(dataTx); bool cached = Pipeline.SaveForPropose(dataTx); if (cached) { diff --git a/ydb/core/tx/datashard/store_distributed_erase_tx_unit.cpp b/ydb/core/tx/datashard/store_distributed_erase_tx_unit.cpp index 633a125228..5fb68f6e1f 100644 --- a/ydb/core/tx/datashard/store_distributed_erase_tx_unit.cpp +++ b/ydb/core/tx/datashard/store_distributed_erase_tx_unit.cpp @@ -17,10 +17,10 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsDistributedEraseTx()); + Y_ENSURE(op->IsDistributedEraseTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); Pipeline.ProposeTx(op, tx->GetTxBody(), txc, ctx); tx->ClearTxBody(); diff --git a/ydb/core/tx/datashard/store_scheme_tx_unit.cpp b/ydb/core/tx/datashard/store_scheme_tx_unit.cpp index b8d11680f0..b47aec58d2 100644 --- a/ydb/core/tx/datashard/store_scheme_tx_unit.cpp +++ b/ydb/core/tx/datashard/store_scheme_tx_unit.cpp @@ -41,18 +41,18 @@ EExecutionStatus TStoreSchemeTxUnit::Execute(TOperation::TPtr op, TTransactionContext &txc, const TActorContext &ctx) { - Y_ABORT_UNLESS(op->IsSchemeTx()); - Y_ABORT_UNLESS(!op->IsAborted() && !op->IsInterrupted()); + Y_ENSURE(op->IsSchemeTx()); + Y_ENSURE(!op->IsAborted() && !op->IsInterrupted()); TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); ui64 ssTabletId = tx->GetSchemeShardId(); if (DataShard.GetCurrentSchemeShardId() == INVALID_TABLET_ID) { DataShard.PersistCurrentSchemeShardId(ssTabletId, txc); } else { - Y_ABORT_UNLESS(DataShard.GetCurrentSchemeShardId() == ssTabletId, - "Got scheme transaction from unknown SchemeShard %" PRIu64, ssTabletId); + Y_ENSURE(DataShard.GetCurrentSchemeShardId() == ssTabletId, + "Got scheme transaction from unknown SchemeShard " << ssTabletId); } if (ui64 subDomainPathId = tx->GetSubDomainPathId()) { diff --git a/ydb/core/tx/datashard/store_snapshot_tx_unit.cpp b/ydb/core/tx/datashard/store_snapshot_tx_unit.cpp index 6acd125259..be9ed967cb 100644 --- a/ydb/core/tx/datashard/store_snapshot_tx_unit.cpp +++ b/ydb/core/tx/datashard/store_snapshot_tx_unit.cpp @@ -16,9 +16,9 @@ public: } EExecutionStatus Execute(TOperation::TPtr op, TTransactionContext& txc, const TActorContext& ctx) override { - Y_ABORT_UNLESS(op->IsSnapshotTx()); + Y_ENSURE(op->IsSnapshotTx()); TActiveTransaction* tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); Pipeline.ProposeTx(op, tx->GetTxBody(), txc, ctx); tx->ClearTxBody(); diff --git a/ydb/core/tx/datashard/store_write_unit.cpp b/ydb/core/tx/datashard/store_write_unit.cpp index 7e71888d27..7131b2cd6e 100644 --- a/ydb/core/tx/datashard/store_write_unit.cpp +++ b/ydb/core/tx/datashard/store_write_unit.cpp @@ -42,11 +42,11 @@ EExecutionStatus TStoreWriteUnit::Execute(TOperation::TPtr op, TTransactionContext &txc, const TActorContext &ctx) { - Y_ABORT_UNLESS(!op->IsAborted() && !op->IsInterrupted()); + Y_ENSURE(!op->IsAborted() && !op->IsInterrupted()); TWriteOperation* writeOp = TWriteOperation::CastWriteOperation(op); auto writeTx = writeOp->GetWriteTx(); - Y_ABORT_UNLESS(writeTx); + Y_ENSURE(writeTx); bool cached = Pipeline.SaveForPropose(writeTx); if (cached) { diff --git a/ydb/core/tx/datashard/stream_scan_common.cpp b/ydb/core/tx/datashard/stream_scan_common.cpp index eb8e712919..185ee0cf48 100644 --- a/ydb/core/tx/datashard/stream_scan_common.cpp +++ b/ydb/core/tx/datashard/stream_scan_common.cpp @@ -16,7 +16,7 @@ TLimits::TLimits(const NKikimrTxDataShard::TEvCdcStreamScanRequest_TLimits& prot TVector<TRawTypeValue> MakeKey(TArrayRef<const TCell> cells, const TVector<NScheme::TTypeInfo>& keyColumnTypes) { TVector<TRawTypeValue> key(Reserve(cells.size())); - Y_ABORT_UNLESS(cells.size() == keyColumnTypes.size()); + Y_ENSURE(cells.size() == keyColumnTypes.size()); for (TPos pos = 0; pos < cells.size(); ++pos) { key.emplace_back(cells.at(pos).AsRef(), keyColumnTypes.at(pos).GetTypeId()); } diff --git a/ydb/core/tx/datashard/type_serialization.cpp b/ydb/core/tx/datashard/type_serialization.cpp index 4a49dda810..d48f630b39 100644 --- a/ydb/core/tx/datashard/type_serialization.cpp +++ b/ydb/core/tx/datashard/type_serialization.cpp @@ -24,14 +24,14 @@ TString DyNumberToString(TStringBuf data) { TStringBuilder err; bool success = DyNumberToStream(data, out, err); - Y_ABORT_UNLESS(success); + Y_ENSURE(success); return result; } TString PgToString(TStringBuf data, const NScheme::TTypeInfo& typeInfo) { const NPg::TConvertResult& pgResult = NPg::PgNativeTextFromNativeBinary(data, typeInfo.GetPgTypeDesc()); - Y_ABORT_UNLESS(pgResult.Error.Empty()); + Y_ENSURE(pgResult.Error.Empty()); return pgResult.Str; } diff --git a/ydb/core/tx/datashard/ut_common/datashard_ut_common.cpp b/ydb/core/tx/datashard/ut_common/datashard_ut_common.cpp index 5eee9b7e84..3f950eb4aa 100644 --- a/ydb/core/tx/datashard/ut_common/datashard_ut_common.cpp +++ b/ydb/core/tx/datashard/ut_common/datashard_ut_common.cpp @@ -156,7 +156,7 @@ TTester::TTester(ESchema schema, const TString& dispatchName, std::function<void void TTester::EmptyShardKeyResolver(TKeyDesc& key) { Y_UNUSED(key); - Y_ABORT(); + Y_ENSURE(false); } void TTester::SingleShardKeyResolver(TKeyDesc& key) { @@ -355,7 +355,7 @@ TRuntimeNode TEngineHolder::ProgramText2Bin(TTester& tester, const TString& prog ); const TDuration TIME_LIMIT = TDuration::Seconds(NValgrind::PlainOrUnderValgrind(60, 300)); - Y_ABORT_UNLESS(resFuture.Wait(TIME_LIMIT), "ProgramText2Bin is taking too long to compile"); + Y_ENSURE(resFuture.Wait(TIME_LIMIT), "ProgramText2Bin is taking too long to compile"); NYql::TConvertResult res = resFuture.GetValue(); res.Errors.PrintTo(Cerr); UNIT_ASSERT(res.Node.GetNode()); @@ -946,7 +946,7 @@ ui64 TFakeMiniKQLProxy::Plan(ui64 stepId, const TMap<ui64, TFakeProxyTx::TPtr>& RebootTablet(Tester.Runtime, TTestTxConfig::TxTablet0, Tester.Sender); } - Y_ABORT_UNLESS(delayedEvent); + Y_ENSURE(delayedEvent); DelayedReadSets.clear(); Tester.Runtime.Send(delayedEvent.Release()); Cerr << "resending delayed RS" << Endl; @@ -1427,12 +1427,12 @@ TRowVersion GrabCreateVolatileSnapshotResult( auto ev = runtime.GrabEdgeEventRethrow<TEvTxUserProxy::TEvProposeTransactionStatus>(sender); const auto& record = ev->Get()->Record; auto status = static_cast<TEvTxUserProxy::TEvProposeTransactionStatus::EStatus>(record.GetStatus()); - Y_VERIFY_S(status == TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecComplete, + Y_ENSURE(status == TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecComplete, "Unexpected status " << status); auto step = record.GetStep(); auto txId = record.GetTxId(); - Y_VERIFY_S(step != 0 && txId != 0, + Y_ENSURE(step != 0 && txId != 0, "Unexpected step " << step << " and txId " << txId); return { step, txId }; @@ -1558,12 +1558,12 @@ TRowVersion CommitWrites( auto ev = runtime.GrabEdgeEventRethrow<TEvTxUserProxy::TEvProposeTransactionStatus>(sender); const auto& record = ev->Get()->Record; auto status = static_cast<TEvTxUserProxy::TEvProposeTransactionStatus::EStatus>(record.GetStatus()); - Y_VERIFY_S(status == TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecComplete, + Y_ENSURE(status == TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecComplete, "Unexpected status " << status); auto step = record.GetStep(); auto txId = record.GetTxId(); - Y_VERIFY_S(txId != 0, + Y_ENSURE(txId != 0, "Unexpected step " << step << " and txId " << txId); return { step, txId }; @@ -2118,7 +2118,7 @@ void AddValueToCells(ui64 value, const TString& columnType, TVector<TCell>& cell stringValues.emplace_back(Sprintf("String_%" PRIu64, value)); cells.emplace_back(TCell(stringValues.back().c_str(), stringValues.back().size())); } else { - Y_ABORT("Unsupported column type"); + Y_ENSURE(false, "Unsupported column type " << columnType); } } @@ -2412,7 +2412,7 @@ namespace { case TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecResponseData: { const auto rsData = msg->Record.GetSerializedReadTableResponse(); Ydb::ResultSet rsParsed; - Y_ABORT_UNLESS(rsParsed.ParseFromString(rsData)); + Y_ENSURE(rsParsed.ParseFromString(rsData)); NYdb::TResultSet rs(rsParsed); auto& columns = rs.GetColumnsMeta(); NYdb::TResultSetParser parser(rs); @@ -2467,7 +2467,7 @@ namespace { } void Handle(TEvResume::TPtr&, const TActorContext& ctx) { - Y_ABORT_UNLESS(State == EState::PauseSent); + Y_ENSURE(State == EState::PauseSent); State = EState::Normal; SendQuotas(ctx); } @@ -2508,7 +2508,7 @@ namespace { break; default: - Y_ABORT("Unhandled"); + Y_ENSURE(false, "Unhandled"); } } @@ -2532,7 +2532,7 @@ namespace { PRINT_PRIMITIVE(DyNumber); default: - Y_ABORT("Unhandled"); + Y_ENSURE(false, "Unhandled"); } #undef PRINT_PRIMITIVE diff --git a/ydb/core/tx/datashard/ut_common/datashard_ut_common.h b/ydb/core/tx/datashard/ut_common/datashard_ut_common.h index 3381b4dae7..c000653342 100644 --- a/ydb/core/tx/datashard/ut_common/datashard_ut_common.h +++ b/ydb/core/tx/datashard/ut_common/datashard_ut_common.h @@ -828,7 +828,7 @@ class TEvWriteRows : public std::vector<TEvWriteRow> { const TEvWriteRow& ProcessRow(const TTableId& tableId, ui64 txId) { bool allTablesEmpty = std::all_of(begin(), end(), [](const auto& row) { return !bool(row.TableId); }); auto row = std::find_if(begin(), end(), [tableId, allTablesEmpty](const auto& row) { return !row.IsUsed && (allTablesEmpty || row.TableId == tableId); }); - Y_VERIFY_S(row != end(), "There should be at least one EvWrite row to process."); + Y_ENSURE(row != end(), "There should be at least one EvWrite row to process."); row->IsUsed = true; Cerr << "Processing EvWrite row " << txId << Endl; diff --git a/ydb/core/tx/datashard/volatile_tx.cpp b/ydb/core/tx/datashard/volatile_tx.cpp index d3b75840fa..8cedff4ffe 100644 --- a/ydb/core/tx/datashard/volatile_tx.cpp +++ b/ydb/core/tx/datashard/volatile_tx.cpp @@ -11,7 +11,7 @@ namespace NKikimr::NDataShard { TVolatileTxPersistence(TVolatileTxInfo* info) : TxInfo(info) { - Y_ABORT_UNLESS(TxInfo && !TxInfo->Persistence); + Y_ENSURE(TxInfo && !TxInfo->Persistence); TxInfo->Persistence = this; } @@ -56,7 +56,7 @@ namespace NKikimr::NDataShard { NIceDb::TNiceDb db(txc.DB); - Y_ABORT_UNLESS(info && info->State == EVolatileTxState::Committed); + Y_ENSURE(info && info->State == EVolatileTxState::Committed); for (auto& pr : Self->GetUserTables()) { auto tid = pr.second->LocalTid; @@ -121,8 +121,8 @@ namespace NKikimr::NDataShard { void OnCommitted(const TActorContext& ctx) { auto* info = TxInfo; - Y_ABORT_UNLESS(info && info->State == EVolatileTxState::Committed); - Y_ABORT_UNLESS(info->AddCommitted); + Y_ENSURE(info && info->State == EVolatileTxState::Committed); + Y_ENSURE(info->AddCommitted); Self->VolatileTxManager.UnblockDependents(info); @@ -157,7 +157,7 @@ namespace NKikimr::NDataShard { return true; } - Y_ABORT_UNLESS(info && info->State == EVolatileTxState::Aborting); + Y_ENSURE(info && info->State == EVolatileTxState::Aborting); for (auto& pr : Self->GetUserTables()) { auto tid = pr.second->LocalTid; @@ -178,7 +178,7 @@ namespace NKikimr::NDataShard { TString bodyStr; bool ok = data.SerializeToString(&bodyStr); - Y_ABORT_UNLESS(ok, "Failed to serialize an abort decision readset"); + Y_ENSURE(ok, "Failed to serialize an abort decision readset"); NIceDb::TNiceDb db(txc.DB); for (ui64 seqNo : info->ArbiterReadSets) { @@ -201,8 +201,8 @@ namespace NKikimr::NDataShard { return; } - Y_ABORT_UNLESS(info && info->State == EVolatileTxState::Aborting); - Y_ABORT_UNLESS(info->AddCommitted); + Y_ENSURE(info && info->State == EVolatileTxState::Aborting); + Y_ENSURE(info->AddCommitted); for (auto& ev : info->DelayedAcks) { TActivationContext::Send(ev.Release()); @@ -267,7 +267,7 @@ namespace NKikimr::NDataShard { bool TVolatileTxManager::Load(NIceDb::TNiceDb& db) { using Schema = TDataShard::Schema; - Y_ABORT_UNLESS( + Y_ENSURE( VolatileTxs.empty() && VolatileTxByVersion.empty() && UnstableVolatileTxByVersion.empty() && @@ -310,7 +310,7 @@ namespace NKikimr::NDataShard { case EVolatileTxState::Aborting: RemoveFromCommitOrder(pr.second.get()); ScheduleAbortTx(pr.second.get()); - Y_ABORT("FIXME: unexpected persistent aborting state"); + Y_ENSURE(false, "FIXME: unexpected persistent aborting state"); break; } } @@ -333,12 +333,12 @@ namespace NKikimr::NDataShard { EVolatileTxState state = rowset.GetValue<Schema::TxVolatileDetails::State>(); auto details = rowset.GetValue<Schema::TxVolatileDetails::Details>(); - Y_VERIFY_S(txId == details.GetTxId(), + Y_ENSURE(txId == details.GetTxId(), "Volatile txId# " << txId << " has unexpected details with txId# " << details.GetTxId()); auto res = VolatileTxs.insert( std::make_pair(txId, std::make_unique<TVolatileTxInfo>())); - Y_VERIFY_S(res.second, "Unexpected duplicate volatile txId# " << txId); + Y_ENSURE(res.second, "Unexpected duplicate volatile txId# " << txId); auto* info = res.first->second.get(); info->TxId = txId; @@ -382,7 +382,7 @@ namespace NKikimr::NDataShard { // Note that aborting transactions are deleted and we should never observe it as a persistent state for (ui64 commitTxId : info->CommitTxIds) { auto res2 = VolatileTxByCommitTxId.emplace(commitTxId, info); - Y_VERIFY_S(res2.second, "Unexpected duplicate commitTxId# " << commitTxId); + Y_ENSURE(res2.second, "Unexpected duplicate commitTxId# " << commitTxId); TxMap->Add(commitTxId, info->Version); } @@ -405,12 +405,12 @@ namespace NKikimr::NDataShard { case EVolatileTxState::Aborting: { // Aborting transactions don't have dependencies info->Dependencies.clear(); - Y_ABORT("FIXME: unexpected persistent aborting state"); + Y_ENSURE(false, "FIXME: unexpected persistent aborting state"); return; } } - Y_VERIFY_S(false, "Unexpected volatile txId# " << info->TxId << " @" << info->Version << " with state# " << ui32(info->State)); + Y_ENSURE(false, "Unexpected volatile txId# " << info->TxId << " @" << info->Version << " with state# " << ui32(info->State)); }; for (auto& pr : VolatileTxs) { @@ -464,10 +464,10 @@ namespace NKikimr::NDataShard { ui64 shardId = rowset.GetValue<Schema::TxVolatileParticipants::ShardId>(); auto* info = (lastInfo && lastInfo->TxId == txId) ? lastInfo : FindByTxId(txId); - Y_VERIFY_S(info, "Unexpected failure to find volatile txId# " << txId); + Y_ENSURE(info, "Unexpected failure to find volatile txId# " << txId); // Only waiting transactions may have participants - Y_VERIFY_S(info->State == EVolatileTxState::Waiting, + Y_ENSURE(info->State == EVolatileTxState::Waiting, "Unexpected volatile txId# " << txId << " with participant# " << shardId << " in state# " << ui32(info->State)); @@ -483,7 +483,7 @@ namespace NKikimr::NDataShard { // Sanity check that are are no waiting transactions without participants if (info->State == EVolatileTxState::Waiting) { - Y_VERIFY_S(!info->Participants.empty(), + Y_ENSURE(!info->Participants.empty(), "Unexpected waiting volatile txId# " << info->TxId << " without participants"); } } @@ -519,12 +519,12 @@ namespace NKikimr::NDataShard { { using Schema = TDataShard::Schema; - Y_VERIFY_S(!commitTxIds.empty(), + Y_ENSURE(!commitTxIds.empty(), "Unexpected volatile txId# " << txId << " @" << version << " without commits"); auto res = VolatileTxs.insert( std::make_pair(txId, std::make_unique<TVolatileTxInfo>())); - Y_VERIFY_S(res.second, "Cannot add volatile txId# " << txId << " @" << version + Y_ENSURE(res.second, "Cannot add volatile txId# " << txId << " @" << version << ": duplicate volatile tx @" << res.first->second->Version << " already exists"); auto* info = res.first->second.get(); @@ -555,14 +555,14 @@ namespace NKikimr::NDataShard { for (ui64 commitTxId : commitTxIds) { auto res2 = VolatileTxByCommitTxId.emplace(commitTxId, info); - Y_VERIFY_S(res2.second, "Cannot add volatile txId# " << txId << " @" << version << " with commitTxId# " << commitTxId + Y_ENSURE(res2.second, "Cannot add volatile txId# " << txId << " @" << version << " with commitTxId# " << commitTxId << ": already registered for txId# " << res.first->second->TxId << " @" << res.first->second->Version); TxMap->Add(commitTxId, version); } for (ui64 dependencyTxId : info->Dependencies) { auto* dependency = FindByTxId(dependencyTxId); - Y_VERIFY_S(dependency, "Cannot find dependency txId# " << dependencyTxId + Y_ENSURE(dependency, "Cannot find dependency txId# " << dependencyTxId << " for volatile txId# " << txId << " @" << version); dependency->Dependents.insert(txId); } @@ -612,8 +612,8 @@ namespace NKikimr::NDataShard { }); txc.DB.OnPersistent([this, txId]() { auto* info = FindByTxId(txId); - Y_VERIFY_S(info, "Unexpected failure to find volatile txId# " << txId); - Y_VERIFY_S(!info->AddCommitted, "Unexpected commit of a committed volatile txId# " << txId); + Y_ENSURE(info, "Unexpected failure to find volatile txId# " << txId); + Y_ENSURE(!info->AddCommitted, "Unexpected commit of a committed volatile txId# " << txId); info->AddCommitted = true; if (info->State == EVolatileTxState::Committed) { RunCommitCallbacks(info); @@ -629,7 +629,7 @@ namespace NKikimr::NDataShard { void TVolatileTxManager::RollbackAddVolatileTx(ui64 txId) { auto* info = FindByTxId(txId); - Y_VERIFY_S(info, "Rollback cannot find volatile txId# " << txId); + Y_ENSURE(info, "Rollback cannot find volatile txId# " << txId); // Unlink dependencies for (ui64 dependencyTxId : info->Dependencies) { @@ -675,9 +675,9 @@ namespace NKikimr::NDataShard { ui64 txId = info->TxId; Y_VERIFY_DEBUG_S(FindByTxId(txId) == info, "Unexpected failure to find volatile tx " << txId); - Y_VERIFY_S(info->Dependencies.empty(), "Unexpected remove of volatile tx " << txId << " with dependencies"); - Y_VERIFY_S(info->Dependents.empty(), "Unexpected remove of volatile tx " << txId << " with dependents"); - Y_VERIFY_S(!info->IsInList<TVolatileTxInfoCommitOrderListTag>(), + Y_ENSURE(info->Dependencies.empty(), "Unexpected remove of volatile tx " << txId << " with dependencies"); + Y_ENSURE(info->Dependents.empty(), "Unexpected remove of volatile tx " << txId << " with dependents"); + Y_ENSURE(!info->IsInList<TVolatileTxInfoCommitOrderListTag>(), "Unexpected remove of volatile tx " << txId << " which is in commit order linked list"); UnblockWaitingRemovalOperations(info); @@ -717,7 +717,7 @@ namespace NKikimr::NDataShard { } bool TVolatileTxManager::AttachVolatileTxCallback(ui64 txId, IVolatileTxCallback::TPtr callback) { - Y_ABORT_UNLESS(callback, "Unexpected nullptr callback"); + Y_ENSURE(callback, "Unexpected nullptr callback"); auto it = VolatileTxs.find(txId); if (it == VolatileTxs.end()) { @@ -777,14 +777,14 @@ namespace NKikimr::NDataShard { } void TVolatileTxManager::AttachWaitingSnapshotEvent(const TRowVersion& snapshot, std::unique_ptr<IEventHandle>&& event) { - Y_ABORT_UNLESS(!VolatileTxByVersion.empty() && (*VolatileTxByVersion.begin())->Version <= snapshot); + Y_ENSURE(!VolatileTxByVersion.empty() && (*VolatileTxByVersion.begin())->Version <= snapshot); WaitingSnapshotEvents.emplace_back(snapshot, std::move(event)); std::push_heap(WaitingSnapshotEvents.begin(), WaitingSnapshotEvents.end()); } void TVolatileTxManager::AbortWaitingTransaction(TVolatileTxInfo* info) { - Y_ABORT_UNLESS(info && info->State == EVolatileTxState::Waiting); + Y_ENSURE(info && info->State == EVolatileTxState::Waiting); ui64 txId = info->TxId; @@ -794,7 +794,7 @@ namespace NKikimr::NDataShard { // Aborted transactions don't have dependencies for (ui64 dependencyTxId : info->Dependencies) { auto* dependency = FindByTxId(dependencyTxId); - Y_ABORT_UNLESS(dependency); + Y_ENSURE(dependency); dependency->Dependents.erase(txId); } info->Dependencies.clear(); @@ -822,7 +822,7 @@ namespace NKikimr::NDataShard { const ui64 txId = record.GetTxId(); auto* info = FindByTxId(txId); - Y_ABORT_UNLESS(info, "ProcessReadSet called for an unknown volatile tx"); + Y_ENSURE(info, "ProcessReadSet called for an unknown volatile tx"); switch (info->State) { case EVolatileTxState::Waiting: @@ -859,7 +859,7 @@ namespace NKikimr::NDataShard { bool committed = [&]() { if (record.GetFlags() & NKikimrTx::TEvReadSet::FLAG_NO_DATA) { - Y_ABORT_UNLESS(!(record.GetFlags() & NKikimrTx::TEvReadSet::FLAG_EXPECT_READSET), + Y_ENSURE(!(record.GetFlags() & NKikimrTx::TEvReadSet::FLAG_EXPECT_READSET), "Unexpected FLAG_EXPECT_READSET + FLAG_NO_DATA in ProcessReadSet"); LOG_TRACE_S(*TlsActivationContext, NKikimrServices::TX_DATASHARD, "Processed readset without data from " << srcTabletId << " to " << dstTabletId @@ -869,7 +869,7 @@ namespace NKikimr::NDataShard { NKikimrTx::TReadSetData data; bool ok = data.ParseFromString(record.GetReadSet()); - Y_ABORT_UNLESS(ok, "Failed to parse readset from %" PRIu64 " to %" PRIu64, srcTabletId, dstTabletId); + Y_ENSURE(ok, "Failed to parse readset from " << srcTabletId << " to " << dstTabletId); if (data.GetDecision() != NKikimrTx::TReadSetData::DECISION_COMMIT) { LOG_TRACE_S(*TlsActivationContext, NKikimrServices::TX_DATASHARD, @@ -991,7 +991,7 @@ namespace NKikimr::NDataShard { bool maybeUnblocked = false; for (ui64 dependentTxId : info->Dependents) { auto* dependent = FindByTxId(dependentTxId); - Y_VERIFY_S(dependent, "Unexpected failure to find dependent tx " + Y_ENSURE(dependent, "Unexpected failure to find dependent tx " << dependentTxId << " that depended on " << info->TxId); dependent->Dependencies.erase(info->TxId); if (dependent->Dependencies.empty()) { @@ -1005,7 +1005,7 @@ namespace NKikimr::NDataShard { } break; case EVolatileTxState::Aborting: - Y_ABORT("FIXME: unexpected dependency removed from aborting tx"); + Y_ENSURE(false, "FIXME: unexpected dependency removed from aborting tx"); break; } } @@ -1068,9 +1068,9 @@ namespace NKikimr::NDataShard { } bool TVolatileTxManager::RemoveFromCommitOrder(TVolatileTxInfo* info) { - Y_ABORT_UNLESS(info->IsInList<TVolatileTxInfoCommitOrderListTag>(), + Y_ENSURE(info->IsInList<TVolatileTxInfoCommitOrderListTag>(), "Volatile transaction is not in a commit order linked list"); - Y_ABORT_UNLESS(!VolatileTxByCommitOrder.Empty(), "Commit order linked list is unexpectedly empty"); + Y_ENSURE(!VolatileTxByCommitOrder.Empty(), "Commit order linked list is unexpectedly empty"); const bool wasFirst = VolatileTxByCommitOrder.Front() == info; VolatileTxByCommitOrder.Remove(info); return wasFirst; diff --git a/ydb/core/tx/datashard/wait_for_stream_clearance_unit.cpp b/ydb/core/tx/datashard/wait_for_stream_clearance_unit.cpp index 4cf47e8a32..7280f327cc 100644 --- a/ydb/core/tx/datashard/wait_for_stream_clearance_unit.cpp +++ b/ydb/core/tx/datashard/wait_for_stream_clearance_unit.cpp @@ -76,7 +76,7 @@ EExecutionStatus TWaitForStreamClearanceUnit::Execute(TOperation::TPtr op, } TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (!op->IsWaitingForStreamClearance()) { auto tid = tx->GetDataTx()->GetReadTableTransaction().GetTableId().GetTableId(); @@ -136,7 +136,7 @@ void TWaitForStreamClearanceUnit::Handle(TDataShard::TEvPrivate::TEvNodeDisconne { if (op->IsWaitingForStreamClearance()) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); if (ev->Get()->NodeId == tx->GetStreamSink().NodeId()) { Abort(TStringBuilder() << "Disconnected from stream sink (node " << ev->Get()->NodeId @@ -190,7 +190,7 @@ void TWaitForStreamClearanceUnit::Abort(const TString &err, const TActorContext &ctx) { TActiveTransaction *tx = dynamic_cast<TActiveTransaction*>(op.Get()); - Y_VERIFY_S(tx, "cannot cast operation of kind " << op->GetKind()); + Y_ENSURE(tx, "cannot cast operation of kind " << op->GetKind()); BuildResult(op)->AddError(NKikimrTxDataShard::TError::WRONG_SHARD_STATE, err); if (tx->GetScanSnapshotId()) { diff --git a/ydb/core/tx/locks/locks.cpp b/ydb/core/tx/locks/locks.cpp index 6162f84432..92f86e3c8b 100644 --- a/ydb/core/tx/locks/locks.cpp +++ b/ydb/core/tx/locks/locks.cpp @@ -69,7 +69,7 @@ ILocksDb::TLockRange TRangeKey::ToSerializedLockRange() const { protoRange.SetToInclusive(true); } bool ok = protoRange.SerializeToString(&range.Data); - Y_ABORT_UNLESS(ok, "Unexpected failure to serialize TRangeKey"); + Y_ENSURE(ok, "Unexpected failure to serialize TRangeKey"); return range; } @@ -146,7 +146,7 @@ void TLockInfo::MakeShardLock() { } bool TLockInfo::AddShardLock(const TPathId& pathId) { - Y_ABORT_UNLESS(IsShardLock()); + Y_ENSURE(IsShardLock()); Y_DEBUG_ABORT_UNLESS(Locker->FindTablePtr(pathId)); if (ReadTables.insert(pathId).second) { UnpersistedRanges = true; @@ -216,8 +216,8 @@ void TLockInfo::OnRemoved() { } void TLockInfo::PersistLock(ILocksDb* db) { - Y_ABORT_UNLESS(!IsPersistent()); - Y_ABORT_UNLESS(db, "Cannot persist lock without a db"); + Y_ENSURE(!IsPersistent()); + Y_ENSURE(db, "Cannot persist lock without a db"); db->PersistAddLock(LockId, LockNodeId, Generation, Counter, CreationTime.MicroSeconds(), ui64(Flags & ELockFlags::PersistentMask)); Flags |= ELockFlags::Persistent; @@ -226,14 +226,14 @@ void TLockInfo::PersistLock(ILocksDb* db) { } void TLockInfo::PersistBrokenLock(ILocksDb* db) { - Y_ABORT_UNLESS(IsPersistent()); - Y_ABORT_UNLESS(db, "Cannot persist lock without a db"); + Y_ENSURE(IsPersistent()); + Y_ENSURE(db, "Cannot persist lock without a db"); db->PersistLockCounter(LockId, Max<ui64>()); } void TLockInfo::PersistRemoveLock(ILocksDb* db) { - Y_ABORT_UNLESS(IsPersistent()); - Y_ABORT_UNLESS(db, "Cannot persist lock without a db"); + Y_ENSURE(IsPersistent()); + Y_ENSURE(db, "Cannot persist lock without a db"); // Remove persistent volatile dependencies for (ui64 txId : VolatileDependencies) { @@ -267,7 +267,7 @@ void TLockInfo::PersistRemoveLock(ILocksDb* db) { } void TLockInfo::PersistRanges(ILocksDb* db) { - Y_ABORT_UNLESS(IsPersistent()); + Y_ENSURE(IsPersistent()); if (UnpersistedRanges) { for (const TPathId& pathId : ReadTables) { PersistAddRange(pathId, ELockRangeFlags::Read, db); @@ -280,8 +280,8 @@ void TLockInfo::PersistRanges(ILocksDb* db) { } void TLockInfo::PersistAddRange(const TPathId& tableId, ELockRangeFlags flags, ILocksDb* db) { - Y_ABORT_UNLESS(IsPersistent()); - Y_ABORT_UNLESS(db, "Cannot persist ranges without a db"); + Y_ENSURE(IsPersistent()); + Y_ENSURE(db, "Cannot persist ranges without a db"); // We usually have a single range with flags, so linear search is ok ui64 maxId = 0; for (auto& range : PersistentRanges) { @@ -303,8 +303,8 @@ void TLockInfo::PersistAddRange(const TPathId& tableId, ELockRangeFlags flags, I } void TLockInfo::AddConflict(TLockInfo* otherLock, ILocksDb* db) { - Y_ABORT_UNLESS(this != otherLock, "Lock cannot conflict with itself"); - Y_ABORT_UNLESS(LockId != otherLock->LockId, "Unexpected conflict between a pair of locks with the same id"); + Y_ENSURE(this != otherLock, "Lock cannot conflict with itself"); + Y_ENSURE(LockId != otherLock->LockId, "Unexpected conflict between a pair of locks with the same id"); auto& flags = ConflictLocks[otherLock]; if (!(flags & ELockConflictFlags::BreakThemOnOurCommit)) { @@ -313,24 +313,24 @@ void TLockInfo::AddConflict(TLockInfo* otherLock, ILocksDb* db) { otherFlags |= ELockConflictFlags::BreakUsOnTheirCommit; if (IsPersistent() && otherLock->IsPersistent()) { // Any conflict between persistent locks is also persistent - Y_ABORT_UNLESS(db, "Cannot persist conflicts without a db"); + Y_ENSURE(db, "Cannot persist conflicts without a db"); db->PersistAddConflict(LockId, otherLock->LockId); } } } void TLockInfo::AddVolatileDependency(ui64 txId, ILocksDb* db) { - Y_ABORT_UNLESS(LockId != txId, "Unexpected volatile dependency between a lock and itself"); + Y_ENSURE(LockId != txId, "Unexpected volatile dependency between a lock and itself"); if (VolatileDependencies.insert(txId).second && IsPersistent()) { - Y_ABORT_UNLESS(db, "Cannot persist dependencies without a db"); + Y_ENSURE(db, "Cannot persist dependencies without a db"); db->PersistAddVolatileDependency(LockId, txId); } } void TLockInfo::PersistConflicts(ILocksDb* db) { - Y_ABORT_UNLESS(IsPersistent()); - Y_ABORT_UNLESS(db, "Cannot persist conflicts without a db"); + Y_ENSURE(IsPersistent()); + Y_ENSURE(db, "Cannot persist conflicts without a db"); for (auto& pr : ConflictLocks) { TLockInfo* otherLock = pr.first; if (!otherLock->IsPersistent()) { @@ -462,7 +462,7 @@ void TLockInfo::RestoreInMemoryConflict(TLockInfo* otherLock) { } void TLockInfo::RestorePersistentConflict(TLockInfo* otherLock) { - Y_ABORT_UNLESS(IsPersistent() && otherLock->IsPersistent()); + Y_ENSURE(IsPersistent() && otherLock->IsPersistent()); RestoreInMemoryConflict(otherLock); } @@ -471,12 +471,12 @@ void TLockInfo::RestoreInMemoryVolatileDependency(ui64 txId) { } void TLockInfo::RestorePersistentVolatileDependency(ui64 txId) { - Y_ABORT_UNLESS(IsPersistent()); + Y_ENSURE(IsPersistent()); RestoreInMemoryVolatileDependency(txId); } void TLockInfo::SetFrozen(ILocksDb* db) { - Y_ABORT_UNLESS(IsPersistent()); + Y_ENSURE(IsPersistent()); Flags |= ELockFlags::Frozen; if (db) { db->PersistLockFlags(LockId, ui64(Flags & ELockFlags::PersistentMask)); @@ -490,8 +490,8 @@ void TTableLocks::AddShardLock(TLockInfo* lock) { } void TTableLocks::AddPointLock(const TPointKey& point, TLockInfo* lock) { - Y_ABORT_UNLESS(lock->MayHavePointsAndRanges()); - Y_ABORT_UNLESS(point.Table == this); + Y_ENSURE(lock->MayHavePointsAndRanges()); + Y_ENSURE(point.Table == this); TRangeTreeBase::TOwnedRange added( point.Key, true, @@ -501,8 +501,8 @@ void TTableLocks::AddPointLock(const TPointKey& point, TLockInfo* lock) { } void TTableLocks::AddRangeLock(const TRangeKey& range, TLockInfo* lock) { - Y_ABORT_UNLESS(lock->MayHavePointsAndRanges()); - Y_ABORT_UNLESS(range.Table == this); + Y_ENSURE(lock->MayHavePointsAndRanges()); + Y_ENSURE(range.Table == this); // FIXME: we have to force empty From/To to be inclusive due to outdated // scripts/tests assuming missing columns are +inf, and that expect // non-inclusive +inf to include everything. This clashes with the new @@ -625,7 +625,7 @@ void TLockLocker::MakeShardLock(TLockInfo* lock) { } void TLockLocker::UndoShardLock(TLockInfo* lock) { - Y_ABORT_UNLESS(lock->IsShardLock()); + Y_ENSURE(lock->IsShardLock()); for (const TPathId& tableId : lock->GetReadTables()) { Tables.at(tableId)->RemoveShardLock(lock); } @@ -635,7 +635,7 @@ void TLockLocker::AddShardLock(const TLockInfo::TPtr& lock, TIntrusiveList<TTabl MakeShardLock(lock.Get()); for (auto& table : readTables) { const TPathId& tableId = table.GetTableId(); - Y_ABORT_UNLESS(Tables.at(tableId).Get() == &table); + Y_ENSURE(Tables.at(tableId).Get() == &table); if (lock->AddShardLock(tableId)) { table.AddShardLock(lock.Get()); } @@ -645,7 +645,7 @@ void TLockLocker::AddShardLock(const TLockInfo::TPtr& lock, TIntrusiveList<TTabl void TLockLocker::AddWriteLock(const TLockInfo::TPtr& lock, TIntrusiveList<TTableLocks, TTableLocksWriteListTag>& writeTables) { for (auto& table : writeTables) { const TPathId& tableId = table.GetTableId(); - Y_ABORT_UNLESS(Tables.at(tableId).Get() == &table); + Y_ENSURE(Tables.at(tableId).Get() == &table); if (lock->AddWriteLock(tableId)) { table.AddWriteLock(lock.Get()); } @@ -757,7 +757,7 @@ TLockInfo::TPtr TLockLocker::GetOrAddLock(ui64 lockId, ui32 lockNodeId) { } TLockInfo::TPtr lock(new TLockInfo(this, lockId, lockNodeId)); - Y_ABORT_UNLESS(!lock->IsPersistent()); + Y_ENSURE(!lock->IsPersistent()); Locks[lockId] = lock; if (lockNodeId) { PendingSubscribeLocks.emplace_back(lockId, lockNodeId); @@ -767,10 +767,10 @@ TLockInfo::TPtr TLockLocker::GetOrAddLock(ui64 lockId, ui32 lockNodeId) { } TLockInfo::TPtr TLockLocker::AddLock(const ILocksDb::TLockRow& row) { - Y_ABORT_UNLESS(Locks.find(row.LockId) == Locks.end()); + Y_ENSURE(Locks.find(row.LockId) == Locks.end()); TLockInfo::TPtr lock(new TLockInfo(this, row)); - Y_ABORT_UNLESS(lock->IsPersistent()); + Y_ENSURE(lock->IsPersistent()); Locks[row.LockId] = lock; if (row.LockNodeId) { PendingSubscribeLocks.emplace_back(row.LockId, row.LockNodeId); @@ -825,7 +825,7 @@ void TLockLocker::RemoveOneLock(ui64 lockTxId, ILocksDb* db) { Locks.erase(it); if (txLock->IsPersistent()) { - Y_ABORT_UNLESS(db, "Cannot remove persistent locks without a database"); + Y_ENSURE(db, "Cannot remove persistent locks without a database"); txLock->PersistRemoveLock(db); } @@ -861,7 +861,7 @@ void TLockLocker::RemoveSchema(const TPathId& tableId, ILocksDb* db) { } Tables.erase(tableId); - Y_ABORT_UNLESS(Tables.empty()); + Y_ENSURE(Tables.empty()); Locks.clear(); ShardLocks.clear(); LocksWithRanges.Clear(); @@ -914,7 +914,7 @@ bool TLockLocker::ForceShardLock( void TLockLocker::ScheduleBrokenLock(TLockInfo* lock) { auto it = Locks.find(lock->GetLockId()); - Y_ABORT_UNLESS(it != Locks.end() && it->second.Get() == lock, + Y_ENSURE(it != Locks.end() && it->second.Get() == lock, "Sanity check: adding an unknown broken lock"); if (lock->IsPersistent()) { BrokenPersistentLocks.PushBack(lock); @@ -974,7 +974,7 @@ TLocksUpdate::~TLocksUpdate() { // TSysLocks std::pair<TVector<TSysLocks::TLock>, TVector<ui64>> TSysLocks::ApplyLocks() { - Y_ABORT_UNLESS(Update); + Y_ENSURE(Update); TMicrosecTimerCounter measureApplyLocks(*Self, COUNTER_APPLY_LOCKS_USEC); @@ -1011,7 +1011,7 @@ std::pair<TVector<TSysLocks::TLock>, TVector<ui64>> TSysLocks::ApplyLocks() { size_t erases = 0; while (Update->EraseLocks) { - Y_ABORT_UNLESS(!Update->HasLocks(), "Can't erase and set locks in one Tx"); + Y_ENSURE(!Update->HasLocks(), "Can't erase and set locks in one Tx"); auto* lock = Update->EraseLocks.PopFront(); Locker.RemoveLock(lock->GetLockId(), Db); ++erases; @@ -1023,8 +1023,8 @@ std::pair<TVector<TSysLocks::TLock>, TVector<ui64>> TSysLocks::ApplyLocks() { if (!Update->HasLocks()) { // Adding read/write conflicts implies locking - Y_ABORT_UNLESS(!Update->ReadConflictLocks); - Y_ABORT_UNLESS(!Update->WriteConflictLocks); + Y_ENSURE(!Update->ReadConflictLocks); + Y_ENSURE(!Update->WriteConflictLocks); return {TVector<TLock>(), brokenLocks}; } @@ -1125,7 +1125,7 @@ ui64 TSysLocks::ExtractLockTxId(const TArrayRef<const TCell>& key) const { ui64 lockTxId, tabletId; bool ok = TLocksTable::ExtractKey(key, TLocksTable::EColumns::LockId, lockTxId); ok = ok && TLocksTable::ExtractKey(key, TLocksTable::EColumns::DataShard, tabletId); - Y_ABORT_UNLESS(ok && Self->TabletID() == tabletId); + Y_ENSURE(ok && Self->TabletID() == tabletId); return lockTxId; } @@ -1133,7 +1133,7 @@ TSysLocks::TLock TSysLocks::GetLock(const TArrayRef<const TCell>& key) const { ui64 lockTxId, tabletId; bool ok = TLocksTable::ExtractKey(key, TLocksTable::EColumns::LockId, lockTxId); ok = ok && TLocksTable::ExtractKey(key, TLocksTable::EColumns::DataShard, tabletId); - Y_ABORT_UNLESS(ok && Self->TabletID() == tabletId); + Y_ENSURE(ok && Self->TabletID() == tabletId); if (Cache) { auto it = Cache->Locks.find(lockTxId); @@ -1143,17 +1143,17 @@ TSysLocks::TLock TSysLocks::GetLock(const TArrayRef<const TCell>& key) const { return TLock(); } - Y_ABORT_UNLESS(Update); + Y_ENSURE(Update); auto &checkVersion = Update->CheckVersion; TLockInfo::TPtr txLock = Locker.GetLock(lockTxId, checkVersion); if (txLock) { if (key.size() == 2) { // locks v1 const auto& tableIds = txLock->GetReadTables(); - Y_ABORT_UNLESS(tableIds.size() == 1); + Y_ENSURE(tableIds.size() == 1); return MakeAndLogLock(lockTxId, txLock->GetGeneration(), txLock->GetCounter(checkVersion), *tableIds.begin(), txLock->IsWriteLock()); } else { // locks v2 - Y_ABORT_UNLESS(key.size() == 4); + Y_ENSURE(key.size() == 4); TPathId tableId; ok = ok && TLocksTable::ExtractKey(key, TLocksTable::EColumns::SchemeShard, tableId.OwnerId); ok = ok && TLocksTable::ExtractKey(key, TLocksTable::EColumns::PathId, tableId.LocalPathId); @@ -1178,21 +1178,21 @@ TSysLocks::TLock TSysLocks::GetLock(const TArrayRef<const TCell>& key) const { } void TSysLocks::EraseLock(ui64 lockId) { - Y_ABORT_UNLESS(Update); + Y_ENSURE(Update); if (auto* lock = Locker.FindLockPtr(lockId)) { Update->AddEraseLock(lock); } } void TSysLocks::EraseLock(const TArrayRef<const TCell>& key) { - Y_ABORT_UNLESS(Update); + Y_ENSURE(Update); if (auto* lock = Locker.FindLockPtr(GetLockId(key))) { Update->AddEraseLock(lock); } } void TSysLocks::CommitLock(const TArrayRef<const TCell>& key) { - Y_ABORT_UNLESS(Update); + Y_ENSURE(Update); if (auto* lock = Locker.FindLockPtr(GetLockId(key))) { for (auto& pr : lock->ConflictLocks) { if (!!(pr.second & ELockConflictFlags::BreakThemOnOurCommit)) { @@ -1204,8 +1204,8 @@ void TSysLocks::CommitLock(const TArrayRef<const TCell>& key) { } void TSysLocks::SetLock(const TTableId& tableId, const TArrayRef<const TCell>& key) { - Y_ABORT_UNLESS(Update && Update->LockTxId); - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(Update && Update->LockTxId); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); if (!Self->IsUserTable(tableId)) return; @@ -1218,8 +1218,8 @@ void TSysLocks::SetLock(const TTableId& tableId, const TTableRange& range) { return; } - Y_ABORT_UNLESS(Update && Update->LockTxId); - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(Update && Update->LockTxId); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); if (!Self->IsUserTable(tableId)) return; @@ -1227,8 +1227,8 @@ void TSysLocks::SetLock(const TTableId& tableId, const TTableRange& range) { } void TSysLocks::SetWriteLock(const TTableId& tableId, const TArrayRef<const TCell>& key) { - Y_ABORT_UNLESS(Update && Update->LockTxId); - Y_ABORT_UNLESS(!TSysTables::IsSystemTable(tableId)); + Y_ENSURE(Update && Update->LockTxId); + Y_ENSURE(!TSysTables::IsSystemTable(tableId)); if (!Self->IsUserTable(tableId)) return; @@ -1245,7 +1245,7 @@ void TSysLocks::BreakLock(ui64 lockId) { } void TSysLocks::BreakLocks(const TTableId& tableId, const TArrayRef<const TCell>& key) { - Y_ABORT_UNLESS(!tableId.HasSamePath(TTableId(TSysTables::SysSchemeShard, TSysTables::SysTableLocks))); + Y_ENSURE(!tableId.HasSamePath(TTableId(TSysTables::SysSchemeShard, TSysTables::SysTableLocks))); if (auto* table = Locker.FindTablePtr(tableId)) { if (table->HasRangeLocks()) { @@ -1262,7 +1262,7 @@ void TSysLocks::BreakLocks(const TTableId& tableId, const TArrayRef<const TCell> } void TSysLocks::AddReadConflict(ui64 conflictId) { - Y_ABORT_UNLESS(Update && Update->LockTxId); + Y_ENSURE(Update && Update->LockTxId); if (conflictId != Update->LockTxId) { if (auto* lock = Locker.FindLockPtr(conflictId)) { @@ -1272,7 +1272,7 @@ void TSysLocks::AddReadConflict(ui64 conflictId) { } void TSysLocks::AddWriteConflict(ui64 conflictId) { - Y_ABORT_UNLESS(Update && Update->LockTxId); + Y_ENSURE(Update && Update->LockTxId); if (conflictId != Update->LockTxId) { if (auto* lock = Locker.FindLockPtr(conflictId)) { @@ -1282,7 +1282,7 @@ void TSysLocks::AddWriteConflict(ui64 conflictId) { } void TSysLocks::AddWriteConflict(const TTableId& tableId, const TArrayRef<const TCell>& key) { - Y_ABORT_UNLESS(Update && Update->LockTxId); + Y_ENSURE(Update && Update->LockTxId); if (auto* table = Locker.FindTablePtr(tableId)) { if (table->HasRangeLocks()) { @@ -1301,14 +1301,14 @@ void TSysLocks::AddWriteConflict(const TTableId& tableId, const TArrayRef<const } void TSysLocks::AddVolatileDependency(ui64 txId) { - Y_ABORT_UNLESS(Update && Update->LockTxId); + Y_ENSURE(Update && Update->LockTxId); Update->AddVolatileDependency(txId); } void TSysLocks::BreakAllLocks(const TTableId& tableId) { - Y_ABORT_UNLESS(Update); - Y_ABORT_UNLESS(!tableId.HasSamePath(TTableId(TSysTables::SysSchemeShard, TSysTables::SysTableLocks))); + Y_ENSURE(Update); + Y_ENSURE(!tableId.HasSamePath(TTableId(TSysTables::SysSchemeShard, TSysTables::SysTableLocks))); if (!Self->IsUserTable(tableId)) return; @@ -1323,7 +1323,7 @@ void TSysLocks::BreakAllLocks(const TTableId& tableId) { } void TSysLocks::BreakSetLocks() { - Y_ABORT_UNLESS(Update && Update->LockTxId); + Y_ENSURE(Update && Update->LockTxId); Update->BreakSetLocks(); } @@ -1335,7 +1335,7 @@ bool TSysLocks::IsMyKey(const TArrayRef<const TCell>& key) const { } bool TSysLocks::HasCurrentWriteLock(const TTableId& tableId) const { - Y_ABORT_UNLESS(Update && Update->LockTxId); + Y_ENSURE(Update && Update->LockTxId); if (Update->WriteTables) { if (auto* table = Locker.FindTablePtr(tableId.PathId)) { @@ -1355,7 +1355,7 @@ bool TSysLocks::HasCurrentWriteLock(const TTableId& tableId) const { } bool TSysLocks::HasCurrentWriteLocks() const { - Y_ABORT_UNLESS(Update && Update->LockTxId); + Y_ENSURE(Update && Update->LockTxId); if (Update->WriteTables) { return true; @@ -1385,8 +1385,8 @@ bool TSysLocks::HasWriteLocks(const TTableId& tableId) const { } EEnsureCurrentLock TSysLocks::EnsureCurrentLock() { - Y_ABORT_UNLESS(Update && Update->LockTxId); - Y_ABORT_UNLESS(Db, "EnsureCurrentLock needs a valid locks database"); + Y_ENSURE(Update && Update->LockTxId); + Y_ENSURE(Db, "EnsureCurrentLock needs a valid locks database"); if (auto* lock = Locker.FindLockPtr(Update->LockTxId)) { // We cannot expand a broken lock @@ -1448,7 +1448,7 @@ bool TSysLocks::Load(ILocksDb& db) { for (auto& lockRow : rows) { auto* lock = Locker.FindLockPtr(lockRow.LockId); - Y_ABORT_UNLESS(lock); + Y_ENSURE(lock); for (ui64 conflictId : lockRow.Conflicts) { if (auto* otherLock = Locker.FindLockPtr(conflictId)) { lock->RestorePersistentConflict(otherLock); diff --git a/ydb/core/tx/locks/locks.h b/ydb/core/tx/locks/locks.h index fe4864308c..941b058340 100644 --- a/ydb/core/tx/locks/locks.h +++ b/ydb/core/tx/locks/locks.h @@ -486,12 +486,12 @@ public: } NScheme::TTypeInfo GetKeyColumnType(ui32 pos) const { - Y_ABORT_UNLESS(pos < KeyColumnTypes.size()); + Y_ENSURE(pos < KeyColumnTypes.size()); return KeyColumnTypes[pos]; } void UpdateKeyColumnsTypes(const TVector<NScheme::TTypeInfo>& keyTypes) { - Y_ABORT_UNLESS(KeyColumnTypes.size() <= keyTypes.size()); + Y_ENSURE(KeyColumnTypes.size() <= keyTypes.size()); if (KeyColumnTypes.size() < keyTypes.size()) { KeyColumnTypes = keyTypes; Ranges.SetKeyTypes(keyTypes); @@ -619,7 +619,7 @@ public: } TRangeKey MakeRange(const TTableId& tableId, const TTableRange& range) const { - Y_ABORT_UNLESS(!range.Point); + Y_ENSURE(!range.Point); return TRangeKey{ GetTableLocks(tableId), TOwnedCellVec(range.From), @@ -690,7 +690,7 @@ private: TTableLocks::TPtr GetTableLocks(const TTableId& table) const { auto it = Tables.find(table.PathId); - Y_ABORT_UNLESS(it != Tables.end()); + Y_ENSURE(it != Tables.end()); return it->second; } @@ -841,8 +841,8 @@ public: {} void SetupUpdate(TLocksUpdate* update, ILocksDb* db = nullptr) { - Y_ABORT_UNLESS(!Update, "Cannot setup a recursive update"); - Y_ABORT_UNLESS(update, "Cannot setup a nullptr update"); + Y_ENSURE(!Update, "Cannot setup a recursive update"); + Y_ENSURE(update, "Cannot setup a nullptr update"); Update = update; Db = db; } @@ -866,7 +866,7 @@ public: } ui64 CurrentLockTxId() const { - Y_ABORT_UNLESS(Update); + Y_ENSURE(Update); return Update->LockTxId; } @@ -960,7 +960,7 @@ private: static ui64 GetLockId(const TArrayRef<const TCell>& key) { ui64 lockId; bool ok = TLocksTable::ExtractKey(key, TLocksTable::EColumns::LockId, lockId); - Y_ABORT_UNLESS(ok); + Y_ENSURE(ok); return lockId; } }; diff --git a/ydb/core/tx/locks/range_treap.h b/ydb/core/tx/locks/range_treap.h index b85696d3ad..683948ca75 100644 --- a/ydb/core/tx/locks/range_treap.h +++ b/ydb/core/tx/locks/range_treap.h @@ -104,8 +104,8 @@ namespace NDataShard { * Adds mapping from the given range to the given value */ void AddRange(TOwnedRange range, TValue value) { - Y_ABORT_UNLESS(range.LeftKey.size() <= KeyTypes.size(), "Range left key is too large"); - Y_ABORT_UNLESS(range.RightKey.size() <= KeyTypes.size(), "Range right key is too large"); + Y_ENSURE(range.LeftKey.size() <= KeyTypes.size(), "Range left key is too large"); + Y_ENSURE(range.RightKey.size() <= KeyTypes.size(), "Range right key is too large"); auto leftBorder = TBorder::MakeLeft(range.LeftKey, range.LeftInclusive); auto rightBorder = TBorder::MakeRight(range.RightKey, range.RightInclusive); @@ -518,7 +518,7 @@ namespace NDataShard { */ void Validate() const { if (Root) { - Y_ABORT_UNLESS(Root->Parent == nullptr, "Root must not have a parent"); + Y_ENSURE(Root->Parent == nullptr, "Root must not have a parent"); DoValidate(Root.Get()); } } @@ -535,14 +535,14 @@ namespace NDataShard { bool maxRightTrivial = true; if (auto* l = t->Left.Get()) { - Y_ABORT_UNLESS(l->Parent == t, "Left child parent is incorrect"); - Y_ABORT_UNLESS(l->Prio >= t->Prio, "Left child prio is incorrect"); + Y_ENSURE(l->Parent == t, "Left child parent is incorrect"); + Y_ENSURE(l->Prio >= t->Prio, "Left child prio is incorrect"); cmp = this->CompareBorders(l->LeftBorder(), t->LeftBorder()); - Y_ABORT_UNLESS(cmp < 0 || cmp == 0 && TValueTraits::Less(l->Value, t->Value), "Left child must be smaller than t"); + Y_ENSURE(cmp < 0 || cmp == 0 && TValueTraits::Less(l->Value, t->Value), "Left child must be smaller than t"); TNode* leftRightMost; std::tie(leftMost, leftRightMost) = DoValidate(l); cmp = this->CompareBorders(leftRightMost->LeftBorder(), t->LeftBorder()); - Y_ABORT_UNLESS(cmp < 0 || cmp == 0 && TValueTraits::Less(leftRightMost->Value, t->Value), "Left child rightmost node must be smaller than t"); + Y_ENSURE(cmp < 0 || cmp == 0 && TValueTraits::Less(leftRightMost->Value, t->Value), "Left child rightmost node must be smaller than t"); cmp = this->CompareBorders(maxRightBorder, l->MaxRightBorder()); if (cmp < 0) { maxRightBorder = l->MaxRightBorder(); @@ -551,14 +551,14 @@ namespace NDataShard { } if (auto* r = t->Right.Get()) { - Y_ABORT_UNLESS(r->Parent == t, "Right child parent is incorrect"); - Y_ABORT_UNLESS(r->Prio >= t->Prio, "Right child prio is incorrect"); + Y_ENSURE(r->Parent == t, "Right child parent is incorrect"); + Y_ENSURE(r->Prio >= t->Prio, "Right child prio is incorrect"); cmp = this->CompareBorders(t->LeftBorder(), r->LeftBorder()); - Y_ABORT_UNLESS(cmp < 0 || cmp == 0 && TValueTraits::Less(t->Value, r->Value), "Right child must be bigger than t"); + Y_ENSURE(cmp < 0 || cmp == 0 && TValueTraits::Less(t->Value, r->Value), "Right child must be bigger than t"); TNode* rightLeftMost; std::tie(rightLeftMost, rightMost) = DoValidate(r); cmp = this->CompareBorders(t->LeftBorder(), rightLeftMost->LeftBorder()); - Y_ABORT_UNLESS(cmp < 0 || cmp == 0 && TValueTraits::Less(t->Value, rightLeftMost->Value), "Right child leftmost node must be bigger than t"); + Y_ENSURE(cmp < 0 || cmp == 0 && TValueTraits::Less(t->Value, rightLeftMost->Value), "Right child leftmost node must be bigger than t"); cmp = this->CompareBorders(maxRightBorder, r->MaxRightBorder()); if (cmp < 0) { maxRightBorder = r->MaxRightBorder(); @@ -567,10 +567,9 @@ namespace NDataShard { } cmp = this->CompareBorders(maxRightBorder, t->MaxRightBorder()); - Y_ABORT_UNLESS(cmp == 0, "Subtree must have max right key equal to the calculated max"); - Y_ABORT_UNLESS(maxRightTrivial == t->MaxRightTrivial, - "Subtree must have correct MaxRightTrivial flag (computed=%d, stored=%d)", - int(maxRightTrivial), int(t->MaxRightTrivial)); + Y_ENSURE(cmp == 0, "Subtree must have max right key equal to the calculated max"); + Y_ENSURE(maxRightTrivial == t->MaxRightTrivial, + "Subtree must have correct MaxRightTrivial flag (computed=" << int(maxRightTrivial) << ", stored=" << int(t->MaxRightTrivial) << ")"); return { leftMost, rightMost }; } diff --git a/ydb/core/tx/locks/range_tree_base.h b/ydb/core/tx/locks/range_tree_base.h index 6b01bf0ae9..18c470952a 100644 --- a/ydb/core/tx/locks/range_tree_base.h +++ b/ydb/core/tx/locks/range_tree_base.h @@ -71,7 +71,7 @@ namespace NDataShard { public: void SetKeyTypes(const TVector<NScheme::TTypeInfo>& keyTypes) { - Y_ABORT_UNLESS(keyTypes.size() >= KeyTypes.size(), "Number of key columns must not decrease over time"); + Y_ENSURE(keyTypes.size() >= KeyTypes.size(), "Number of key columns must not decrease over time"); KeyTypes = keyTypes; } diff --git a/ydb/core/tx/locks/sys_tables.h b/ydb/core/tx/locks/sys_tables.h index 7378daf1e2..66e679d084 100644 --- a/ydb/core/tx/locks/sys_tables.h +++ b/ydb/core/tx/locks/sys_tables.h @@ -199,7 +199,7 @@ struct TSysTables { } static bool ExtractKey(const TArrayRef<const TCell>& key, EColumns columnId, ui64& value) { - Y_ABORT_UNLESS(columnId == EColumns::LockId || + Y_ENSURE(columnId == EColumns::LockId || columnId == EColumns::DataShard || columnId == EColumns::SchemeShard || columnId == EColumns::PathId); @@ -212,7 +212,7 @@ struct TSysTables { if (cell.IsNull()) return false; - Y_ABORT_UNLESS(cell.Size() == sizeof(ui64)); + Y_ENSURE(cell.Size() == sizeof(ui64)); value = ReadUnaligned<ui64>(reinterpret_cast<const ui64*>(cell.Data())); return true; } |