feat(postgres): support concurrent index creation
This commit is contained in:
1 parent
ebf412b144
commit
aa6d60533c
38 files changed
+1917
-34
No files matched your search
+18
-1
@@ -1,7 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { frontendQueryTimeoutDelayMs, frontendQueryTimeoutSecsForSql, queryTimeoutSecsForConnection } from "@/lib/sql/queryTimeout";
|
||||
import { CONCURRENT_INDEX_QUERY_TIMEOUT_SECS, frontendQueryTimeoutDelayMs, frontendQueryTimeoutSecsForSql, queryTimeoutSecsForConcurrentIndex, queryTimeoutSecsForConnection } from "@/lib/sql/queryTimeout";
|
||||
|
||||
describe("queryTimeout", () => {
|
||||
it("gives CREATE INDEX CONCURRENTLY a dedicated long budget instead of the 30s default", () => {
|
||||
expect(CONCURRENT_INDEX_QUERY_TIMEOUT_SECS).toBe(1800);
|
||||
expect(CONCURRENT_INDEX_QUERY_TIMEOUT_SECS).toBeGreaterThan(30);
|
||||
expect(frontendQueryTimeoutDelayMs(CONCURRENT_INDEX_QUERY_TIMEOUT_SECS)).toBe(1_800_000);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["non-concurrent", 30, false, 30],
|
||||
["non-concurrent", 3600, false, 3600],
|
||||
["concurrent + 0 (unlimited)", 0, true, 0],
|
||||
["concurrent + 30 (below floor)", 30, true, 1800],
|
||||
["concurrent + 600 (below floor)", 600, true, 1800],
|
||||
["concurrent + 1800 (floor)", 1800, true, 1800],
|
||||
["concurrent + 3600 (above floor)", 3600, true, 3600],
|
||||
] as const)("queryTimeoutSecsForConcurrentIndex preserves %s", (_name, configured, concurrent, expected) => {
|
||||
expect(queryTimeoutSecsForConcurrentIndex(configured, concurrent)).toBe(expected);
|
||||
});
|
||||
it("lets PostgreSQL row queries use the backend inactivity timeout", () => {
|
||||
expect(frontendQueryTimeoutSecsForSql("SELECT * FROM sample_records LIMIT 2000", "postgres", 30)).toBe(0);
|
||||
expect(frontendQueryTimeoutSecsForSql("/* page */\nWITH rows AS (SELECT 1) SELECT * FROM rows", "postgres", 30)).toBe(0);
|
||||
|
||||
Reference in new issue
Block a user