@@ -315,6 +315,17 @@ func (c *Cluster) syncStreams() error {
315315 return nil
316316 }
317317
318+ // create publications to each created slot
319+ c .logger .Debug ("syncing database publications" )
320+ for publication , tables := range publications {
321+ // but first check for existing publications
322+ dbName := slots [publication ]["database" ]
323+ err = c .syncPublication (publication , dbName , tables )
324+ if err != nil {
325+ c .logger .Warningf ("could not sync publication %q in database %q: %v" , publication , dbName , err )
326+ }
327+ }
328+
318329 // add extra logical slots to Patroni config
319330 c .logger .Debug ("syncing Postgres config for logical decoding" )
320331 requiresRestart , err := c .syncPostgresConfig (requiredPatroniConfig )
@@ -326,17 +337,7 @@ func (c *Cluster) syncStreams() error {
326337 return nil
327338 }
328339
329- // next, create publications to each created slot
330- c .logger .Debug ("syncing database publications" )
331- for publication , tables := range publications {
332- // but first check for existing publications
333- dbName := slots [publication ]["database" ]
334- err = c .syncPublication (publication , dbName , tables )
335- if err != nil {
336- c .logger .Warningf ("could not sync publication %q in database %q: %v" , publication , dbName , err )
337- }
338- }
339-
340+ // after Postgres was restarted we can create stream CRDs
340341 err = c .createOrUpdateStreams ()
341342 if err != nil {
342343 return err
0 commit comments