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