Skip to content

Commit

Permalink
Revert "Increase connectors Sequelize connection pool (#5808)" (#5811)
Browse files Browse the repository at this point in the history
This reverts commit 254892f.
  • Loading branch information
spolu authored Jun 24, 2024
1 parent 67e6d74 commit 3a6f127
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 38 deletions.
38 changes: 6 additions & 32 deletions connectors/src/resources/storage/index.ts
Original file line number Diff line number Diff line change
@@ -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,
}
);
5 changes: 4 additions & 1 deletion front/lib/development.ts
Original file line number Diff line number Diff line change
@@ -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() ||
Expand Down
2 changes: 1 addition & 1 deletion front/lib/resources/storage/index.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
1 change: 0 additions & 1 deletion types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 0 additions & 3 deletions types/src/shared/env.ts

This file was deleted.

0 comments on commit 3a6f127

Please sign in to comment.