@@ -273,6 +273,17 @@ func (c *Cluster) syncStreams() error {
273273 return nil
274274 }
275275
276+ // update config to set wal_level: logical
277+ requiredPatroniConfig := c .Spec .Patroni
278+ requiresRestart , err := c .syncPostgresConfig (requiredPatroniConfig )
279+ if err != nil {
280+ return fmt .Errorf ("failed to snyc Postgres config for event streaming: %v" , err )
281+ }
282+ if requiresRestart {
283+ c .logger .Debugf ("updated Postgres config. Server will be restarted and streams will get created during next sync" )
284+ return nil
285+ }
286+
276287 // fetch different application IDs from streams section
277288 // there will be a separate event stream resource for each ID
278289 appIds := gatherApplicationIds (c .Spec .Streams )
@@ -282,7 +293,6 @@ func (c *Cluster) syncStreams() error {
282293 slotsToSync := make (map [string ]map [string ]string )
283294 publications := make (map [string ]map [string ]acidv1.StreamTable )
284295
285- requiredPatroniConfig := c .Spec .Patroni
286296 if len (requiredPatroniConfig .Slots ) > 0 {
287297 slots = requiredPatroniConfig .Slots
288298 }
@@ -330,15 +340,10 @@ func (c *Cluster) syncStreams() error {
330340 }
331341
332342 // add extra logical slots to Patroni config
333- c .logger .Debug ("syncing Postgres config for logical decoding" )
334- requiresRestart , err := c .syncPostgresConfig (requiredPatroniConfig )
343+ _ , err = c .syncPostgresConfig (requiredPatroniConfig )
335344 if err != nil {
336345 return fmt .Errorf ("failed to snyc Postgres config for event streaming: %v" , err )
337346 }
338- if requiresRestart {
339- c .logger .Debugf ("updated Postgres config. Server will be restarted and streams will get created during next sync" )
340- return nil
341- }
342347
343348 // after Postgres was restarted we can create stream CRDs
344349 err = c .createOrUpdateStreams ()
0 commit comments