Enforce read-only sessions on diagnostic scripts#64
Open
teknogeek0 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a read-only safety belt to the scripts that only ever read, via an exported
PGOPTIONS.What
compare-pg-params.shdefault_transaction_read_only=on+statement_timeout=30s+lock_timeout=5scheck-cdc-status.shcheck-migration-status.shpreflight-check.shverify-migration.shread_onlyonly — it manages its own per-tableCOUNT(*)timeout via--exact-count-timeout, and a shortlock_timeoutcould turn a transient lock on a busy source into a false verification failureWhy
These are diagnostics that should never write.
default_transaction_read_only=onmakes 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
export PGOPTIONSafter each script's env load, so every existingpsqlcall inherits it with no per-call changes.read_only=on.bash -npasses on all five.No automated test suite in this repo; validated by syntax check and code inspection.