Skip to content

Commit e8a8b18

Browse files
Revert "feat(core): Enable insights for sqlite legacy (#14606)"
This reverts commit 88ed7be.
1 parent 0e2eceb commit e8a8b18

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

packages/cli/src/modules/insights/__tests__/insights.pre-init.test.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@ describe('InsightsModulePreInit', () => {
1010
it('should return false if instance type is not "main"', () => {
1111
const ctx: ModulePreInitContext = {
1212
instance: mock<InstanceSettings>({ instanceType: 'worker' }),
13-
database: mock<DatabaseConfig>({ type: 'sqlite' }),
13+
database: mock<DatabaseConfig>({ type: 'sqlite', sqlite: { poolSize: 10 } }),
1414
};
1515
expect(shouldLoadModule(ctx)).toBe(false);
1616
});
1717

18-
it.each(['postgresdb', 'mariadb', 'mysqldb', 'sqlite'])(
19-
'should return true if instance type is "main"',
18+
it('should return false if database type is "sqlite" and poolSize is < 1', () => {
19+
const ctx: ModulePreInitContext = {
20+
instance: mock<InstanceSettings>({ instanceType: 'main' }),
21+
database: mock<DatabaseConfig>({ type: 'sqlite', sqlite: { poolSize: 0 } }),
22+
};
23+
expect(shouldLoadModule(ctx)).toBe(false);
24+
});
25+
26+
it.each(['postgresdb', 'mariadb', 'mysqldb'])(
27+
'should return true if instance type is "main" and database is not sqlite',
2028
(dbType: 'postgresdb' | 'mysqldb' | 'sqlite' | 'mariadb') => {
2129
const ctx: ModulePreInitContext = {
2230
instance: mock<InstanceSettings>({ instanceType: 'main' }),
@@ -25,4 +33,12 @@ describe('InsightsModulePreInit', () => {
2533
expect(shouldLoadModule(ctx)).toBe(true);
2634
},
2735
);
36+
37+
it('should return true if instance type is "main" and sqlite poolSize is >= 1', () => {
38+
const ctx: ModulePreInitContext = {
39+
instance: mock<InstanceSettings>({ instanceType: 'main' }),
40+
database: mock<DatabaseConfig>({ type: 'sqlite', sqlite: { poolSize: 1 } }),
41+
};
42+
expect(shouldLoadModule(ctx)).toBe(true);
43+
});
2844
});

packages/cli/src/modules/insights/insights.pre-init.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ import type { ModulePreInitContext } from '../modules.config';
33
export const shouldLoadModule = (ctx: ModulePreInitContext) =>
44
// Only main instance(s) should collect insights
55
// Because main instances are informed of all finished workflow executions, whatever the mode
6-
ctx.instance.instanceType === 'main';
6+
ctx.instance.instanceType === 'main' &&
7+
// This is because legacy sqlite (without pool) does not support nested transactions needed for insights
8+
// TODO: remove once benchmarks confirm this issue is solved with buffering / flushing mechanism
9+
(ctx.database.type !== 'sqlite' || ctx.database.sqlite.poolSize > 0);

0 commit comments

Comments
 (0)