skip slots where publication sync failed (#2091)

This commit is contained in:
Felix Kunde 2022-10-25 14:51:29 +02:00 committed by GitHub
parent 70f3ee8e36
commit 529cdfc0b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -279,6 +279,7 @@ func (c *Cluster) syncStreams() error {
c.streamApplications = appIds
slots := make(map[string]map[string]string)
slotsToSync := make(map[string]map[string]string)
publications := make(map[string]map[string]acidv1.StreamTable)
requiredPatroniConfig := c.Spec.Patroni
@ -308,13 +309,6 @@ func (c *Cluster) syncStreams() error {
}
}
// no slots = no streams defined
if len(slots) > 0 {
requiredPatroniConfig.Slots = slots
} else {
return nil
}
// create publications to each created slot
c.logger.Debug("syncing database publications")
for publication, tables := range publications {
@ -323,7 +317,16 @@ func (c *Cluster) syncStreams() error {
err = c.syncPublication(publication, dbName, tables)
if err != nil {
c.logger.Warningf("could not sync publication %q in database %q: %v", publication, dbName, err)
continue
}
slotsToSync[publication] = slots[publication]
}
// no slots to sync = no streams defined or publications created
if len(slotsToSync) > 0 {
requiredPatroniConfig.Slots = slotsToSync
} else {
return nil
}
// add extra logical slots to Patroni config