diff --git a/internal/flypg/node.go b/internal/flypg/node.go index e578313e..d91993b5 100644 --- a/internal/flypg/node.go +++ b/internal/flypg/node.go @@ -511,46 +511,46 @@ func (n *Node) evaluateCollationIntegrity(ctx context.Context, conn *pgx.Conn) e log.Printf("[WARN] Collation mismatches detected. Refreshing collation versions.\n") - // Detect any indexes that are currently impacted by collation mismatches. - // Unfortunately, we will need to do this for each database. dbs, err := admin.ListDatabases(ctx, conn) if err != nil { return fmt.Errorf("failed to list databases: %s", err) } + // Manually adding this, since it's not returned by the list databases query. dbs = append(dbs, admin.DbInfo{Name: "template1"}) mismatches := 0 + // Iterate over each database and evaluate collation integrity. for _, db := range dbs { - // Establish a connection to the specified database. dbConn, err := n.NewLocalConnection(ctx, db.Name, n.SUCredentials) if err != nil { return fmt.Errorf("failed to establish connection to database %s: %s", db.Name, err) } defer func() { _ = dbConn.Close(ctx) }() + // TODO - Identify the impacted objects and log them. // Count collation mismatches count, err := countCollationMismatchs(ctx, dbConn) if err != nil { log.Printf("[WARN] Failed to count collation mismatches: %s\n", err) } - // Skip if no mismatches are found. + // Skip if no mismatches were found. if err == nil && count == 0 { continue } mismatches++ - log.Printf("[WARN] %d collation mismatches detected %s\n", count, db.Name) - // Identify any impacted indexes and re-index them concurrently. if err := reIndexMismatchedIndexes(ctx, dbConn); err != nil { return fmt.Errorf("failed to reindex database: %s", err) } } + // We won't be able to confirm the collation integrity until the next boot since impacted + // indexes will be reindexed concurrently. if mismatches > 0 { return nil }