@@ -735,6 +735,16 @@ struct TTestHelper {
735735 UNIT_ASSERT_VALUES_EQUAL (rowsRead, Min (rowCount, limit));
736736 }
737737
738+ void WriteRowTwin (const TString& tableName, const TVector<ui32>& values, bool isEvWrite) {
739+ if (isEvWrite)
740+ WriteRow (tableName, ++TxId, values);
741+ else
742+ ExecSQL (Server, Sender, TStringBuilder ()
743+ << " UPSERT INTO `/Root/" << tableName << " `\n "
744+ << " (" << JoinSeq (" ," , MakeMappedRange (Tables[tableName].Columns , [](const auto & col) { return col.Name ; })) << " )\n "
745+ << " VALUES\n (" << JoinSeq (" ," , values) << " );" );
746+ }
747+
738748 NKikimrDataEvents::TEvWriteResult WriteRow (const TString& tableName, ui64 txId, const TVector<ui32>& values, NKikimrDataEvents::TEvWrite::ETxMode txMode = NKikimrDataEvents::TEvWrite::MODE_IMMEDIATE) {
739749 const auto & table = Tables[tableName];
740750
@@ -909,6 +919,7 @@ struct TTestHelper {
909919 ui64 ShardCount = 1 ;
910920 Tests::TServer::TPtr Server;
911921 TActorId Sender;
922+ ui64 TxId = 100 ;
912923
913924 THashMap<TString, TTableInfo> Tables;
914925};
@@ -3148,59 +3159,32 @@ Y_UNIT_TEST_SUITE(DataShardReadIterator) {
31483159 UNIT_ASSERT (lock.GetCounter () < brokenLock.GetCounter ());
31493160 }
31503161
3151- Y_UNIT_TEST (ShouldReturnBrokenLockWhenReadRange) {
3162+ Y_UNIT_TEST_TWIN (ShouldReturnBrokenLockWhenReadRange, EvWrite ) {
31523163 // upsert into "left border -1 " and to the "right border + 1" - lock not broken
31533164 // upsert inside range - broken
31543165 TTestHelper helper;
31553166
31563167 const ui64 lockTxId = 1011121314 ;
3168+ const TString tableName = " table-1" ;
3169+ const TVector<ui32> checkKey = {11 , 11 , 11 };
31573170
3158- auto request1 = helper.GetBaseReadRequest (" table-1 " , 1 );
3171+ auto request1 = helper.GetBaseReadRequest (tableName , 1 );
31593172 request1->Record .SetLockTxId (lockTxId);
3160- AddRangeQuery<ui32>(
3161- *request1,
3162- {3 , 3 , 3 },
3163- true ,
3164- {8 , 0 , 1 },
3165- true
3166- );
3173+ AddRangeQuery<ui32>(*request1, {3 , 3 , 3 }, true , {8 , 0 , 1 }, true );
3174+ auto readResult1 = helper.SendRead (tableName, request1.release ());
31673175
3168- auto readResult1 = helper.SendRead (" table-1" , request1.release ());
3176+ // upsert to the left and check that lock is not broken
3177+ helper.WriteRowTwin (tableName, {1 , 1 , 1 , 101 }, EvWrite);
3178+ helper.CheckLockValid (tableName, 2 , checkKey, lockTxId);
31693179
3170- {
3171- // upsert to the left and check that lock is not broken
3172- ExecSQL (helper.Server , helper.Sender , R"(
3173- UPSERT INTO `/Root/table-1`
3174- (key1, key2, key3, value)
3175- VALUES
3176- (1, 1, 1, 101);
3177- )" );
3178-
3179- helper.CheckLockValid (" table-1" , 2 , {11 , 11 , 11 }, lockTxId);
3180- }
3181-
3182- {
3183- // upsert to the right and check that lock is not broken
3184- ExecSQL (helper.Server , helper.Sender , R"(
3185- UPSERT INTO `/Root/table-1`
3186- (key1, key2, key3, value)
3187- VALUES
3188- (8, 1, 0, 802);
3189- )" );
3190-
3191- helper.CheckLockValid (" table-1" , 2 , {11 , 11 , 11 }, lockTxId);
3192- }
3180+ // upsert to the right and check that lock is not broken
3181+ helper.WriteRowTwin (tableName, {8 , 1 , 0 , 802 }, EvWrite);
3182+ helper.CheckLockValid (tableName, 2 , checkKey, lockTxId);
31933183
31943184 // breaks lock
31953185 // also we modify range: insert new key
3196- ExecSQL (helper.Server , helper.Sender , R"(
3197- UPSERT INTO `/Root/table-1`
3198- (key1, key2, key3, value)
3199- VALUES
3200- (4, 4, 4, 400);
3201- )" );
3202-
3203- helper.CheckLockBroken (" table-1" , 3 , {11 , 11 , 11 }, lockTxId, *readResult1);
3186+ helper.WriteRowTwin (tableName, {4 , 4 , 4 , 400 }, EvWrite);
3187+ helper.CheckLockBroken (tableName, 3 , checkKey, lockTxId, *readResult1);
32043188 }
32053189
32063190 Y_UNIT_TEST (ShouldReturnBrokenLockWhenReadRangeInvisibleRowSkips) {
0 commit comments