Skip to content

Commit 50b0665

Browse files
authored
Enable read on replica for all (#16740)
Removing the feature flag to enable read on replica for all workspaces. It will still be possible to toggle off the feature by removing the env variable `PG_DATABASE_REPLICA_URL`.
1 parent 8696083 commit 50b0665

6 files changed

Lines changed: 3 additions & 25 deletions

File tree

packages/twenty-front/src/generated-metadata/graphql.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,6 @@ export enum FeatureFlagKey {
13131313
IS_PAGE_LAYOUT_ENABLED = 'IS_PAGE_LAYOUT_ENABLED',
13141314
IS_POSTGRESQL_INTEGRATION_ENABLED = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
13151315
IS_PUBLIC_DOMAIN_ENABLED = 'IS_PUBLIC_DOMAIN_ENABLED',
1316-
IS_READ_ON_REPLICA_ENABLED = 'IS_READ_ON_REPLICA_ENABLED',
13171316
IS_RECORD_PAGE_LAYOUT_ENABLED = 'IS_RECORD_PAGE_LAYOUT_ENABLED',
13181317
IS_STRIPE_INTEGRATION_ENABLED = 'IS_STRIPE_INTEGRATION_ENABLED',
13191318
IS_TIMELINE_ACTIVITY_MIGRATED = 'IS_TIMELINE_ACTIVITY_MIGRATED',

packages/twenty-front/src/generated/graphql.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,6 @@ export enum FeatureFlagKey {
12961296
IS_PAGE_LAYOUT_ENABLED = 'IS_PAGE_LAYOUT_ENABLED',
12971297
IS_POSTGRESQL_INTEGRATION_ENABLED = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
12981298
IS_PUBLIC_DOMAIN_ENABLED = 'IS_PUBLIC_DOMAIN_ENABLED',
1299-
IS_READ_ON_REPLICA_ENABLED = 'IS_READ_ON_REPLICA_ENABLED',
13001299
IS_RECORD_PAGE_LAYOUT_ENABLED = 'IS_RECORD_PAGE_LAYOUT_ENABLED',
13011300
IS_STRIPE_INTEGRATION_ENABLED = 'IS_STRIPE_INTEGRATION_ENABLED',
13021301
IS_TIMELINE_ACTIVITY_MIGRATED = 'IS_TIMELINE_ACTIVITY_MIGRATED',

packages/twenty-server/src/engine/api/common/common-query-runners/common-base-query-runner.service.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { WorkspacePreQueryHookPayload } from 'src/engine/api/graphql/workspace-q
3232
import { WorkspaceQueryHookService } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-hook/workspace-query-hook.service';
3333
import { ApiKeyRoleService } from 'src/engine/core-modules/api-key/services/api-key-role.service';
3434
import { AuthContext } from 'src/engine/core-modules/auth/types/auth-context.type';
35-
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
3635
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
3736
import { MetricsService } from 'src/engine/core-modules/metrics/metrics.service';
3837
import { MetricsKeys } from 'src/engine/core-modules/metrics/types/metrics-keys.type';
@@ -337,16 +336,9 @@ export abstract class CommonBaseQueryRunnerService<
337336
intersectionOf: [roleId],
338337
};
339338

340-
const isReadOnReplicaEnabled =
341-
await this.featureFlagService.isFeatureEnabled(
342-
FeatureFlagKey.IS_READ_ON_REPLICA_ENABLED,
343-
workspaceId,
344-
);
345-
346-
const globalWorkspaceDataSource =
347-
this.isReadOnly && isReadOnReplicaEnabled
348-
? await this.globalWorkspaceOrmManager.getGlobalWorkspaceDataSourceReplica()
349-
: await this.globalWorkspaceOrmManager.getGlobalWorkspaceDataSource();
339+
const globalWorkspaceDataSource = this.isReadOnly
340+
? await this.globalWorkspaceOrmManager.getGlobalWorkspaceDataSourceReplica()
341+
: await this.globalWorkspaceOrmManager.getGlobalWorkspaceDataSource();
350342

351343
const repository = globalWorkspaceDataSource.getRepository(
352344
queryRunnerContext.flatObjectMetadata.nameSingular,

packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ export enum FeatureFlagKey {
1414
IS_DASHBOARD_V2_ENABLED = 'IS_DASHBOARD_V2_ENABLED',
1515
IS_TIMELINE_ACTIVITY_MIGRATED = 'IS_TIMELINE_ACTIVITY_MIGRATED',
1616
IS_GLOBAL_WORKSPACE_DATASOURCE_ENABLED = 'IS_GLOBAL_WORKSPACE_DATASOURCE_ENABLED',
17-
IS_READ_ON_REPLICA_ENABLED = 'IS_READ_ON_REPLICA_ENABLED',
1817
IS_WORKSPACE_CREATION_V2_ENABLED = 'IS_WORKSPACE_CREATION_V2_ENABLED',
1918
}

packages/twenty-server/src/engine/twenty-orm/entity-manager/workspace-entity-manager.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ describe('WorkspaceEntityManager', () => {
213213
IS_DASHBOARD_V2_ENABLED: false,
214214
IS_TIMELINE_ACTIVITY_MIGRATED: false,
215215
IS_GLOBAL_WORKSPACE_DATASOURCE_ENABLED: false,
216-
IS_READ_ON_REPLICA_ENABLED: false,
217216
IS_WORKSPACE_CREATION_V2_ENABLED: false,
218217
},
219218
eventEmitterService: {

packages/twenty-server/src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { type ObjectLiteral } from 'typeorm';
44

55
import { type WorkspaceAuthContext } from 'src/engine/api/common/interfaces/workspace-auth-context.interface';
66

7-
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
87
import { buildObjectIdByNameMaps } from 'src/engine/metadata-modules/flat-object-metadata/utils/build-object-id-by-name-maps.util';
98
import { GlobalWorkspaceDataSource } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-datasource';
109
import { GlobalWorkspaceDataSourceService } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-datasource.service';
@@ -114,13 +113,4 @@ export class GlobalWorkspaceOrmManager {
114113
userWorkspaceRoleMap,
115114
};
116115
}
117-
118-
private async isReadOnReplicaEnabled(workspaceId: string): Promise<boolean> {
119-
const { featureFlagsMap } = await this.workspaceCacheService.getOrRecompute(
120-
workspaceId,
121-
['featureFlagsMap'],
122-
);
123-
124-
return !!featureFlagsMap[FeatureFlagKey.IS_READ_ON_REPLICA_ENABLED];
125-
}
126116
}

0 commit comments

Comments
 (0)