@@ -373,6 +373,44 @@ Y_UNIT_TEST_SUITE(DataShardWrite) {
373373 }
374374 }
375375
376+ Y_UNIT_TEST (CancelImmediate) {
377+ auto [runtime, server, sender] = TestCreateServer ();
378+
379+ TShardedTableOptions opts;
380+ const TString tableName = " table-1" ;
381+ const auto [shards, tableId] = CreateShardedTable (server, sender, " /Root" , tableName, opts);
382+ const ui64 shard = shards[0 ];
383+ const ui32 rowCount = 3 ;
384+
385+ ui64 txId = 100 ;
386+
387+ TActorId shardActorId = ResolveTablet ( runtime, shard, 0 , false );
388+
389+ Cout << " ========= Send immediate =========\n " ;
390+ {
391+ auto request = MakeWriteRequest (txId, NKikimrDataEvents::TEvWrite::MODE_IMMEDIATE, NKikimrDataEvents::TEvWrite::TOperation::OPERATION_UPSERT, tableId, opts.Columns_ , rowCount);
392+ runtime.Send (new IEventHandle (shardActorId, sender, request.release ()), 0 , true );
393+ }
394+
395+ Cout << " ========= Send cancel to tablet =========\n " ;
396+ {
397+ auto request = std::make_unique<TEvDataShard::TEvCancelTransactionProposal>(txId);
398+ runtime.Send (new IEventHandle (shardActorId, sender, request.release ()), 0 , true );
399+ }
400+
401+ Cout << " ========= Wait for STATUS_CANCELLED result =========\n " ;
402+ {
403+ const auto writeResult = WaitForWriteCompleted (runtime, sender, NKikimrDataEvents::TEvWriteResult::STATUS_CANCELLED);
404+ UNIT_ASSERT_VALUES_EQUAL (writeResult.GetTxId (), txId);
405+ }
406+
407+ Cout << " ========= Send immediate upserts =========\n " ;
408+ {
409+ ExecSQL (server, sender, Q_ (" UPSERT INTO `/Root/table-1` (key, value) VALUES (0, 1);" ));
410+ Upsert (runtime, sender, shard, tableId, opts.Columns_ , rowCount, txId, NKikimrDataEvents::TEvWrite::MODE_IMMEDIATE);
411+ }
412+ }
413+
376414 Y_UNIT_TEST_TWIN (UpsertPreparedManyTables, Volatile) {
377415 auto [runtime, server, sender] = TestCreateServer ();
378416
0 commit comments