@@ -253,15 +253,39 @@ func TestScatterWithOneVoter(t *testing.T) {
253253 if err != nil {
254254 t .Fatal (err )
255255 }
256+ t .Logf ("before scatter: replica distribution across stores: %v (total: %d)" ,
257+ oldReplicaCounts , oldTotalReplicas )
256258
257259 // Expect that the number of replicas on store 1 to have changed. We can't
258260 // assert that the distribution will be even across all three stores, but s1
259261 // (the initial leaseholder and replica) should have a different number of
260262 // replicas than before. Rebalancing is otherwise disabled in this test, so
261263 // the only replica movements are from the scatter.
264+
265+ // Enable tracing to capture detailed scatter execution information.
266+ r .Exec (t , "SET tracing = on" )
262267 r .Exec (t , "ALTER TABLE test.t SCATTER" )
268+ r .Exec (t , "SET tracing = off" )
269+
270+ // If the test fails, print the trace of the scatter statement to help
271+ // us investigate failures.
272+ defer func () {
273+ if ! t .Failed () {
274+ return
275+ }
276+
277+ traceRows := r .QueryStr (t , "SELECT age, message FROM [SHOW TRACE FOR SESSION]" )
278+ if len (traceRows ) > 0 {
279+ t .Logf ("SCATTER trace (%d relevant messages):" , len (traceRows ))
280+ for _ , row := range traceRows {
281+ t .Logf ("[%s] %s" , row [0 ], row [1 ])
282+ }
283+ }
284+ }()
285+
263286 newReplicaCounts , newTotalReplicas , err := getReplicaCounts ()
264287 require .NoError (t , err )
288+ t .Logf ("after scatter: replica distribution across stores: %v (total: %d)" , newReplicaCounts , newTotalReplicas )
265289
266290 require .Equal (t , oldTotalReplicas , newTotalReplicas ,
267291 "expected total replica count to remain the same post-scatter, " +
0 commit comments