@@ -3804,9 +3804,17 @@ func TestLeaseDescriptorRangeFeedFailure(t *testing.T) {
3804
3804
p .Params .ExecutionPhase != scop .PostCommitPhase {
3805
3805
return nil
3806
3806
}
3807
+ foundDescriptorDrop := false
3808
+ // Ensure we have a descriptor drop that will be executed before
3809
+ // we mess with the range feed.
3810
+ for _ , op := range p .Stages [stageIdx ].EdgeOps {
3811
+ if _ , ok := op .(* scop.MarkDescriptorAsDropped ); ok {
3812
+ foundDescriptorDrop = true
3813
+ }
3814
+ }
3807
3815
// Once this stage completes, we can "resume" the range feed,
3808
3816
// so the update is detected.
3809
- if stageIdx == 0 {
3817
+ if foundDescriptorDrop {
3810
3818
rangeFeedResetChan = srv .ApplicationLayer (1 ).LeaseManager ().(* lease.Manager ).TestingSetDisableRangeFeedCheckpointFn (true )
3811
3819
enableAfterStageKnob .Swap (false )
3812
3820
grp .Go (func () error {
@@ -3830,15 +3838,20 @@ func TestLeaseDescriptorRangeFeedFailure(t *testing.T) {
3830
3838
// detects a problem.
3831
3839
defer srv .ApplicationLayer (1 ).LeaseManager ().(* lease.Manager ).TestingSetDisableRangeFeedCheckpointFn (false )
3832
3840
firstConn .Exec (t , "CREATE TABLE t1(n int)" )
3841
+ firstConn .Exec (t , "CREATE TABLE t2(n int)" )
3833
3842
require .NoError (t , srv .WaitForFullReplication ())
3834
3843
tx := secondConn .Begin (t )
3835
3844
_ , err := tx .Exec ("SELECT * FROM t1;" )
3836
3845
require .NoError (t , err )
3846
+ _ , err = tx .Exec ("SELECT * FROM t2;" )
3847
+ require .NoError (t , err )
3837
3848
// This schema change will wait for the connection on
3838
3849
// node 1 to release the lease. Because the rangefeed is
3839
3850
// disabled it will never know about the new version.
3840
3851
enableAfterStageKnob .Store (true )
3841
- firstConn .Exec (t , "ALTER TABLE t1 ADD COLUMN j INT DEFAULT 64" )
3852
+ firstConn .Exec (t , "SET autocommit_before_ddl=false" )
3853
+ firstConn .Exec (t , "SET use_declarative_schema_changer='unsafe_always'" )
3854
+ firstConn .Exec (t , "ALTER TABLE t1 ADD COLUMN j INT DEFAULT 64; DROP TABLE t2;" )
3842
3855
_ , err = tx .Exec ("INSERT INTO t1 VALUES (32)" )
3843
3856
if err != nil {
3844
3857
t .Fatal (err )
0 commit comments