You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 01916d9
Browse filesBrowse the repository at this point in the historyBrowse files
feat(server): build the attention acknowledgement index through store migration 0003
Main's numbered migrations pin each schema version's checksum, which covers
indexes.sql, so the audit-log index the acknowledgement listing reads needs
its own migration. 0003 only creates sqb_security_audit_attention, with
IF NOT EXISTS so an index an operator pre-built CONCURRENTLY on PostgreSQL is
skipped. Version 3's SQLite and PostgreSQL checksums are pinned, and the
upgrade tests now expect the latest version.
The server docs say how to pre-build the index before upgrading, since on a
large audit log the migration holds up audit writes, including sign-ins.
Coordination: the observed-runs server half adds its own migration
(sqb_warehouse_runs) later; whichever lands first takes 0003, and the other
renumbers to 0004 and pins its checksums again.
Copy file name to clipboardExpand all lines: crates/sqlbuild-orchestration/src/store_migrations/_helpers/migration.rs
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,18 @@ use crate::store_migrations::models::{StoreMigration, StoreMigrationPlan};
14
14
usecrate::store::constants::{INDEXES,SCHEMA};
15
15
16
16
/// The migrations after the baseline, in order: entry `i` includes `store_migrations/sql/{NNNN}_{name}.{sqlite,postgres}.sql` and brings a store to version `NNNN = BASELINE_VERSION + i + 1`.
-- The index the Overview's attention acknowledgement listing reads: each item's latest
2
+
-- acknowledgement or withdrawal. IF NOT EXISTS skips an index an operator pre-built.
3
+
-- On a large audit log, pre-build it with CREATE INDEX CONCURRENTLY IF NOT EXISTS to keep sign-ins flowing.
4
+
CREATEINDEXIF NOT EXISTS sqb_security_audit_attention ON sqb_security_audit((scope_json ->>'location_id'), (scope_json ->>'target'), (scope_json ->>'key'), storage_id) WHERE action IN ('attention.acknowledged', 'attention.acknowledgement_withdrawn');
-- The index the Overview's attention acknowledgement listing reads: each item's latest
2
+
-- acknowledgement or withdrawal. IF NOT EXISTS skips an index an operator pre-built.
3
+
CREATEINDEXIF NOT EXISTS sqb_security_audit_attention ON sqb_security_audit((scope_json ->>'location_id'), (scope_json ->>'target'), (scope_json ->>'key'), storage_id) WHERE action IN ('attention.acknowledged', 'attention.acknowledgement_withdrawn');
Copy file name to clipboardExpand all lines: src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/server.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -348,11 +348,17 @@ server can't read what they wrote.
348
348
the control server is older than this worker and refused its run report; upgrade the server before its workers
349
349
```
350
350
351
-
Some releases add an index to the control database, which the server builds when it starts. On
352
-
PostgreSQL that build holds a lock on its table, so on a large table writes wait for it: the index
353
-
on acknowledgements in the audit log, for example, delays sign-ins until it is built. Upgrade when
354
-
few people are signed in, or create the index yourself first with `CREATE INDEX CONCURRENTLY` and the
355
-
definition in the release notes; the server then finds it already there.
351
+
Some migrations add an index, which the server builds when it migrates. On PostgreSQL that build
352
+
locks its table against writes, so on a large table those writes wait until it is built. Migration
353
+
`0003` indexes acknowledgements in the audit log, so on a large audit log it holds up audit writes,
354
+
including sign-ins. To avoid that, build the index yourself before you upgrade, without blocking
355
+
writes:
356
+
357
+
```sql
358
+
CREATEINDEXCONCURRENTLY IF NOT EXISTS sqb_security_audit_attention ON sqb_security_audit((scope_json ->>'location_id'), (scope_json ->>'target'), (scope_json ->>'key'), storage_id) WHERE action IN ('attention.acknowledged', 'attention.acknowledgement_withdrawn');
359
+
```
360
+
361
+
The migration then finds the index already there and skips it.
Copy file name to clipboardExpand all lines: website/src/content/docs/docs/cli/server.mdx
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -327,11 +327,17 @@ server can't read what they wrote.
327
327
the control server is older than this worker and refused its run report; upgrade the server before its workers
328
328
```
329
329
330
-
Some releases add an index to the control database, which the server builds when it starts. On
331
-
PostgreSQL that build holds a lock on its table, so on a large table writes wait for it: the index
332
-
on acknowledgements in the audit log, for example, delays sign-ins until it is built. Upgrade when
333
-
few people are signed in, or create the index yourself first with `CREATE INDEX CONCURRENTLY` and the
334
-
definition in the release notes; the server then finds it already there.
330
+
Some migrations add an index, which the server builds when it migrates. On PostgreSQL that build
331
+
locks its table against writes, so on a large table those writes wait until it is built. Migration
332
+
`0003` indexes acknowledgements in the audit log, so on a large audit log it holds up audit writes,
333
+
including sign-ins. To avoid that, build the index yourself before you upgrade, without blocking
334
+
writes:
335
+
336
+
```sql
337
+
CREATEINDEXCONCURRENTLY IF NOT EXISTS sqb_security_audit_attention ON sqb_security_audit((scope_json ->>'location_id'), (scope_json ->>'target'), (scope_json ->>'key'), storage_id) WHERE action IN ('attention.acknowledged', 'attention.acknowledgement_withdrawn');
338
+
```
339
+
340
+
The migration then finds the index already there and skips it.
0 commit comments