senzing_governor.py
contains a Governor
class that can be used to govern the behavior of
programs like:
when used with PostgreSQL database.
The senzing_governor.py
in this repository monitors the age of the PostgreSQL Transaction IDs
to determine when to pass back control to the caller.
Essentially it does the following SQL statement:
SELECT age(datfrozenxid) FROM pg_database WHERE datname = (%s);
If the age is greater than a high-watermark, SENZING_GOVERNOR_POSTGRESQL_HIGH_WATERMARK, then the Governor waits until the watermark recedes to a low-watermark, SENZING_GOVERNOR_POSTGRESQL_LOW_WATERMARK.
The lowering of the watermark must be done manually by using PostgreSQL VACUUM.
At Senzing, we strive to create GitHub documentation in a "don't make me think" style. For the most part, instructions are copy and paste. Whenever thinking is needed, it's marked with a "thinking" icon 🤔. Whenever customization is needed, it's marked with a "pencil" icon ✏️. If the instructions are not clear, please let us know by opening a new Documentation issue describing where we can improve. Now on with the show...
- 🤔 - A "thinker" icon means that a little extra thinking may be required. Perhaps there are some choices to be made. Perhaps it's an optional step.
- ✏️ - A "pencil" icon means that the instructions may need modification before performing.
⚠️ - A "warning" icon means that something tricky is happening, so pay attention.
- Space: This repository and demonstration require 10 KB free disk space.
- Time: Budget 20 minutes to get the demonstration up-and-running, depending on CPU and network speeds.
- Background knowledge: This repository assumes a working knowledge of:
🤔 The following tasks need to be complete before proceeding. These are "one-time tasks" which may already have been completed.
- Install system dependencies:
- Use
apt
based installation for Debian, Ubuntu and others- See apt-packages.txt for list
- Use
yum
based installation for Red Hat, CentOS, openSuse and others.- See yum-packages.txt for list
- Use
- Install Python dependencies:
- See requirements.txt for list
-
Get a local copy of senzing_governor.py and programs that test the governor.
-
✏️ Specify a director of where to download files. Example:
export SENZING_GOVERNOR_PROJECT_DIR=~/test-governor
-
Make project directory. Example:
mkdir -p ${SENZING_GOVERNOR_PROJECT_DIR}
-
Download files. Example:
curl -X GET \ --output ${SENZING_GOVERNOR_PROJECT_DIR}/senzing_governor.py \ https://raw.githubusercontent.com/Senzing/governor-postgresql-transaction-id/main/senzing_governor.py curl -X GET \ --output ${SENZING_GOVERNOR_PROJECT_DIR}/senzing_governor_tester.py \ https://raw.githubusercontent.com/Senzing/governor-postgresql-transaction-id/main/senzing_governor_tester.py chmod +x ${SENZING_GOVERNOR_PROJECT_DIR}/senzing_governor_tester.py curl -X GET \ --output ${SENZING_GOVERNOR_PROJECT_DIR}/senzing_governor_tester_context_manager.py \ https://raw.githubusercontent.com/Senzing/governor-postgresql-transaction-id/main/senzing_governor_tester_context_manager.py chmod +x ${SENZING_GOVERNOR_PROJECT_DIR}/senzing_governor_tester_context_manager.py
-
-
🤔 Alternative: The entire git repository can be downloaded by following instructions at Clone repository
-
Update
PYTHONPATH
. Example:export PYTHONPATH=${PYTHONPATH}:${SENZING_GOVERNOR_PROJECT_DIR}
-
✏️ Identify PostgreSQL database. The format of the URL can be seen at SENZING_DATABASE_URL Example:
export SENZING_GOVERNOR_DATABASE_URLS=postgresql://postgres:postgres@localhost:5432/G2
-
🤔 Optional: Multiple databases can be specified in a list. Example:
export SENZING_GOVERNOR_DATABASE_URLS=postgresql://postgres:postgres@localhost:5432/G2,postgresql://postgres:postgres@localhost:5432/G2-RES
-
🤔 Optional: The comma is used as a list item separator. If a different separator is needed it can be specified. Example:
export SENZING_GOVERNOR_LIST_SEPARATOR="+" export SENZING_GOVERNOR_DATABASE_URLS="postgresql://postgres:postgres@localhost:5432/G2+postgresql://postgres:postgres@localhost:5432/G2-RES"
-
-
Run the command. Example:
${SENZING_GOVERNOR_PROJECT_DIR}/senzing_governor_tester.py
-
For more examples of use, see Examples of CLI.
Configuration values specified by environment variable or command line parameter.