@@ -756,13 +756,8 @@ impl Coordinator {
756756 ) ;
757757
758758 let builtin_table_updates = vec ! [ builtin_table_retraction, builtin_table_addition] ;
759-
760- self . builtin_table_update ( )
761- . execute ( builtin_table_updates)
762- . await
763- . 0
764- . instrument ( info_span ! ( "coord::message_cluster_event::table_updates" ) )
765- . await ;
759+ // Returns a Future that completes when the Builtin Table write is completed.
760+ let builtin_table_completion = self . builtin_table_update ( ) . defer ( builtin_table_updates) ;
766761
767762 let cluster = self . catalog ( ) . get_cluster ( event. cluster_id ) ;
768763 let replica = cluster. replica ( event. replica_id ) . expect ( "Replica exists" ) ;
@@ -771,12 +766,24 @@ impl Coordinator {
771766 . get_cluster_replica_status ( event. cluster_id , event. replica_id ) ;
772767
773768 if old_replica_status != new_replica_status {
774- self . broadcast_notice ( AdapterNotice :: ClusterReplicaStatusChanged {
769+ let notifier = self . broadcast_notice_tx ( ) ;
770+ let notice = AdapterNotice :: ClusterReplicaStatusChanged {
775771 cluster : cluster. name . clone ( ) ,
776772 replica : replica. name . clone ( ) ,
777773 status : new_replica_status,
778774 time : event. time ,
779- } ) ;
775+ } ;
776+ // In a separate task, so we don't block the Coordinator, wait for the builtin
777+ // table update to complete, and then notify active sessions.
778+ mz_ore:: task:: spawn (
779+ || format ! ( "cluster_event-{}-{}" , event. cluster_id, event. replica_id) ,
780+ async move {
781+ // Wait for the builtin table updates to complete.
782+ builtin_table_completion. await ;
783+ // Notify all sessions that were active at the time the cluster status changed.
784+ ( notifier) ( notice)
785+ } ,
786+ ) ;
780787 }
781788 }
782789 }
0 commit comments