Skip to content

Commit

Permalink
Validate mirror: Bypass no rows error (#1309)
Browse files Browse the repository at this point in the history
Bypass no rows error due to some managed offerings being different

---------

Co-authored-by: Philip Dubé <[email protected]>
  • Loading branch information
Amogh-Bharadwaj and serprex authored Feb 16, 2024
1 parent c0bc2ea commit cf07c9a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions flow/connectors/postgres/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,22 @@ func (c *PostgresConnector) CheckReplicationPermissions(ctx context.Context, use
var replicationRes bool
err := c.conn.QueryRow(ctx, "SELECT rolreplication FROM pg_roles WHERE rolname = $1", username).Scan(&replicationRes)
if err != nil {
return err
if err == pgx.ErrNoRows {
c.logger.Warn("No rows in pg_roles for user. Skipping rolereplication check",
"username", username)
} else {
return err
}
}

if !replicationRes {
// RDS case: check pg_settings for rds.logical_replication
var setting string
err := c.conn.QueryRow(ctx, "SELECT setting FROM pg_settings WHERE name = 'rds.logical_replication'").Scan(&setting)
if err != nil || setting != "on" {
return errors.New("postgres user does not have replication role")
if err != pgx.ErrNoRows {
if err != nil || setting != "on" {
return errors.New("postgres user does not have replication role")
}
}
}

Expand Down

0 comments on commit cf07c9a

Please sign in to comment.