create publication before creating logical replication slot (#2085)

This commit is contained in:
Felix Kunde 2022-10-21 14:31:13 +02:00 committed by GitHub
parent 920f3dee3e
commit d55e74e1e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 11 deletions

View File

@ -315,6 +315,17 @@ func (c *Cluster) syncStreams() error {
return nil
}
// create publications to each created slot
c.logger.Debug("syncing database publications")
for publication, tables := range publications {
// but first check for existing publications
dbName := slots[publication]["database"]
err = c.syncPublication(publication, dbName, tables)
if err != nil {
c.logger.Warningf("could not sync publication %q in database %q: %v", publication, dbName, err)
}
}
// add extra logical slots to Patroni config
c.logger.Debug("syncing Postgres config for logical decoding")
requiresRestart, err := c.syncPostgresConfig(requiredPatroniConfig)
@ -326,17 +337,7 @@ func (c *Cluster) syncStreams() error {
return nil
}
// next, create publications to each created slot
c.logger.Debug("syncing database publications")
for publication, tables := range publications {
// but first check for existing publications
dbName := slots[publication]["database"]
err = c.syncPublication(publication, dbName, tables)
if err != nil {
c.logger.Warningf("could not sync publication %q in database %q: %v", publication, dbName, err)
}
}
// after Postgres was restarted we can create stream CRDs
err = c.createOrUpdateStreams()
if err != nil {
return err