Skip to content

Commit

Permalink
fix statement_timeout bug
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Oct 15, 2023
1 parent 6798a70 commit e561ce7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions lib/PubSubManager/initPubSubManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ export async function initPubSubManager(this: PubSubManager): Promise<PubSubMana
`
}

const queryIdentifier = "prostgles query used to keep track of which prgl backend clients are still connected"
checkForStaleTriggers = `
DO $$
BEGIN
/*
${queryIdentifier}
${REALTIME_TRIGGER_CHECK_QUERY}
${PubSubManager.EXCLUDE_QUERY_FROM_SCHEMA_WATCH_ID}
*/
Expand All @@ -92,6 +94,7 @@ export async function initPubSubManager(this: PubSubManager): Promise<PubSubMana
const queryTimeoutMillis = Math.min(5e3, Math.round(this.appCheckFrequencyMS/2));
this.db.any(`
/*
${queryIdentifier}
${REALTIME_TRIGGER_CHECK_QUERY}
${PubSubManager.EXCLUDE_QUERY_FROM_SCHEMA_WATCH_ID}
*/
Expand All @@ -101,9 +104,9 @@ export async function initPubSubManager(this: PubSubManager): Promise<PubSubMana
SELECT pg_cancel_backend(pid)
FROM pg_catalog.pg_stat_activity
WHERE pid <> pg_backend_pid()
AND query = \${checkForStaleTriggers};
AND query = \${queryIdentifier};
END $$;
`, { queryTimeoutMillis, checkForStaleTriggers })
`, { queryTimeoutMillis, queryIdentifier })
await this.db.any(checkForStaleTriggers);
tries = 5;
log("updated last_check");
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prostgles-server",
"version": "4.1.90",
"version": "4.1.91",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion tests/client/PID.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2606752
2611629
2 changes: 1 addition & 1 deletion tests/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e561ce7

Please sign in to comment.