@@ -4535,100 +4535,3 @@ func TestUnexpectedCommitOnTxnRecovery(t *testing.T) {
4535
4535
close (blockCh )
4536
4536
wg .Wait ()
4537
4537
}
4538
-
4539
- // TestBatchPutScanReverseScanWithFailedPutReplication is a regression test for
4540
- // #150304 in which a batch containing a Put, Scan, and ReverseScan, failed to
4541
- // read its own write during one of the Scans. This was the result of the batch
4542
- // being split downstream of the txnPipeliner and thus the Put not being
4543
- // verified before the overlapping scan was issued.
4544
- func TestBatchPutScanReverseScanWithFailedPutReplication (t * testing.T ) {
4545
- defer leaktest .AfterTest (t )()
4546
- defer log .Scope (t ).Close (t )
4547
-
4548
- // TODO(yuzefovich): figure out whether we should just delete this test.
4549
- skip .IgnoreLint (t , "this test constructs no longer valid scenario" )
4550
-
4551
- keyA := roachpb .Key ("a" )
4552
- keyB := roachpb .Key ("b" )
4553
- keyC := roachpb .Key ("c" )
4554
-
4555
- var (
4556
- targetTxnIDString atomic.Value
4557
- cmdID atomic.Value
4558
- )
4559
- cmdID .Store (kvserverbase .CmdIDKey ("" ))
4560
- targetTxnIDString .Store ("" )
4561
- ctx := context .Background ()
4562
- st := cluster .MakeTestingClusterSettings ()
4563
-
4564
- tc := testcluster .StartTestCluster (t , 3 , base.TestClusterArgs {
4565
- ServerArgs : base.TestServerArgs {
4566
- Settings : st ,
4567
- Knobs : base.TestingKnobs {
4568
- Store : & kvserver.StoreTestingKnobs {
4569
- TestingProposalFilter : func (fArgs kvserverbase.ProposalFilterArgs ) * kvpb.Error {
4570
- if fArgs .Req .Header .Txn == nil ||
4571
- fArgs .Req .Header .Txn .ID .String () != targetTxnIDString .Load ().(string ) {
4572
- return nil // not our txn
4573
- }
4574
- putReq , ok := fArgs .Req .Requests [0 ].GetInner ().(* kvpb.PutRequest )
4575
- // Only fail replication on the Put to keyB.
4576
- if ok && putReq .Key .Equal (keyB ) {
4577
- t .Logf ("will fail application for txn %s; req: %+v; raft cmdID: %x" ,
4578
- fArgs .Req .Header .Txn .ID .String (), putReq , fArgs .CmdID )
4579
- cmdID .Store (fArgs .CmdID )
4580
- }
4581
- return nil
4582
- },
4583
- TestingApplyCalledTwiceFilter : func (fArgs kvserverbase.ApplyFilterArgs ) (int , * kvpb.Error ) {
4584
- if fArgs .CmdID == cmdID .Load ().(kvserverbase.CmdIDKey ) {
4585
- t .Logf ("failing application for raft cmdID: %x" , cmdID )
4586
- return 0 , kvpb .NewErrorf ("test injected error" )
4587
- }
4588
- return 0 , nil
4589
- },
4590
- },
4591
- },
4592
- },
4593
- })
4594
- defer tc .Stopper ().Stop (ctx )
4595
-
4596
- db := tc .Server (0 ).DB ()
4597
-
4598
- err := db .Put (ctx , keyA , "initial_a" )
4599
- require .NoError (t , err )
4600
-
4601
- err = db .Txn (ctx , func (ctx context.Context , txn * kv.Txn ) error {
4602
- if txnID := targetTxnIDString .Load (); txnID == "" {
4603
- // Store the txnID for the testing knobs.
4604
- targetTxnIDString .Store (txn .ID ().String ())
4605
- t .Logf ("txn ID is: %s" , txn .ID ())
4606
- }
4607
-
4608
- // Create a batch that will be split into two batches because of scan
4609
- // directions. We've arranged for the put to fail application.
4610
- b := txn .NewBatch ()
4611
- b .Put (keyB , "value_b" )
4612
- b .ScanForUpdate (keyA , keyC , kvpb .GuaranteedDurability )
4613
- b .ReverseScanForShare (keyA , keyC , kvpb .GuaranteedDurability )
4614
-
4615
- // If the batch isn't marked for async consensus, the batch will fail.
4616
- if err := txn .Run (ctx , b ); err != nil {
4617
- return err
4618
- }
4619
-
4620
- // If the batch doesn't fail, then it _must_ have both rows in the second
4621
- // scan.
4622
- require .Equal (t , 2 , len (b .Results [2 ].Rows ))
4623
- return nil
4624
- })
4625
-
4626
- // The transaction should fail due to the replication failure.
4627
- require .Error (t , err )
4628
- require .ErrorContains (t , err , "test injected error" )
4629
-
4630
- // Verify that the Put didn't succeed by checking that keyB doesn't exist.
4631
- res , err := db .Get (ctx , keyB )
4632
- require .NoError (t , err )
4633
- require .False (t , res .Exists (), "keyB should not exist due to failed replication" )
4634
- }
0 commit comments