-
Notifications
You must be signed in to change notification settings - Fork 48
RHINENG-26348: add ability to repair system_advisories_0 partition #2287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TenSt
wants to merge
1
commit into
RedHatInsights:master
Choose a base branch
from
TenSt:stepan/RHINENG-26348-repair-system-advisories-table
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| -- One-off repair for corrupt system_advisories_0 (pg_xact / unreadable heap). | ||
| -- Gated by database_admin flag repair_system_advisories_0=true (default false). | ||
| -- Irreversible: drops partition data for hash remainder 0 and clears related caches. | ||
| -- Safe to re-run only when intentionally wiping bucket 0 again (e.g. failed cutover). | ||
|
|
||
| BEGIN; | ||
|
|
||
| -- Detach if still a partition of system_advisories (no-op when already detached/missing). | ||
| DO $$ | ||
| BEGIN | ||
| IF EXISTS ( | ||
| SELECT 1 | ||
| FROM pg_inherits i | ||
| JOIN pg_class child ON child.oid = i.inhrelid | ||
| JOIN pg_class parent ON parent.oid = i.inhparent | ||
| WHERE parent.relname = 'system_advisories' | ||
| AND child.relname = 'system_advisories_0' | ||
| ) THEN | ||
| EXECUTE 'ALTER TABLE system_advisories DETACH PARTITION system_advisories_0'; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| DROP TABLE IF EXISTS system_advisories_0; | ||
|
|
||
| CREATE TABLE system_advisories_0 | ||
| PARTITION OF system_advisories | ||
| FOR VALUES WITH (MODULUS 32, REMAINDER 0) | ||
| WITH (fillfactor = '70', autovacuum_vacuum_scale_factor = '0.05'); | ||
|
|
||
| GRANT SELECT, INSERT, UPDATE, DELETE ON system_advisories_0 TO evaluator; | ||
| GRANT UPDATE, DELETE ON system_advisories_0 TO manager; | ||
| GRANT SELECT, INSERT, UPDATE, DELETE ON system_advisories_0 TO listener; | ||
| GRANT SELECT, DELETE ON system_advisories_0 TO vmaas_sync; | ||
|
|
||
| -- Clear denormalized counts for accounts that hash into remainder 0 (do not read old _0). | ||
| DELETE FROM advisory_account_data aad | ||
| WHERE satisfies_hash_partition( | ||
| 'system_advisories'::regclass, 32, 0, aad.rh_account_id); | ||
|
|
||
| DELETE FROM account_advisory aa | ||
| WHERE satisfies_hash_partition( | ||
| 'system_advisories'::regclass, 32, 0, aa.rh_account_id); | ||
|
|
||
| COMMIT; |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.