fix(replicas): GRANT SELECT on publisher tables to repl_user
settings/setting_templates were created after replica setup, so the subscription COPY user could not read them and tablesync looped. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,8 +7,8 @@
|
|||||||
REPLICA_DSNS="postgresql://USER:PASSWORD@SLAVE_1_IP:5433/superadmin
|
REPLICA_DSNS="postgresql://USER:PASSWORD@SLAVE_1_IP:5433/superadmin
|
||||||
postgresql://USER:PASSWORD@SLAVE_2_IP:5432/superadmin"
|
postgresql://USER:PASSWORD@SLAVE_2_IP:5432/superadmin"
|
||||||
|
|
||||||
# Read-only app user on replicas (program-settings API). Grants re-applied after data repair.
|
# Replication user that subscribers use to COPY from this publisher (must SELECT every table).
|
||||||
# REPLICA_APP_DB_USER=montime
|
# REPL_PUBLISHER_USER=repl_user
|
||||||
|
|
||||||
# Optional. If TCP 127.0.0.1:15432 is refused, omit this — the script falls back
|
# Optional. If TCP 127.0.0.1:15432 is refused, omit this — the script falls back
|
||||||
# to unix socket / `runuser -u postgres` on port 15432.
|
# to unix socket / `runuser -u postgres` on port 15432.
|
||||||
|
|||||||
@@ -188,6 +188,21 @@ publisher_dump() {
|
|||||||
|
|
||||||
connect_publisher
|
connect_publisher
|
||||||
|
|
||||||
|
REPL_PUBLISHER_USER="${REPL_PUBLISHER_USER:-repl_user}"
|
||||||
|
|
||||||
|
grant_publisher_repl_user() {
|
||||||
|
echo "publisher: GRANT SELECT on all tables to ${REPL_PUBLISHER_USER}"
|
||||||
|
publisher_psql -v ON_ERROR_STOP=1 -q -c "
|
||||||
|
GRANT USAGE ON SCHEMA public TO ${REPL_PUBLISHER_USER};
|
||||||
|
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ${REPL_PUBLISHER_USER};
|
||||||
|
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO ${REPL_PUBLISHER_USER};
|
||||||
|
ALTER DEFAULT PRIVILEGES IN SCHEMA public
|
||||||
|
GRANT SELECT ON TABLES TO ${REPL_PUBLISHER_USER};
|
||||||
|
" || true
|
||||||
|
}
|
||||||
|
|
||||||
|
grant_publisher_repl_user
|
||||||
|
|
||||||
table_count() {
|
table_count() {
|
||||||
local dsn="$1" table="$2"
|
local dsn="$1" table="$2"
|
||||||
if [[ "$dsn" == "$PUBLISHER" ]]; then
|
if [[ "$dsn" == "$PUBLISHER" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user