{"id":24782564,"url":"https://github.com/levkk/pg-replica-auditor","last_synced_at":"2026-05-03T19:34:45.100Z","repository":{"id":52697259,"uuid":"232477313","full_name":"levkk/pg-replica-auditor","owner":"levkk","description":"Run a few sanity checks on your logical PostgreSQL replica to make sure its the same as the primary.","archived":false,"fork":false,"pushed_at":"2021-04-20T19:32:55.000Z","size":113,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-25T10:33:50.567Z","etag":null,"topics":["checker","logical-replication","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/levkk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-08T04:25:50.000Z","updated_at":"2025-08-27T12:22:02.000Z","dependencies_parsed_at":"2022-08-21T18:00:27.384Z","dependency_job_id":null,"html_url":"https://github.com/levkk/pg-replica-auditor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/levkk/pg-replica-auditor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levkk%2Fpg-replica-auditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levkk%2Fpg-replica-auditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levkk%2Fpg-replica-auditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levkk%2Fpg-replica-auditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/levkk","download_url":"https://codeload.github.com/levkk/pg-replica-auditor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levkk%2Fpg-replica-auditor/sbom","scorecard":{"id":586305,"data":{"date":"2025-08-11","repo":{"name":"github.com/levkk/pg-replica-auditor","commit":"e40375ce06802dfaf05a5d911c85eed793969656"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/24 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2020-92 / GHSA-hj5v-574p-mj7c","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: GHSA-g7vv-2v7x-gj9p","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 9 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T20:36:13.797Z","repository_id":52697259,"created_at":"2025-08-20T20:36:13.797Z","updated_at":"2025-08-20T20:36:13.797Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32582840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checker","logical-replication","postgresql"],"created_at":"2025-01-29T11:18:04.320Z","updated_at":"2026-05-03T19:34:45.068Z","avatar_url":"https://github.com/levkk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-replica-auditor\n\nA tool to compare a PostgreSQL logical replica to its primary. It can help detect data inconsistencies.\n\n## Features\n\n### Assumptions\nThese tests assume that `id` and `updated_at` (or column specified in `--lag-column`) columns exist and have indexes for efficient querying and that the table exists on both databases.\n\n#### Row comparison\nRuns row comparisons between primary and replica using two methods:\n\n1. select 8128 rows (or number of rows given to `--rows`) at random between `MIN(id)` and `MAX(id)`\n2. select the last 1000 rows.\n\n#### Replica lag\nChecks for \"replica lag\" by comparing `MAX(updated_at)` on the given table on both databases.\n\n#### MinMax\nChecks that the minimum `id` and the maximum `id` match on both replica and primary. These can drift _a little_ because of replica lag.\n\n#### Bulk 1000 Sum\nTake the sum of the `id` column in chunks of 1000 and compare it between databases. This assumes that retrieving rows in bulk is easier than at random and runs faster than the row comparison and can scan more rows.\n\n#### Count all rows\nCounts all the rows using `COUNT(lag_column)` to make sure row counts match on both replica and primary. Very slow, since it has to do a full scan (index or table). Adjust `--count-before` to count all columns before a timestamp on `--lag-column`, or `updated_at` by default.\n\n#### Missing Sequential Records\nGo throught the table with a step size of `MAX(id)` * `--step-size=0.01`. The assumption is that if records will be missing, they will be missing in bulk, grouped together.\n\n## Requirements\n\n1. Python 3\n2. Postgres development files (required by psycopg2). On Mac OS, use `brew install postgresql`. On Ubuntu, install `libpq-dev`.\n\n## Installation\n\n### Development\nUsing virtualenv, `pip install -r requirements.txt`\n\n### Production\nUsing Pypi, `pip install pg-replica-auditor`.\n\n## Usage\n\nThis script requires three arguments:\n1. `--primary`, any acceptable Postgres connection string (incl. DSN),\n2. `--replica`, same as `--primary` but for the replica database,\n\nOptional arguments:\n1. `--exclude-tables`, excludes the comma-separated tables from the scan,\n2. `--table`, only scans this table,\n3. `--debug`, will print debugging information,\n4. `--rows`, will scan this many rows in the row comparisons check,\n5. `--lag-column`, will use this column for the replica lag check,\n6. `--show-skipped`, will print the skipped rows in the Last 1000 check,\n7. `--count-before`, will count all rows in the table created/updated before this timestamp,\n8. `--step-size`, will decrease the step size for missing sequential records search.\n\nExample:\n\n```bash\n$ pgreplicaauditor --primary=postgres://primary-db.amazonaws.com:5432/my_db --replica=postgres://replica-db.amazonaws.com:5432/my_db --table=immutable_items --lag-column=created_at --count-before=\"2020-04-06\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevkk%2Fpg-replica-auditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flevkk%2Fpg-replica-auditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevkk%2Fpg-replica-auditor/lists"}