@@ -3765,9 +3765,17 @@ func TestLeaseDescriptorRangeFeedFailure(t *testing.T) {
3765
3765
p .Params .ExecutionPhase != scop .PostCommitPhase {
3766
3766
return nil
3767
3767
}
3768
+ foundDescriptorDrop := false
3769
+ // Ensure we have a descriptor drop that will be executed before
3770
+ // we mess with the range feed.
3771
+ for _ , op := range p .Stages [stageIdx ].EdgeOps {
3772
+ if _ , ok := op .(* scop.MarkDescriptorAsDropped ); ok {
3773
+ foundDescriptorDrop = true
3774
+ }
3775
+ }
3768
3776
// Once this stage completes, we can "resume" the range feed,
3769
3777
// so the update is detected.
3770
- if stageIdx == 0 {
3778
+ if foundDescriptorDrop {
3771
3779
rangeFeedResetChan = srv .ApplicationLayer (1 ).LeaseManager ().(* lease.Manager ).TestingSetDisableRangeFeedCheckpointFn (true )
3772
3780
enableAfterStageKnob .Swap (false )
3773
3781
grp .Go (func () error {
@@ -3791,15 +3799,20 @@ func TestLeaseDescriptorRangeFeedFailure(t *testing.T) {
3791
3799
// detects a problem.
3792
3800
defer srv .ApplicationLayer (1 ).LeaseManager ().(* lease.Manager ).TestingSetDisableRangeFeedCheckpointFn (false )
3793
3801
firstConn .Exec (t , "CREATE TABLE t1(n int)" )
3802
+ firstConn .Exec (t , "CREATE TABLE t2(n int)" )
3794
3803
require .NoError (t , srv .WaitForFullReplication ())
3795
3804
tx := secondConn .Begin (t )
3796
3805
_ , err := tx .Exec ("SELECT * FROM t1;" )
3797
3806
require .NoError (t , err )
3807
+ _ , err = tx .Exec ("SELECT * FROM t2;" )
3808
+ require .NoError (t , err )
3798
3809
// This schema change will wait for the connection on
3799
3810
// node 1 to release the lease. Because the rangefeed is
3800
3811
// disabled it will never know about the new version.
3801
3812
enableAfterStageKnob .Store (true )
3802
- firstConn .Exec (t , "ALTER TABLE t1 ADD COLUMN j INT DEFAULT 64" )
3813
+ firstConn .Exec (t , "SET autocommit_before_ddl=false" )
3814
+ firstConn .Exec (t , "SET use_declarative_schema_changer='unsafe_always'" )
3815
+ firstConn .Exec (t , "ALTER TABLE t1 ADD COLUMN j INT DEFAULT 64; DROP TABLE t2;" )
3803
3816
_ , err = tx .Exec ("INSERT INTO t1 VALUES (32)" )
3804
3817
if err != nil {
3805
3818
t .Fatal (err )
0 commit comments