Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ describe('InsightsModulePreInit', () => {
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' }),
Expand All @@ -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);
});
});
5 changes: 1 addition & 4 deletions packages/cli/src/modules/insights/insights.pre-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';