mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-07-30 08:38:50 +02:00
feat(core): Enable insights for sqlite legacy (#14606)
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user