Skip to content

Commit

Permalink
Do not use connectors replica in relocation worker (#10446)
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd authored Jan 31, 2025
1 parent 53c22fc commit a82f103
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ModelId } from "@dust-tt/types";
import { QueryTypes } from "sequelize";

import { getConnectorsReplicaDbConnection } from "@app/lib/production_checks/utils";
import { getConnectorsPrimaryDbConnection } from "@app/lib/production_checks/utils";
import logger from "@app/logger/logger";
import type {
ReadTableChunkParams,
Expand All @@ -17,17 +17,15 @@ export async function getAllConnectorsForWorkspace({
workspaceId: string;
}) {
// TODO: Use the front databases to get the connectorIds.

// We can use the replica db because we don't need to write to it.
const connectorReplicaDb = getConnectorsReplicaDbConnection();
const connectorsDb = getConnectorsPrimaryDbConnection();

const localLogger = logger.child({
workspaceId,
});

localLogger.info("[SQL] Getting all connectors for workspace");

const rows = await connectorReplicaDb.query<{ id: ModelId }>(
const rows = await connectorsDb.query<{ id: ModelId }>(
`SELECT * FROM "connectors" WHERE "workspaceId" = :workspaceId`,
{
replacements: { workspaceId },
Expand Down Expand Up @@ -64,10 +62,9 @@ export async function getAllConnectorsForWorkspace({
}

export async function getTablesWithConnectorIdOrder() {
// We can use the replica db because we don't need to write to it.
const connectorReplicaDb = getConnectorsReplicaDbConnection();
const connectorsDb = getConnectorsPrimaryDbConnection();

return getTopologicalOrder(connectorReplicaDb, {
return getTopologicalOrder(connectorsDb, {
columnName: "connectorId",
});
}
Expand All @@ -93,11 +90,11 @@ export async function readConnectorsTableChunk({
localLogger.info("[SQL Table] Reading table chunk");

// We can use the replica db because we don't need to write to it.
const connectorReplicaDb = getConnectorsReplicaDbConnection();
const connectorsDb = getConnectorsPrimaryDbConnection();

const idClause = lastId ? `AND id > ${lastId}` : "";

const rows = await connectorReplicaDb.query<{ id: ModelId }>(
const rows = await connectorsDb.query<{ id: ModelId }>(
`SELECT * FROM "${tableName}"
WHERE "connectorId" = :connectorId ${idClause}
ORDER BY id
Expand Down

0 comments on commit a82f103

Please sign in to comment.