feat(core): Enable insights for sqlite legacy (#14606)

This commit is contained in:
Guillaume Jacquart
2025-04-22 10:38:34 +02:00
committed by GitHub
parent 6b344f8a7e
commit 88ed7beff2
2 changed files with 4 additions and 23 deletions
@@ -10,21 +10,13 @@ describe('InsightsModulePreInit', () => {
it('should return false if instance type is not "main"', () => {
const ctx: ModulePreInitContext = {
instance: mock<InstanceSettings>({ instanceType: 'worker' }),
database: mock<DatabaseConfig>({ type: 'sqlite', sqlite: { poolSize: 10 } }),
database: mock<DatabaseConfig>({ type: 'sqlite' }),
};
expect(shouldLoadModule(ctx)).toBe(false);
});
it('should return false if database type is "sqlite" and poolSize is < 1', () => {
const ctx: ModulePreInitContext = {
instance: mock<InstanceSettings>({ instanceType: 'main' }),
database: mock<DatabaseConfig>({ type: 'sqlite', sqlite: { poolSize: 0 } }),
};
expect(shouldLoadModule(ctx)).toBe(false);
});
it.each(['postgresdb', 'mariadb', 'mysqldb'])(
'should return true if instance type is "main" and database is not sqlite',
it.each(['postgresdb', 'mariadb', 'mysqldb', 'sqlite'])(
'should return true if instance type is "main"',
(dbType: 'postgresdb' | 'mysqldb' | 'sqlite' | 'mariadb') => {
const ctx: ModulePreInitContext = {
instance: mock<InstanceSettings>({ instanceType: 'main' }),
@@ -33,12 +25,4 @@ describe('InsightsModulePreInit', () => {
expect(shouldLoadModule(ctx)).toBe(true);
},
);
it('should return true if instance type is "main" and sqlite poolSize is >= 1', () => {
const ctx: ModulePreInitContext = {
instance: mock<InstanceSettings>({ instanceType: 'main' }),
database: mock<DatabaseConfig>({ type: 'sqlite', sqlite: { poolSize: 1 } }),
};
expect(shouldLoadModule(ctx)).toBe(true);
});
});
@@ -3,7 +3,4 @@ import type { ModulePreInitContext } from '../modules.config';
export const shouldLoadModule = (ctx: ModulePreInitContext) =>
// Only main instance(s) should collect insights
// Because main instances are informed of all finished workflow executions, whatever the mode
ctx.instance.instanceType === 'main' &&
// This is because legacy sqlite (without pool) does not support nested transactions needed for insights
// TODO: remove once benchmarks confirm this issue is solved with buffering / flushing mechanism
(ctx.database.type !== 'sqlite' || ctx.database.sqlite.poolSize > 0);
ctx.instance.instanceType === 'main';