Skip to content

Commit 0cae146

Browse files
authored
Force database to reinitilizate with longer query timeout for refresh materialized view jobs (#1791)
1 parent dcba0f9 commit 0cae146

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

backend/src/bin/jobs/refreshMaterializedViewsForCube.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const job: CrowdJob = {
1919

2020
try {
2121
// initialize database with 15 minutes query timeout
22-
const database = await databaseInit(1000 * 60 * 15)
22+
const forceNewDbInstance = true
23+
const database = await databaseInit(1000 * 60 * 15, forceNewDbInstance)
2324

2425
const materializedViews = [
2526
'mv_members_cube',

backend/src/database/databaseConnection.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ let cached
55
/**
66
* Initializes the connection to the Database
77
*/
8-
export async function databaseInit(queryTimeoutMilliseconds: number = 30000) {
8+
export async function databaseInit(
9+
queryTimeoutMilliseconds: number = 30000,
10+
forceNewInstance: boolean = false,
11+
) {
12+
if (forceNewInstance) {
13+
return models(queryTimeoutMilliseconds)
14+
}
15+
916
if (!cached) {
1017
cached = models(queryTimeoutMilliseconds)
1118
}

0 commit comments

Comments
 (0)