@@ -5149,6 +5149,60 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) {
51495149 }
51505150 }
51515151
5152+ Y_UNIT_TEST (BrokenLockChangesDontLeak) {
5153+ TPortManager pm;
5154+ TServerSettings serverSettings (pm.GetPort (2134 ));
5155+ serverSettings.SetDomainName (" Root" )
5156+ .SetUseRealThreads (false )
5157+ .SetDomainPlanResolution (100 );
5158+
5159+ Tests::TServer::TPtr server = new TServer (serverSettings);
5160+ auto &runtime = *server->GetRuntime ();
5161+ auto sender = runtime.AllocateEdgeActor ();
5162+
5163+ runtime.SetLogPriority (NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE);
5164+
5165+ InitRoot (server, sender);
5166+
5167+ TDisableDataShardLogBatching disableDataShardLogBatching;
5168+
5169+ UNIT_ASSERT_VALUES_EQUAL (
5170+ KqpSchemeExec (runtime, R"(
5171+ CREATE TABLE `/Root/table` (key Uint32, value Uint32, PRIMARY KEY (key));
5172+ )" ),
5173+ " SUCCESS" );
5174+
5175+ ExecSQL (server, sender, " UPSERT INTO `/Root/table` (key, value) VALUES (1, 11);" );
5176+
5177+ TString sessionId, txId;
5178+ UNIT_ASSERT_VALUES_EQUAL (
5179+ KqpSimpleBegin (runtime, sessionId, txId, R"(
5180+ SELECT key, value FROM `/Root/table`
5181+ ORDER BY key;
5182+ )" ),
5183+ " { items { uint32_value: 1 } items { uint32_value: 11 } }" );
5184+
5185+ ExecSQL (server, sender, " UPSERT INTO `/Root/table` (key, value) VALUES (2, 22);" );
5186+
5187+ UNIT_ASSERT_VALUES_EQUAL (
5188+ KqpSimpleContinue (runtime, sessionId, txId, R"(
5189+ UPSERT INTO `/Root/table` (key, value) VALUES (3, 33);
5190+ SELECT key, value FROM `/Root/table` ORDER BY key;
5191+ )" ),
5192+ " ERROR: ABORTED" );
5193+
5194+ const auto shards = GetTableShards (server, sender, " /Root/table" );
5195+ const auto tableId = ResolveTableId (server, sender, " /Root/table" );
5196+ UNIT_ASSERT_VALUES_EQUAL (shards.size (), 1u );
5197+
5198+ // Check shard doesn't have open transactions
5199+ {
5200+ runtime.SendToPipe (shards.at (0 ), sender, new TEvDataShard::TEvGetOpenTxs (tableId.PathId ));
5201+ auto ev = runtime.GrabEdgeEventRethrow <TEvDataShard::TEvGetOpenTxsResult>(sender);
5202+ UNIT_ASSERT_C (ev->Get ()->OpenTxs .empty (), " at shard " << shards.at (0 ));
5203+ }
5204+ }
5205+
51525206}
51535207
51545208} // namespace NKikimr
0 commit comments