@@ -209,17 +209,51 @@ func (s ClickHouseSuite) Test_MariaDB_CompressedColumn_AddedMidCDC() {
209209
210210 catalogPool , err := internal .GetCatalogConnectionPoolFromEnv (s .t .Context ())
211211 require .NoError (s .t , err )
212+ s .t .Cleanup (func () {
213+ if ! s .t .Failed () {
214+ return
215+ }
216+
217+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
218+ defer cancel ()
219+ rows , err := catalogPool .Query (ctx , `
220+ SELECT error_type, error_message
221+ FROM peerdb_stats.flow_errors
222+ WHERE flow_name = $1
223+ ORDER BY id` , flowConnConfig .FlowJobName )
224+ if err != nil {
225+ s .t .Log ("failed to query flow logs after test failure:" , err )
226+ return
227+ }
228+ defer rows .Close ()
229+ for rows .Next () {
230+ var errorType , message string
231+ if err := rows .Scan (& errorType , & message ); err != nil {
232+ s .t .Log ("failed to scan flow log after test failure:" , err )
233+ return
234+ }
235+ s .t .Logf ("flow log after test failure: type=%s message=%s" , errorType , message )
236+ }
237+ if err := rows .Err (); err != nil {
238+ s .t .Log ("failed while reading flow logs after test failure:" , err )
239+ }
240+ })
212241
213242 EnvWaitForCount (env , s , "waiting on initial snapshot" , dstTableName , "id,name" , 1 )
243+ // Seeing the snapshot row at the destination does not guarantee that the CDC activity has
244+ // started. Prove that CDC is consuming this source before introducing the unsupported type.
245+ require .NoError (s .t , src .Exec (s .t .Context (), fmt .Sprintf (
246+ `INSERT INTO %s (id, name) VALUES (2, 'cdc-ready')` , srcFullName )))
247+ EnvWaitForCount (env , s , "waiting for CDC to start" , dstTableName , "id,name" , 2 )
214248
215249 // Add a COMPRESSED column mid-stream, then write a row so a row event carrying the undecodable
216250 // wire type reaches the pipe and trips the TABLE_MAP detection.
217251 require .NoError (s .t , src .Exec (s .t .Context (), fmt .Sprintf (
218252 `ALTER TABLE %s ADD COLUMN val TEXT COMPRESSED` , srcFullName )))
219253 require .NoError (s .t , src .Exec (s .t .Context (), fmt .Sprintf (
220- `INSERT INTO %s (id, name, val) VALUES (2 , 'cdc', 'compressed value')` , srcFullName )))
254+ `INSERT INTO %s (id, name, val) VALUES (3 , 'cdc', 'compressed value')` , srcFullName )))
221255
222- EnvWaitFor (s .t , env , 6 * time .Minute , "waiting for compressed column error" , func () bool {
256+ EnvWaitFor (s .t , env , 3 * time .Minute , "waiting for compressed column error" , func () bool {
223257 count , err := GetLogCount (s .t .Context (), catalogPool , flowConnConfig .FlowJobName , "error" , "cannot be replicated via CDC" )
224258 if err != nil {
225259 s .t .Log ("Error querying flow_errors:" , err )
0 commit comments