@@ -537,8 +537,8 @@ func (d *dispatcherStat) handleSingleDataEvents(events []dispatcher.DispatcherEv
537537 return false
538538 }
539539 if events [0 ].GetType () == commonEvent .TypeDDLEvent {
540- originalDDL := events [0 ].Event .(* commonEvent.DDLEvent )
541- ddl , err := d .applyRoutingToDDLEvent ( originalDDL )
540+ ddl := events [0 ].Event .(* commonEvent.DDLEvent )
541+ ddl , err := d .target . GetRouter (). ApplyToDDLEvent ( ddl )
542542 if err != nil {
543543 log .Error ("failed to apply routing to DDL event" ,
544544 zap .Stringer ("changefeedID" , d .target .GetChangefeedID ()),
@@ -551,23 +551,8 @@ func (d *dispatcherStat) handleSingleDataEvents(events []dispatcher.DispatcherEv
551551 }
552552 events [0 ].Event = ddl
553553 if ddl .TableInfo != nil {
554- // Check if this DDL's TableInfo is for a different table.
555- // This can happen with CREATE TABLE LIKE, where the DDL is added to the
556- // reference table's history for blocking purposes, but the TableInfo is
557- // for the new table. In this case, we should NOT update the stored tableInfo.
558- dispatcherTableID := d .target .GetTableSpan ().TableID
559- ddlTableID := ddl .TableInfo .TableName .TableID
560- if ddlTableID != dispatcherTableID {
561- log .Debug ("DDL TableInfo is for a different table, skipping tableInfo update" ,
562- zap .Stringer ("changefeedID" , d .target .GetChangefeedID ()),
563- zap .Stringer ("dispatcher" , d .getDispatcherID ()),
564- zap .Int64 ("dispatcherTableID" , dispatcherTableID ),
565- zap .Int64 ("ddlTableID" , ddlTableID ),
566- zap .String ("ddlTableName" , ddl .TableInfo .TableName .Table ))
567- } else {
568- d .tableInfoVersion .Store (ddl .FinishedTs )
569- d .tableInfo .Store (ddl .TableInfo )
570- }
554+ d .tableInfoVersion .Store (ddl .FinishedTs )
555+ d .tableInfo .Store (ddl .TableInfo )
571556 }
572557 }
573558 d .updateCommitTsStateByEvents (state , events )
@@ -720,7 +705,8 @@ func (d *dispatcherStat) handleHandshakeEvent(event dispatcher.DispatcherEvent)
720705 }
721706 tableInfo := handshakeEvent .TableInfo
722707 if tableInfo != nil {
723- d .tableInfo .Store (d .applyRoutingToTableInfo (tableInfo ))
708+ tableInfo := d .target .GetRouter ().ApplyToTableInfo (tableInfo )
709+ d .tableInfo .Store (tableInfo )
724710 }
725711 state .lastEventSeq .Store (handshakeEvent .Seq )
726712 d .observeCurrentEpochMaxEventTs (state , handshakeEvent .GetCommitTs ())
@@ -820,17 +806,3 @@ func (d *dispatcherStat) newDispatcherRemoveRequest(serverId string) *messaging.
820806 },
821807 }
822808}
823-
824- // applyRoutingToTableInfo applies routing rules to the TableInfo and returns a new TableInfo
825- // with TargetSchema/TargetTable set. If no routing is needed (no router configured, or routing
826- // results in same schema/table), returns the original tableInfo unchanged.
827- // This avoids mutating shared TableInfo objects that may be used by multiple changefeeds.
828- func (d * dispatcherStat ) applyRoutingToTableInfo (tableInfo * common.TableInfo ) * common.TableInfo {
829- router := d .target .GetRouter ()
830- return router .ApplyToTableInfo (tableInfo )
831- }
832-
833- func (d * dispatcherStat ) applyRoutingToDDLEvent (ddl * commonEvent.DDLEvent ) (* commonEvent.DDLEvent , error ) {
834- router := d .target .GetRouter ()
835- return router .ApplyToDDLEvent (ddl )
836- }
0 commit comments