Closed xray-robot closed 11 months ago
Alternative proposal - remove possibility for any cron job or interactive psql-based job to be running by using something like below in setup-grest.sh
instead of listing every cron job to kill:
psql cexplorer -c 'select pg_cancel_backend(pid) from pg_stat_activity where usename='"'"'${USER}'"'"' and application_name = '"'"'psql'"'"' and query not like '"'"'%pg_stat_activity%'"'"';'
As any DB Pool connection (incl. DBSync/PostgREST) queries do not register application_name as psql
Need to test to ensure there are no edge cases. If there is a worry about customized use-cases, we can also add query like '"'"'grest'"'"'
to the command
I think these functions must be extended as you wrote:
The point is - if we go with my proposal we would be able to get rid of much of those functions and replace the logic entirely 🙂
The point is - if we go with my proposal we would be able to get rid of much of those functions and replace the logic entirely 🙂
Yeah, I just wanted to point that out, maybe these functions are being used elsewhere. I don't know if I should close this issue or you will follow up on it. :)
Ah - we will test out and link a PR to map against commit
The names are not the same as the function/procedure names in sql. So there is no tasks interruption on
remove_all_grest_cron_jobs()
becausegrest.get_query_pids_partial_match
doesn't find the right PID, and reinitialization freezes if cron jobs not completed:https://github.com/cardano-community/guild-operators/blob/ae49c9707852413ac8fdc15f95dd3bdfb5c5ce4d/scripts/grest-helper-scripts/setup-grest.sh#L223-L225
Solution: it may be worth rename procedures and functions according to the names from
remove_all_grest_cron_jobs()
:GREST.UPDATE_NEWLY_REGISTERED_ACCOUNTS_STAKE_DISTRIBUTION_CACHE
GREST.STAKE_DISTRIBUTION_CACHE_UPDATE_CHECK()
GREST.CAPTURE_LAST_EPOCH_SNAPSHOT()