risingwavelabs/risingwave · error · anyhow::Error
PostgreSQL table {} exists, but the connection user `{}` doe
Error message
PostgreSQL table {} exists, but the connection user `{}` does not have USAGE privilege on schema `{}`. Grant privileges on the upstream PostgreSQL database: {} What it means
After confirming schema and table exist, ensure_table_privilege verifies the connection user holds the USAGE privilege on the schema (needed to resolve and read objects within it). This error is raised when the user lacks that privilege, and the message includes a ready-made GRANT statement to fix it.
Source
Thrown at src/connector/src/connector_common/postgres.rs:347
let privilege_status = PostgresTablePrivilege {
user_name: row.get("user_name"),
schema_exists: row.get("schema_exists"),
table_exists: row.get("table_exists"),
has_schema_usage: row.get("has_schema_usage"),
has_table_privilege: row.get("has_table_privilege"),
has_any_column_privilege: row.get("has_any_column_privilege"),
};
if !privilege_status.schema_exists {
return Err(anyhow!("PostgreSQL schema `{schema}` does not exist").into());
}
if !privilege_status.table_exists {
return Err(anyhow!("PostgreSQL table `{schema}`.`{table}` does not exist").into());
}
if !privilege_status.has_schema_usage {
return Err(anyhow!(
"PostgreSQL table {} exists, but the connection user `{}` does not have USAGE privilege on schema `{}`. Grant privileges on the upstream PostgreSQL database: {}",
format_pg_table_name(schema, table),
privilege_status.user_name,
schema,
format_grant_usage(schema, &privilege_status.user_name),
)
.into());
}
if !privilege_status.has_table_privilege {
let column_privilege_msg = if privilege_status.has_any_column_privilege {
" The user has column-level privilege on at least one column, but RisingWave requires table-level privilege for CDC schema discovery and snapshot reads."
} else {
""
};
return Err(anyhow!(
"PostgreSQL table {} exists, but the connection user `{}` does not have {} privilege on it.{} Grant privileges on the upstream PostgreSQL database: {}",
format_pg_table_name(schema, table),View on GitHub (pinned to 6469eb736d)
Solutions
- Run the GRANT printed in the error message: `GRANT USAGE ON SCHEMA <schema> TO <user>;` as a superuser or schema owner.
- Also grant table read privileges needed by the source (e.g. `GRANT SELECT ON <schema>.<table> TO <user>;`).
- For CDC, additionally verify replication prerequisites: REPLICATION role/`pg_hba.conf` entry and a publication covering the table.
- Re-run source creation after the grants take effect (no server restart needed).
Example fix
// before: user has SELECT but no schema USAGE // after: grant USAGE on the schema GRANT USAGE ON SCHEMA app TO rw_user; GRANT SELECT ON app.orders TO rw_user;
Defensive patterns
Strategy: validation
Validate before calling
// verify USAGE privilege before creating the source
SELECT has_schema_privilege('rw_user', 'app', 'USAGE'); Prevention
- Provision connector users with GRANT USAGE ON SCHEMA plus table SELECT
- Run has_schema_privilege checks in deployment runbooks
- For CDC, also pre-verify REPLICATION role, pg_hba.conf, and publication coverage
When it happens
Trigger: Creating a PostgreSQL CDC/table source where the configured user passes existence checks but has never been granted `USAGE ON SCHEMA <schema>`, e.g. a fresh replication/readonly user provisioned only with table-level grants.
Common situations: Newly created users in hardened Postgres setups where public schema USAGE was revoked; users restricted to a single database; DBAs granting SELECT on tables but forgetting schema USAGE; schema owners using non-public schemas.
Understand the failure class
Background: "You do not have permission" / 403 Forbidden errors: authenticated but not allowed — causes and fixes across open-source libraries — this error's family across 31 libraries.
Related errors
- PostgreSQL schema `{schema}` does not exist
- PostgreSQL table `{schema}`.`{table}` does not exist
- PostgreSQL table {} exists, but the connection user `{}` doe
- CDC auto schema change error: unsupported data type `{ty}` i
- Failed to check if table exists: {}
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/ed92edcc9cdc365f.
Report an issue: GitHub.