@@ -241,11 +241,11 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
241
241
}
242
242
243
243
void Finalize () {
244
+ YQL_ENSURE (!AlreadyReplied);
244
245
if (LocksBroken) {
245
- TString message = " Transaction locks invalidated." ;
246
-
247
- return ReplyErrorAndDie (Ydb::StatusIds::ABORTED,
248
- YqlIssue ({}, TIssuesIds::KIKIMR_LOCKS_INVALIDATED, message));
246
+ return ReplyErrorAndDie (
247
+ Ydb::StatusIds::ABORTED,
248
+ YqlIssue (TPosition (), TIssuesIds::KIKIMR_LOCKS_INVALIDATED, " Transaction locks invalidated. Unknown table." ));
249
249
}
250
250
251
251
auto & response = *ResponseEv->Record .MutableResponse ();
@@ -1183,6 +1183,23 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
1183
1183
CheckExecutionComplete ();
1184
1184
return ;
1185
1185
}
1186
+ case NKikimrDataEvents::TEvWriteResult::STATUS_LOCKS_BROKEN: {
1187
+ LOG_D (" Broken locks: " << res->Record .DebugString ());
1188
+ YQL_ENSURE (shardState->State == TShardState::EState::Executing);
1189
+ shardState->State = TShardState::EState::Finished;
1190
+ Counters->TxProxyMon ->TxResultAborted ->Inc ();
1191
+ LocksBroken = true ;
1192
+
1193
+ if (!res->Record .GetTxLocks ().empty ()) {
1194
+ ResponseEv->BrokenLockPathId = NYql::TKikimrPathId (
1195
+ res->Record .GetTxLocks (0 ).GetSchemeShard (),
1196
+ res->Record .GetTxLocks (0 ).GetPathId ());
1197
+ return ReplyErrorAndDie (Ydb::StatusIds::ABORTED, {});
1198
+ }
1199
+
1200
+ CheckExecutionComplete ();
1201
+ return ;
1202
+ }
1186
1203
default :
1187
1204
{
1188
1205
return ShardError (res->Record );
@@ -1235,29 +1252,15 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
1235
1252
shardState->State = TShardState::EState::Finished;
1236
1253
1237
1254
Counters->TxProxyMon ->TxResultAborted ->Inc (); // TODO: dedicated counter?
1238
-
1239
1255
LocksBroken = true ;
1240
1256
1241
- TMaybe<TString> tableName;
1242
1257
if (!res->Record .GetTxLocks ().empty ()) {
1243
- auto & lock = res->Record .GetTxLocks (0 );
1244
- auto tableId = TTableId (lock.GetSchemeShard (), lock.GetPathId ());
1245
- auto it = FindIf (TasksGraph.GetStagesInfo (), [tableId](const auto & x){ return x.second .Meta .TableId .HasSamePath (tableId); });
1246
- if (it != TasksGraph.GetStagesInfo ().end ()) {
1247
- tableName = it->second .Meta .TableConstInfo ->Path ;
1248
- }
1249
- }
1250
-
1251
- // Reply as soon as we know which table had locks invalidated
1252
- if (tableName) {
1253
- auto message = TStringBuilder ()
1254
- << " Transaction locks invalidated. Table: " << *tableName;
1255
-
1256
- return ReplyErrorAndDie (Ydb::StatusIds::ABORTED,
1257
- YqlIssue ({}, TIssuesIds::KIKIMR_LOCKS_INVALIDATED, message));
1258
+ ResponseEv->BrokenLockPathId = TKikimrPathId (
1259
+ res->Record .GetTxLocks (0 ).GetSchemeShard (),
1260
+ res->Record .GetTxLocks (0 ).GetPathId ());
1261
+ return ReplyErrorAndDie (Ydb::StatusIds::ABORTED, {});
1258
1262
}
1259
1263
1260
- // Receive more replies from other shards
1261
1264
CheckExecutionComplete ();
1262
1265
return ;
1263
1266
}
0 commit comments