Skip to content

Enforce read-only sessions on diagnostic scripts#64

Open
teknogeek0 wants to merge 1 commit into
mainfrom
harden/readonly-diagnostics
Open

Enforce read-only sessions on diagnostic scripts#64
teknogeek0 wants to merge 1 commit into
mainfrom
harden/readonly-diagnostics

Conversation

@teknogeek0

Copy link
Copy Markdown
Contributor

Adds a read-only safety belt to the scripts that only ever read, via an exported PGOPTIONS.

What

Script Guard
compare-pg-params.sh default_transaction_read_only=on + statement_timeout=30s + lock_timeout=5s
check-cdc-status.sh full (as above)
check-migration-status.sh full
preflight-check.sh full
verify-migration.sh read_only only — it manages its own per-table COUNT(*) timeout via --exact-count-timeout, and a short lock_timeout could turn a transient lock on a busy source into a false verification failure

Why

These are diagnostics that should never write. default_transaction_read_only=on makes accidental writes impossible even if a query is later edited; the statement/lock timeouts keep a check from hanging on a busy database — important since several query the live source.

Notes

  • Applied as a single export PGOPTIONS after each script's env load, so every existing psql call inherits it with no per-call changes.
  • Confirmed all five scripts are write-free before adding read_only=on.
  • bash -n passes on all five.
  • AGENTS.md read-only notes updated to state the actual enforcement.

No automated test suite in this repo; validated by syntax check and code inspection.

Export PGOPTIONS with default_transaction_read_only=on (plus statement and
lock timeouts on the fast diagnostics) so status/preflight/compare checks
cannot write and can't hang on a busy source. verify-migration gets
read-only only, since it manages its own per-table COUNT(*) timeout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant