Skip to content

Instantly share code, notes, and snippets.

@jberkus
Created March 27, 2014 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberkus/9815260 to your computer and use it in GitHub Desktop.
Save jberkus/9815260 to your computer and use it in GitHub Desktop.
Flexible Freeze outline
Specification:
BASIC VERSION
Config File:
Series of time windows for "low traffic" points.
e.g. "Sunday 1am-4am"
Postgres connection info for 1 database
vacuum settings
min_freeze threshold (default 1,000,000)
pause between freeze length (default 1 minute)
Actions:
1. Called by Cron every hour
2. Checks if it's already running. If so, quits.
3. Checks if it's in a freeze time window. If not, quits.
4. Gets list of unfrozen relations, sorted by oldest XID, minimum per config
5. Loops through relations one at a time:
a. Checks if still in time window (if not, exits)
b. Does VACUUM FREEZE with config settings
c. Pauses per config
6. When it runs out of relations or time, exits.
Requirements
Perl or Python
PostgreSQL drivers
Cron
ADVANCED VERSION
Same as basic version, except:
A. Supports multiple databases
B. Supports checks on system load, concurrent transactions, and wait status
with thresholds for quitting if load is too high
C. Supports multiple threads for parallel freeezing
D. Kills running VACUUM at end of time window if still running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment