Files
AI-Horde/sql_statements
tazlin 1f17469c70 fix(kudos): the migration's index builds and CHECK validation run without lock or statement timeouts
- sql_statements/5.1.16.txt: section 3 sets lock_timeout and statement_timeout to 0 and resets both at the end. Before it marks an index valid, a concurrent build waits for every transaction with an older snapshot, on any table. Under a lock timeout, one such transaction fails the build after the whole table has been read, and the build leaves an INVALID index. The builds and VALIDATE CONSTRAINT take SHARE UPDATE EXCLUSIVE, which does not conflict with writes, so their waits do not hold up requests.
- pg_temp.kudos_add_legacy_range sets lock_timeout to 5s as a function setting. Adding the NOT VALID CHECK takes ACCESS EXCLUSIVE, and writes queue behind its wait. The swap transactions keep their SET LOCAL timeouts.
- Tests: a concurrent build waits for a transaction on users that stays open longer than any lock timeout in the file, and the run then completes without an INVALID index.
- Docs: the how-to's build and CHECK steps, with a query for the transactions that hold up a build and a check of each table's freeze age.
2026-11-04 00:47:14 -05:00
..
2023-03-06 23:55:27 +01:00
2024-08-10 15:45:14 +02:00
2024-08-10 15:45:14 +02:00
2023-03-21 13:42:32 +01:00
2024-08-10 15:45:14 +02:00
2024-08-10 15:45:14 +02:00
2024-08-10 15:45:14 +02:00
2023-05-03 18:48:45 +02:00
2024-08-10 15:45:14 +02:00
2023-05-08 02:34:08 +02:00
2023-05-09 00:36:12 +02:00
2023-05-20 22:57:18 +02:00
2024-08-10 15:45:14 +02:00
2023-08-31 17:12:00 +02:00
2024-08-10 15:45:14 +02:00
2024-08-10 15:45:14 +02:00
2024-08-10 15:45:14 +02:00
2024-02-03 15:57:01 +01:00
2024-02-28 00:46:22 +01:00
2024-05-21 23:44:28 +02:00
2024-11-03 19:50:02 +01:00
2024-11-03 19:50:02 +01:00
2025-06-08 16:47:24 +02:00
2024-08-10 15:45:14 +02:00

AI-Horde Database Information

  • postgresql >=15
  • pg_cron
  • 5.1.16.txt requires the psql client, because it uses \gexec. Apply it in one session with -v ON_ERROR_STOP=1 and without --single-transaction, as described in Kudos ledger operations.

pg_cron config

Warning

: All .sql files found in a directory deeper than sql_statements/ will be dynamically run, not only the ones specifically identified in this document. Only place .sql files you intend to run in these directories. This does not apply to the sql_statements level (i.e., sql_statements/4.35.1.sql is not automatically run, but sql_statements/cron/your_new_file.sql will be.)

  • cron/
    • schedule_cron_job.sql
      • Creates a stored procedure which schedules a new pg_cron job to execute a specified stored procedure at intervals defined by a cron schedule string, if a job with the same command doesn't already exist.
      • e.g., CALL schedule_cron_job('0-59 * * * *', 'compile_imagegen_stats_totals');
  • stored_procedures
    • compile_*gen_stats_*.sql
      • These files defined stored procedures which populated the compiled_* tables and generally represent minute/hour/day/total statistics about generations.
    • cron_jobs/
      • Schedules any stats compile jobs via schedule_cron_job.