From 3a6f127492cdb6512bede818adfb2c9a0ec1febc Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Mon, 24 Jun 2024 12:04:36 +0200 Subject: [PATCH] Revert "Increase connectors Sequelize connection pool (#5808)" (#5811) This reverts commit 254892f2cf16c8bf97799dc950d87a9fff2b68e5. --- connectors/src/resources/storage/index.ts | 38 ++++------------------- front/lib/development.ts | 5 ++- front/lib/resources/storage/index.ts | 2 +- types/src/index.ts | 1 - types/src/shared/env.ts | 3 -- 5 files changed, 11 insertions(+), 38 deletions(-) delete mode 100644 types/src/shared/env.ts diff --git a/connectors/src/resources/storage/index.ts b/connectors/src/resources/storage/index.ts index f538de250c54..18b8bf85f7aa 100644 --- a/connectors/src/resources/storage/index.ts +++ b/connectors/src/resources/storage/index.ts @@ -1,36 +1,10 @@ -import { isDevelopment } from "@dust-tt/types"; import { Sequelize } from "sequelize"; -import logger from "@connectors/logger/logger"; import { dbConfig } from "@connectors/resources/storage/config"; -export const sequelizeConnection = new Sequelize({ - logging: false, -}); - -const acquireAttempts = new WeakMap(); - -new Sequelize(dbConfig.getRequiredDatabaseURI(), { - pool: { - // Default is 5. - max: isDevelopment() ? 5 : 10, - }, - logging: false, - hooks: { - beforePoolAcquire: (options) => { - acquireAttempts.set(options, Date.now()); - }, - afterPoolAcquire: (connection, options) => { - const elapsedTime = Date.now() - acquireAttempts.get(options); - if (elapsedTime > 100) { - logger.info( - { - elapsedTime, - callStack: new Error().stack, - }, - "Long sequelize connection acquisition detected" - ); - } - }, - }, -}); +export const sequelizeConnection = new Sequelize( + dbConfig.getRequiredDatabaseURI(), + { + logging: false, + } +); diff --git a/front/lib/development.ts b/front/lib/development.ts index a6c05f015456..05b680e38720 100644 --- a/front/lib/development.ts +++ b/front/lib/development.ts @@ -1,9 +1,12 @@ import type { WorkspaceType } from "@dust-tt/types"; -import { isDevelopment } from "@dust-tt/types"; export const PRODUCTION_DUST_WORKSPACE_ID = "0ec9852c2f"; const PRODUCTION_DUST_APPS_WORKSPACE_ID = "78bda07b39"; +export function isDevelopment() { + return process.env.NODE_ENV === "development"; +} + export function isDevelopmentOrDustWorkspace(owner: WorkspaceType) { return ( isDevelopment() || diff --git a/front/lib/resources/storage/index.ts b/front/lib/resources/storage/index.ts index b755346a72e2..3eba50f5566a 100644 --- a/front/lib/resources/storage/index.ts +++ b/front/lib/resources/storage/index.ts @@ -1,6 +1,6 @@ -import { isDevelopment } from "@dust-tt/types"; import { Sequelize } from "sequelize"; +import { isDevelopment } from "@app/lib/development"; import { dbConfig } from "@app/lib/resources/storage/config"; import logger from "@app/logger/logger"; diff --git a/types/src/index.ts b/types/src/index.ts index 6eddf95d5056..de52b593a1fc 100644 --- a/types/src/index.ts +++ b/types/src/index.ts @@ -64,7 +64,6 @@ export * from "./front/user"; export * from "./front/workspace"; export * from "./shared/cache"; export * from "./shared/deployment"; -export * from "./shared/env"; export * from "./shared/message_classification"; export * from "./shared/model_id"; export * from "./shared/nango_errors"; diff --git a/types/src/shared/env.ts b/types/src/shared/env.ts deleted file mode 100644 index 53647dcb4235..000000000000 --- a/types/src/shared/env.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function isDevelopment() { - return process.env.NODE_ENV === "development"; -}