@strapi/database 5.58.0 → 5.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +15 -2
- package/dist/connection.js.map +1 -1
- package/dist/connection.mjs +15 -2
- package/dist/connection.mjs.map +1 -1
- package/dist/dialects/sqlite/index.js +3 -3
- package/dist/dialects/sqlite/index.js.map +1 -1
- package/dist/dialects/sqlite/index.mjs +3 -3
- package/dist/dialects/sqlite/index.mjs.map +1 -1
- package/dist/entity-manager/regular-relations.js +1 -1
- package/dist/entity-manager/regular-relations.js.map +1 -1
- package/dist/entity-manager/regular-relations.mjs +1 -1
- package/dist/entity-manager/regular-relations.mjs.map +1 -1
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -3
- package/dist/index.mjs.map +1 -1
- package/dist/migrations/internal.d.ts.map +1 -1
- package/dist/migrations/internal.js +1 -0
- package/dist/migrations/internal.js.map +1 -1
- package/dist/migrations/internal.mjs +1 -0
- package/dist/migrations/internal.mjs.map +1 -1
- package/dist/migrations/runner.d.ts +2 -0
- package/dist/migrations/runner.d.ts.map +1 -1
- package/dist/migrations/runner.js +7 -2
- package/dist/migrations/runner.js.map +1 -1
- package/dist/migrations/runner.mjs +7 -2
- package/dist/migrations/runner.mjs.map +1 -1
- package/dist/migrations/users.d.ts.map +1 -1
- package/dist/migrations/users.js +1 -0
- package/dist/migrations/users.js.map +1 -1
- package/dist/migrations/users.mjs +1 -0
- package/dist/migrations/users.mjs.map +1 -1
- package/dist/pool-diagnostics/details.d.ts +58 -0
- package/dist/pool-diagnostics/details.d.ts.map +1 -0
- package/dist/pool-diagnostics/details.js +42 -0
- package/dist/pool-diagnostics/details.js.map +1 -0
- package/dist/pool-diagnostics/details.mjs +38 -0
- package/dist/pool-diagnostics/details.mjs.map +1 -0
- package/dist/pool-diagnostics/event-loop.d.ts +31 -0
- package/dist/pool-diagnostics/event-loop.d.ts.map +1 -0
- package/dist/pool-diagnostics/event-loop.js +59 -0
- package/dist/pool-diagnostics/event-loop.js.map +1 -0
- package/dist/pool-diagnostics/event-loop.mjs +54 -0
- package/dist/pool-diagnostics/event-loop.mjs.map +1 -0
- package/dist/pool-diagnostics/format.d.ts +9 -0
- package/dist/pool-diagnostics/format.d.ts.map +1 -0
- package/dist/pool-diagnostics/format.js +46 -0
- package/dist/pool-diagnostics/format.js.map +1 -0
- package/dist/pool-diagnostics/format.mjs +42 -0
- package/dist/pool-diagnostics/format.mjs.map +1 -0
- package/dist/pool-diagnostics/index.d.ts +33 -0
- package/dist/pool-diagnostics/index.d.ts.map +1 -0
- package/dist/pool-diagnostics/index.js +117 -0
- package/dist/pool-diagnostics/index.js.map +1 -0
- package/dist/pool-diagnostics/index.mjs +109 -0
- package/dist/pool-diagnostics/index.mjs.map +1 -0
- package/dist/pool-diagnostics/stack.d.ts +12 -0
- package/dist/pool-diagnostics/stack.d.ts.map +1 -0
- package/dist/pool-diagnostics/stack.js +46 -0
- package/dist/pool-diagnostics/stack.js.map +1 -0
- package/dist/pool-diagnostics/stack.mjs +44 -0
- package/dist/pool-diagnostics/stack.mjs.map +1 -0
- package/dist/query/helpers/populate/apply.d.ts.map +1 -1
- package/dist/query/helpers/populate/apply.js +21 -3
- package/dist/query/helpers/populate/apply.js.map +1 -1
- package/dist/query/helpers/populate/apply.mjs +21 -3
- package/dist/query/helpers/populate/apply.mjs.map +1 -1
- package/dist/query/helpers/streams/readable.d.ts +1 -1
- package/dist/query/helpers/streams/readable.d.ts.map +1 -1
- package/dist/query/helpers/streams/readable.js +2 -2
- package/dist/query/helpers/streams/readable.js.map +1 -1
- package/dist/query/helpers/streams/readable.mjs +1 -1
- package/dist/query/helpers/streams/readable.mjs.map +1 -1
- package/dist/schema/diff.d.ts.map +1 -1
- package/dist/schema/diff.js +3 -3
- package/dist/schema/diff.js.map +1 -1
- package/dist/schema/diff.mjs +3 -3
- package/dist/schema/diff.mjs.map +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +20 -18
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/index.mjs +20 -18
- package/dist/schema/index.mjs.map +1 -1
- package/dist/utils/knex-log.d.ts +19 -0
- package/dist/utils/knex-log.d.ts.map +1 -0
- package/dist/utils/knex-log.js +51 -0
- package/dist/utils/knex-log.js.map +1 -0
- package/dist/utils/knex-log.mjs +47 -0
- package/dist/utils/knex-log.mjs.map +1 -0
- package/dist/utils/throttle.d.ts +26 -0
- package/dist/utils/throttle.d.ts.map +1 -0
- package/dist/utils/throttle.js +34 -0
- package/dist/utils/throttle.js.map +1 -0
- package/dist/utils/throttle.mjs +32 -0
- package/dist/utils/throttle.mjs.map +1 -0
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/utils/types.js +9 -9
- package/dist/utils/types.js.map +1 -1
- package/dist/utils/types.mjs +9 -9
- package/dist/utils/types.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/migrations/users.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,eAAO,MAAM,2BAA2B,GAAI,IAAI,QAAQ,KAAG,
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/migrations/users.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,eAAO,MAAM,2BAA2B,GAAI,IAAI,QAAQ,KAAG,qBAiC1D,CAAC"}
|
package/dist/migrations/users.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.js","sources":["../../src/migrations/users.ts"],"sourcesContent":["import path from 'path';\n\nimport fse from 'fs-extra';\n\nimport { discoverMigrationFiles } from './discover';\nimport { createMigrationRunner } from './runner';\nimport { resolveMigrationFiles } from './resolver';\nimport { createStorage } from './storage';\nimport { transformLogMessage } from './logger';\n\nimport type { UserMigrationProvider } from './common';\nimport type { Database } from '..';\n\nexport const createUserMigrationProvider = (db: Database): UserMigrationProvider => {\n const dir = db.config.settings.migrations.dir;\n\n fse.ensureDirSync(dir);\n\n const context = { db };\n\n const runner = createMigrationRunner({\n storage: createStorage({ db, tableName: 'strapi_migrations' }),\n logger: {\n info(message) {\n db.logger.info(transformLogMessage('info', message));\n },\n },\n async getMigrations() {\n const filepaths = discoverMigrationFiles(path.resolve(dir));\n return resolveMigrationFiles(filepaths, context);\n },\n });\n\n return {\n async shouldRun() {\n const pendingMigrations = await runner.pending();\n return pendingMigrations.length > 0 && db.config?.settings?.runMigrations === true;\n },\n async up() {\n await runner.up();\n },\n async down() {\n await runner.down();\n },\n };\n};\n"],"names":["createUserMigrationProvider","db","dir","config","settings","migrations","fse","ensureDirSync","context","runner","createMigrationRunner","storage","createStorage","tableName","logger","info","message","transformLogMessage","getMigrations","filepaths","discoverMigrationFiles","path","resolve","resolveMigrationFiles","shouldRun","pendingMigrations","pending","length","runMigrations","up","down"],"mappings":";;;;;;;;;;;;;;;AAaO,MAAMA,8BAA8B,CAACC,EAAAA,GAAAA;IAC1C,MAAMC,GAAAA,GAAMD,GAAGE,MAAM,CAACC,QAAQ,CAACC,UAAU,CAACH,GAAG;AAE7CI,IAAAA,oBAAAA,CAAIC,aAAa,CAACL,GAAAA,CAAAA;AAElB,IAAA,MAAMM,OAAAA,GAAU;AAAEP,QAAAA;AAAG,KAAA;AAErB,IAAA,MAAMQ,WAASC,4BAAAA,CAAsB;AACnCC,QAAAA,OAAAA,EAASC,qBAAAA,CAAc;AAAEX,YAAAA,EAAAA;YAAIY,SAAAA,EAAW;AAAoB,SAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"users.js","sources":["../../src/migrations/users.ts"],"sourcesContent":["import path from 'path';\n\nimport fse from 'fs-extra';\n\nimport { discoverMigrationFiles } from './discover';\nimport { createMigrationRunner } from './runner';\nimport { resolveMigrationFiles } from './resolver';\nimport { createStorage } from './storage';\nimport { transformLogMessage } from './logger';\n\nimport type { UserMigrationProvider } from './common';\nimport type { Database } from '..';\n\nexport const createUserMigrationProvider = (db: Database): UserMigrationProvider => {\n const dir = db.config.settings.migrations.dir;\n\n fse.ensureDirSync(dir);\n\n const context = { db };\n\n const runner = createMigrationRunner({\n storage: createStorage({ db, tableName: 'strapi_migrations' }),\n withPhase: (phase, fn) => db.runInPhase(phase, fn),\n logger: {\n info(message) {\n db.logger.info(transformLogMessage('info', message));\n },\n },\n async getMigrations() {\n const filepaths = discoverMigrationFiles(path.resolve(dir));\n return resolveMigrationFiles(filepaths, context);\n },\n });\n\n return {\n async shouldRun() {\n const pendingMigrations = await runner.pending();\n return pendingMigrations.length > 0 && db.config?.settings?.runMigrations === true;\n },\n async up() {\n await runner.up();\n },\n async down() {\n await runner.down();\n },\n };\n};\n"],"names":["createUserMigrationProvider","db","dir","config","settings","migrations","fse","ensureDirSync","context","runner","createMigrationRunner","storage","createStorage","tableName","withPhase","phase","fn","runInPhase","logger","info","message","transformLogMessage","getMigrations","filepaths","discoverMigrationFiles","path","resolve","resolveMigrationFiles","shouldRun","pendingMigrations","pending","length","runMigrations","up","down"],"mappings":";;;;;;;;;;;;;;;AAaO,MAAMA,8BAA8B,CAACC,EAAAA,GAAAA;IAC1C,MAAMC,GAAAA,GAAMD,GAAGE,MAAM,CAACC,QAAQ,CAACC,UAAU,CAACH,GAAG;AAE7CI,IAAAA,oBAAAA,CAAIC,aAAa,CAACL,GAAAA,CAAAA;AAElB,IAAA,MAAMM,OAAAA,GAAU;AAAEP,QAAAA;AAAG,KAAA;AAErB,IAAA,MAAMQ,WAASC,4BAAAA,CAAsB;AACnCC,QAAAA,OAAAA,EAASC,qBAAAA,CAAc;AAAEX,YAAAA,EAAAA;YAAIY,SAAAA,EAAW;AAAoB,SAAA,CAAA;AAC5DC,QAAAA,SAAAA,EAAW,CAACC,KAAAA,EAAOC,EAAAA,GAAOf,EAAAA,CAAGgB,UAAU,CAACF,KAAAA,EAAOC,EAAAA,CAAAA;QAC/CE,MAAAA,EAAQ;AACNC,YAAAA,IAAAA,CAAAA,CAAKC,OAAO,EAAA;AACVnB,gBAAAA,EAAAA,CAAGiB,MAAM,CAACC,IAAI,CAACE,2BAAoB,MAAA,EAAQD,OAAAA,CAAAA,CAAAA;AAC7C,YAAA;AACF,SAAA;QACA,MAAME,aAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMC,SAAAA,GAAYC,+BAAAA,CAAuBC,qBAAAA,CAAKC,OAAO,CAACxB,GAAAA,CAAAA,CAAAA;AACtD,YAAA,OAAOyB,+BAAsBJ,SAAAA,EAAWf,OAAAA,CAAAA;AAC1C,QAAA;AACF,KAAA,CAAA;IAEA,OAAO;QACL,MAAMoB,SAAAA,CAAAA,GAAAA;YACJ,MAAMC,iBAAAA,GAAoB,MAAMpB,QAAAA,CAAOqB,OAAO,EAAA;YAC9C,OAAOD,iBAAAA,CAAkBE,MAAM,GAAG,CAAA,IAAK9B,GAAGE,MAAM,EAAEC,UAAU4B,aAAAA,KAAkB,IAAA;AAChF,QAAA,CAAA;QACA,MAAMC,EAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMxB,SAAOwB,EAAE,EAAA;AACjB,QAAA,CAAA;QACA,MAAMC,IAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMzB,SAAOyB,IAAI,EAAA;AACnB,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.mjs","sources":["../../src/migrations/users.ts"],"sourcesContent":["import path from 'path';\n\nimport fse from 'fs-extra';\n\nimport { discoverMigrationFiles } from './discover';\nimport { createMigrationRunner } from './runner';\nimport { resolveMigrationFiles } from './resolver';\nimport { createStorage } from './storage';\nimport { transformLogMessage } from './logger';\n\nimport type { UserMigrationProvider } from './common';\nimport type { Database } from '..';\n\nexport const createUserMigrationProvider = (db: Database): UserMigrationProvider => {\n const dir = db.config.settings.migrations.dir;\n\n fse.ensureDirSync(dir);\n\n const context = { db };\n\n const runner = createMigrationRunner({\n storage: createStorage({ db, tableName: 'strapi_migrations' }),\n logger: {\n info(message) {\n db.logger.info(transformLogMessage('info', message));\n },\n },\n async getMigrations() {\n const filepaths = discoverMigrationFiles(path.resolve(dir));\n return resolveMigrationFiles(filepaths, context);\n },\n });\n\n return {\n async shouldRun() {\n const pendingMigrations = await runner.pending();\n return pendingMigrations.length > 0 && db.config?.settings?.runMigrations === true;\n },\n async up() {\n await runner.up();\n },\n async down() {\n await runner.down();\n },\n };\n};\n"],"names":["createUserMigrationProvider","db","dir","config","settings","migrations","fse","ensureDirSync","context","runner","createMigrationRunner","storage","createStorage","tableName","logger","info","message","transformLogMessage","getMigrations","filepaths","discoverMigrationFiles","path","resolve","resolveMigrationFiles","shouldRun","pendingMigrations","pending","length","runMigrations","up","down"],"mappings":";;;;;;;;AAaO,MAAMA,8BAA8B,CAACC,EAAAA,GAAAA;IAC1C,MAAMC,GAAAA,GAAMD,GAAGE,MAAM,CAACC,QAAQ,CAACC,UAAU,CAACH,GAAG;AAE7CI,IAAAA,GAAAA,CAAIC,aAAa,CAACL,GAAAA,CAAAA;AAElB,IAAA,MAAMM,OAAAA,GAAU;AAAEP,QAAAA;AAAG,KAAA;AAErB,IAAA,MAAMQ,SAASC,qBAAAA,CAAsB;AACnCC,QAAAA,OAAAA,EAASC,aAAAA,CAAc;AAAEX,YAAAA,EAAAA;YAAIY,SAAAA,EAAW;AAAoB,SAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"users.mjs","sources":["../../src/migrations/users.ts"],"sourcesContent":["import path from 'path';\n\nimport fse from 'fs-extra';\n\nimport { discoverMigrationFiles } from './discover';\nimport { createMigrationRunner } from './runner';\nimport { resolveMigrationFiles } from './resolver';\nimport { createStorage } from './storage';\nimport { transformLogMessage } from './logger';\n\nimport type { UserMigrationProvider } from './common';\nimport type { Database } from '..';\n\nexport const createUserMigrationProvider = (db: Database): UserMigrationProvider => {\n const dir = db.config.settings.migrations.dir;\n\n fse.ensureDirSync(dir);\n\n const context = { db };\n\n const runner = createMigrationRunner({\n storage: createStorage({ db, tableName: 'strapi_migrations' }),\n withPhase: (phase, fn) => db.runInPhase(phase, fn),\n logger: {\n info(message) {\n db.logger.info(transformLogMessage('info', message));\n },\n },\n async getMigrations() {\n const filepaths = discoverMigrationFiles(path.resolve(dir));\n return resolveMigrationFiles(filepaths, context);\n },\n });\n\n return {\n async shouldRun() {\n const pendingMigrations = await runner.pending();\n return pendingMigrations.length > 0 && db.config?.settings?.runMigrations === true;\n },\n async up() {\n await runner.up();\n },\n async down() {\n await runner.down();\n },\n };\n};\n"],"names":["createUserMigrationProvider","db","dir","config","settings","migrations","fse","ensureDirSync","context","runner","createMigrationRunner","storage","createStorage","tableName","withPhase","phase","fn","runInPhase","logger","info","message","transformLogMessage","getMigrations","filepaths","discoverMigrationFiles","path","resolve","resolveMigrationFiles","shouldRun","pendingMigrations","pending","length","runMigrations","up","down"],"mappings":";;;;;;;;AAaO,MAAMA,8BAA8B,CAACC,EAAAA,GAAAA;IAC1C,MAAMC,GAAAA,GAAMD,GAAGE,MAAM,CAACC,QAAQ,CAACC,UAAU,CAACH,GAAG;AAE7CI,IAAAA,GAAAA,CAAIC,aAAa,CAACL,GAAAA,CAAAA;AAElB,IAAA,MAAMM,OAAAA,GAAU;AAAEP,QAAAA;AAAG,KAAA;AAErB,IAAA,MAAMQ,SAASC,qBAAAA,CAAsB;AACnCC,QAAAA,OAAAA,EAASC,aAAAA,CAAc;AAAEX,YAAAA,EAAAA;YAAIY,SAAAA,EAAW;AAAoB,SAAA,CAAA;AAC5DC,QAAAA,SAAAA,EAAW,CAACC,KAAAA,EAAOC,EAAAA,GAAOf,EAAAA,CAAGgB,UAAU,CAACF,KAAAA,EAAOC,EAAAA,CAAAA;QAC/CE,MAAAA,EAAQ;AACNC,YAAAA,IAAAA,CAAAA,CAAKC,OAAO,EAAA;AACVnB,gBAAAA,EAAAA,CAAGiB,MAAM,CAACC,IAAI,CAACE,oBAAoB,MAAA,EAAQD,OAAAA,CAAAA,CAAAA;AAC7C,YAAA;AACF,SAAA;QACA,MAAME,aAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMC,SAAAA,GAAYC,sBAAAA,CAAuBC,IAAAA,CAAKC,OAAO,CAACxB,GAAAA,CAAAA,CAAAA;AACtD,YAAA,OAAOyB,sBAAsBJ,SAAAA,EAAWf,OAAAA,CAAAA;AAC1C,QAAA;AACF,KAAA,CAAA;IAEA,OAAO;QACL,MAAMoB,SAAAA,CAAAA,GAAAA;YACJ,MAAMC,iBAAAA,GAAoB,MAAMpB,MAAAA,CAAOqB,OAAO,EAAA;YAC9C,OAAOD,iBAAAA,CAAkBE,MAAM,GAAG,CAAA,IAAK9B,GAAGE,MAAM,EAAEC,UAAU4B,aAAAA,KAAkB,IAAA;AAChF,QAAA,CAAA;QACA,MAAMC,EAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMxB,OAAOwB,EAAE,EAAA;AACjB,QAAA,CAAA;QACA,MAAMC,IAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMzB,OAAOyB,IAAI,EAAA;AACnB,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { EventLoopDelay } from './event-loop';
|
|
2
|
+
export declare const POOL_TIMEOUT_CODE = "DB_POOL_ACQUIRE_TIMEOUT";
|
|
3
|
+
export interface PoolState {
|
|
4
|
+
used: number;
|
|
5
|
+
free: number;
|
|
6
|
+
pendingAcquires: number;
|
|
7
|
+
pendingCreates: number;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PoolTimeoutDetails {
|
|
12
|
+
code: typeof POOL_TIMEOUT_CODE;
|
|
13
|
+
/** How long this caller waited before knex gave up. */
|
|
14
|
+
waitedMs: number;
|
|
15
|
+
/** The timeout knex applied: the smaller of acquireConnectionTimeout and pool.acquireTimeoutMillis. */
|
|
16
|
+
acquireTimeoutMs?: number;
|
|
17
|
+
/** As configured, when set. */
|
|
18
|
+
acquireConnectionTimeout?: number;
|
|
19
|
+
poolAcquireTimeoutMillis?: number;
|
|
20
|
+
/** Pool counts at the moment of the timeout. */
|
|
21
|
+
pool?: PoolState;
|
|
22
|
+
/** tarn's message: the error of a failed connection attempt, or "operation timed out for an unknown reason". */
|
|
23
|
+
poolReason?: string;
|
|
24
|
+
eventLoopDelay?: EventLoopDelay;
|
|
25
|
+
phase?: string;
|
|
26
|
+
hostname: string;
|
|
27
|
+
pid: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TarnPoolLike {
|
|
30
|
+
min?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
acquireTimeoutMillis?: number;
|
|
33
|
+
numUsed(): number;
|
|
34
|
+
numFree(): number;
|
|
35
|
+
numPendingAcquires(): number;
|
|
36
|
+
numPendingCreates(): number;
|
|
37
|
+
}
|
|
38
|
+
export interface KnexClientLike {
|
|
39
|
+
config?: {
|
|
40
|
+
acquireConnectionTimeout?: unknown;
|
|
41
|
+
pool?: {
|
|
42
|
+
acquireTimeoutMillis?: unknown;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/** A tarn pool, or knex's wrapper around a native driver pool, which has no counters. */
|
|
46
|
+
pool?: Partial<TarnPoolLike> | null;
|
|
47
|
+
}
|
|
48
|
+
export interface CollectInput {
|
|
49
|
+
waitedMs: number;
|
|
50
|
+
cause: unknown;
|
|
51
|
+
eventLoopDelay?: EventLoopDelay;
|
|
52
|
+
phase?: string;
|
|
53
|
+
hostname: string;
|
|
54
|
+
pid: number;
|
|
55
|
+
}
|
|
56
|
+
export declare const readPoolState: (pool: Partial<TarnPoolLike> | null | undefined) => PoolState | undefined;
|
|
57
|
+
export declare const collectPoolTimeoutDetails: (client: KnexClientLike, input: CollectInput) => PoolTimeoutDetails;
|
|
58
|
+
//# sourceMappingURL=details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"details.d.ts","sourceRoot":"","sources":["../../src/pool-diagnostics/details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,eAAO,MAAM,iBAAiB,4BAA4B,CAAC;AAE3D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,iBAAiB,CAAC;IAC/B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,uGAAuG;IACvG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+BAA+B;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,gDAAgD;IAChD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,gHAAgH;IAChH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,IAAI,MAAM,CAAC;IAClB,OAAO,IAAI,MAAM,CAAC;IAClB,kBAAkB,IAAI,MAAM,CAAC;IAC7B,iBAAiB,IAAI,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE;QAAE,wBAAwB,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE;YAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;IAC3F,yFAAyF;IACzF,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAWD,eAAO,MAAM,aAAa,GACxB,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,KAC7C,SAAS,GAAG,SAcd,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,QAAQ,cAAc,EACtB,OAAO,YAAY,KAClB,kBAkBF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const POOL_TIMEOUT_CODE = 'DB_POOL_ACQUIRE_TIMEOUT';
|
|
4
|
+
const asNumber = (value)=>typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
5
|
+
const hasCounters = (pool)=>typeof pool.numUsed === 'function' && typeof pool.numFree === 'function' && typeof pool.numPendingAcquires === 'function' && typeof pool.numPendingCreates === 'function';
|
|
6
|
+
const readPoolState = (pool)=>{
|
|
7
|
+
// knex also accepts a pool that only has acquire, release and destroy
|
|
8
|
+
if (!pool || !hasCounters(pool)) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
used: pool.numUsed(),
|
|
13
|
+
free: pool.numFree(),
|
|
14
|
+
pendingAcquires: pool.numPendingAcquires(),
|
|
15
|
+
pendingCreates: pool.numPendingCreates(),
|
|
16
|
+
min: asNumber(pool.min),
|
|
17
|
+
max: asNumber(pool.max)
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const collectPoolTimeoutDetails = (client, input)=>{
|
|
21
|
+
const config = client.config ?? {};
|
|
22
|
+
return {
|
|
23
|
+
code: POOL_TIMEOUT_CODE,
|
|
24
|
+
waitedMs: input.waitedMs,
|
|
25
|
+
// knex writes the effective (smaller) timeout into the tarn pool options
|
|
26
|
+
acquireTimeoutMs: asNumber(client.pool?.acquireTimeoutMillis),
|
|
27
|
+
acquireConnectionTimeout: asNumber(config.acquireConnectionTimeout),
|
|
28
|
+
poolAcquireTimeoutMillis: asNumber(config.pool?.acquireTimeoutMillis),
|
|
29
|
+
pool: readPoolState(client.pool),
|
|
30
|
+
// knex 3.3 keeps tarn's error as `cause`; its message is all tarn keeps of a failed attempt
|
|
31
|
+
poolReason: input.cause instanceof Error ? input.cause.message : undefined,
|
|
32
|
+
eventLoopDelay: input.eventLoopDelay,
|
|
33
|
+
phase: input.phase,
|
|
34
|
+
hostname: input.hostname,
|
|
35
|
+
pid: input.pid
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.POOL_TIMEOUT_CODE = POOL_TIMEOUT_CODE;
|
|
40
|
+
exports.collectPoolTimeoutDetails = collectPoolTimeoutDetails;
|
|
41
|
+
exports.readPoolState = readPoolState;
|
|
42
|
+
//# sourceMappingURL=details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"details.js","sources":["../../src/pool-diagnostics/details.ts"],"sourcesContent":["import type { EventLoopDelay } from './event-loop';\n\nexport const POOL_TIMEOUT_CODE = 'DB_POOL_ACQUIRE_TIMEOUT';\n\nexport interface PoolState {\n used: number;\n free: number;\n pendingAcquires: number;\n pendingCreates: number;\n min?: number;\n max?: number;\n}\n\nexport interface PoolTimeoutDetails {\n code: typeof POOL_TIMEOUT_CODE;\n /** How long this caller waited before knex gave up. */\n waitedMs: number;\n /** The timeout knex applied: the smaller of acquireConnectionTimeout and pool.acquireTimeoutMillis. */\n acquireTimeoutMs?: number;\n /** As configured, when set. */\n acquireConnectionTimeout?: number;\n poolAcquireTimeoutMillis?: number;\n /** Pool counts at the moment of the timeout. */\n pool?: PoolState;\n /** tarn's message: the error of a failed connection attempt, or \"operation timed out for an unknown reason\". */\n poolReason?: string;\n eventLoopDelay?: EventLoopDelay;\n phase?: string;\n hostname: string;\n pid: number;\n}\n\nexport interface TarnPoolLike {\n min?: number;\n max?: number;\n acquireTimeoutMillis?: number;\n numUsed(): number;\n numFree(): number;\n numPendingAcquires(): number;\n numPendingCreates(): number;\n}\n\nexport interface KnexClientLike {\n config?: { acquireConnectionTimeout?: unknown; pool?: { acquireTimeoutMillis?: unknown } };\n /** A tarn pool, or knex's wrapper around a native driver pool, which has no counters. */\n pool?: Partial<TarnPoolLike> | null;\n}\n\nexport interface CollectInput {\n waitedMs: number;\n cause: unknown;\n eventLoopDelay?: EventLoopDelay;\n phase?: string;\n hostname: string;\n pid: number;\n}\n\nconst asNumber = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n\nconst hasCounters = (pool: Partial<TarnPoolLike>): pool is TarnPoolLike =>\n typeof pool.numUsed === 'function' &&\n typeof pool.numFree === 'function' &&\n typeof pool.numPendingAcquires === 'function' &&\n typeof pool.numPendingCreates === 'function';\n\nexport const readPoolState = (\n pool: Partial<TarnPoolLike> | null | undefined\n): PoolState | undefined => {\n // knex also accepts a pool that only has acquire, release and destroy\n if (!pool || !hasCounters(pool)) {\n return undefined;\n }\n\n return {\n used: pool.numUsed(),\n free: pool.numFree(),\n pendingAcquires: pool.numPendingAcquires(),\n pendingCreates: pool.numPendingCreates(),\n min: asNumber(pool.min),\n max: asNumber(pool.max),\n };\n};\n\nexport const collectPoolTimeoutDetails = (\n client: KnexClientLike,\n input: CollectInput\n): PoolTimeoutDetails => {\n const config = client.config ?? {};\n\n return {\n code: POOL_TIMEOUT_CODE,\n waitedMs: input.waitedMs,\n // knex writes the effective (smaller) timeout into the tarn pool options\n acquireTimeoutMs: asNumber(client.pool?.acquireTimeoutMillis),\n acquireConnectionTimeout: asNumber(config.acquireConnectionTimeout),\n poolAcquireTimeoutMillis: asNumber(config.pool?.acquireTimeoutMillis),\n pool: readPoolState(client.pool),\n // knex 3.3 keeps tarn's error as `cause`; its message is all tarn keeps of a failed attempt\n poolReason: input.cause instanceof Error ? input.cause.message : undefined,\n eventLoopDelay: input.eventLoopDelay,\n phase: input.phase,\n hostname: input.hostname,\n pid: input.pid,\n };\n};\n"],"names":["POOL_TIMEOUT_CODE","asNumber","value","Number","isFinite","undefined","hasCounters","pool","numUsed","numFree","numPendingAcquires","numPendingCreates","readPoolState","used","free","pendingAcquires","pendingCreates","min","max","collectPoolTimeoutDetails","client","input","config","code","waitedMs","acquireTimeoutMs","acquireTimeoutMillis","acquireConnectionTimeout","poolAcquireTimeoutMillis","poolReason","cause","Error","message","eventLoopDelay","phase","hostname","pid"],"mappings":";;AAEO,MAAMA,oBAAoB;AAuDjC,MAAMC,QAAAA,GAAW,CAACC,KAAAA,GAChB,OAAOA,KAAAA,KAAU,YAAYC,MAAAA,CAAOC,QAAQ,CAACF,KAAAA,CAAAA,GAASA,KAAAA,GAAQG,SAAAA;AAEhE,MAAMC,WAAAA,GAAc,CAACC,IAAAA,GACnB,OAAOA,KAAKC,OAAO,KAAK,cACxB,OAAOD,IAAAA,CAAKE,OAAO,KAAK,UAAA,IACxB,OAAOF,IAAAA,CAAKG,kBAAkB,KAAK,UAAA,IACnC,OAAOH,IAAAA,CAAKI,iBAAiB,KAAK,UAAA;AAE7B,MAAMC,gBAAgB,CAC3BL,IAAAA,GAAAA;;AAGA,IAAA,IAAI,CAACA,IAAAA,IAAQ,CAACD,WAAAA,C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
+
const POOL_TIMEOUT_CODE = 'DB_POOL_ACQUIRE_TIMEOUT';
|
|
2
|
+
const asNumber = (value)=>typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
3
|
+
const hasCounters = (pool)=>typeof pool.numUsed === 'function' && typeof pool.numFree === 'function' && typeof pool.numPendingAcquires === 'function' && typeof pool.numPendingCreates === 'function';
|
|
4
|
+
const readPoolState = (pool)=>{
|
|
5
|
+
// knex also accepts a pool that only has acquire, release and destroy
|
|
6
|
+
if (!pool || !hasCounters(pool)) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
used: pool.numUsed(),
|
|
11
|
+
free: pool.numFree(),
|
|
12
|
+
pendingAcquires: pool.numPendingAcquires(),
|
|
13
|
+
pendingCreates: pool.numPendingCreates(),
|
|
14
|
+
min: asNumber(pool.min),
|
|
15
|
+
max: asNumber(pool.max)
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const collectPoolTimeoutDetails = (client, input)=>{
|
|
19
|
+
const config = client.config ?? {};
|
|
20
|
+
return {
|
|
21
|
+
code: POOL_TIMEOUT_CODE,
|
|
22
|
+
waitedMs: input.waitedMs,
|
|
23
|
+
// knex writes the effective (smaller) timeout into the tarn pool options
|
|
24
|
+
acquireTimeoutMs: asNumber(client.pool?.acquireTimeoutMillis),
|
|
25
|
+
acquireConnectionTimeout: asNumber(config.acquireConnectionTimeout),
|
|
26
|
+
poolAcquireTimeoutMillis: asNumber(config.pool?.acquireTimeoutMillis),
|
|
27
|
+
pool: readPoolState(client.pool),
|
|
28
|
+
// knex 3.3 keeps tarn's error as `cause`; its message is all tarn keeps of a failed attempt
|
|
29
|
+
poolReason: input.cause instanceof Error ? input.cause.message : undefined,
|
|
30
|
+
eventLoopDelay: input.eventLoopDelay,
|
|
31
|
+
phase: input.phase,
|
|
32
|
+
hostname: input.hostname,
|
|
33
|
+
pid: input.pid
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { POOL_TIMEOUT_CODE, collectPoolTimeoutDetails, readPoolState };
|
|
38
|
+
//# sourceMappingURL=details.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"details.mjs","sources":["../../src/pool-diagnostics/details.ts"],"sourcesContent":["import type { EventLoopDelay } from './event-loop';\n\nexport const POOL_TIMEOUT_CODE = 'DB_POOL_ACQUIRE_TIMEOUT';\n\nexport interface PoolState {\n used: number;\n free: number;\n pendingAcquires: number;\n pendingCreates: number;\n min?: number;\n max?: number;\n}\n\nexport interface PoolTimeoutDetails {\n code: typeof POOL_TIMEOUT_CODE;\n /** How long this caller waited before knex gave up. */\n waitedMs: number;\n /** The timeout knex applied: the smaller of acquireConnectionTimeout and pool.acquireTimeoutMillis. */\n acquireTimeoutMs?: number;\n /** As configured, when set. */\n acquireConnectionTimeout?: number;\n poolAcquireTimeoutMillis?: number;\n /** Pool counts at the moment of the timeout. */\n pool?: PoolState;\n /** tarn's message: the error of a failed connection attempt, or \"operation timed out for an unknown reason\". */\n poolReason?: string;\n eventLoopDelay?: EventLoopDelay;\n phase?: string;\n hostname: string;\n pid: number;\n}\n\nexport interface TarnPoolLike {\n min?: number;\n max?: number;\n acquireTimeoutMillis?: number;\n numUsed(): number;\n numFree(): number;\n numPendingAcquires(): number;\n numPendingCreates(): number;\n}\n\nexport interface KnexClientLike {\n config?: { acquireConnectionTimeout?: unknown; pool?: { acquireTimeoutMillis?: unknown } };\n /** A tarn pool, or knex's wrapper around a native driver pool, which has no counters. */\n pool?: Partial<TarnPoolLike> | null;\n}\n\nexport interface CollectInput {\n waitedMs: number;\n cause: unknown;\n eventLoopDelay?: EventLoopDelay;\n phase?: string;\n hostname: string;\n pid: number;\n}\n\nconst asNumber = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n\nconst hasCounters = (pool: Partial<TarnPoolLike>): pool is TarnPoolLike =>\n typeof pool.numUsed === 'function' &&\n typeof pool.numFree === 'function' &&\n typeof pool.numPendingAcquires === 'function' &&\n typeof pool.numPendingCreates === 'function';\n\nexport const readPoolState = (\n pool: Partial<TarnPoolLike> | null | undefined\n): PoolState | undefined => {\n // knex also accepts a pool that only has acquire, release and destroy\n if (!pool || !hasCounters(pool)) {\n return undefined;\n }\n\n return {\n used: pool.numUsed(),\n free: pool.numFree(),\n pendingAcquires: pool.numPendingAcquires(),\n pendingCreates: pool.numPendingCreates(),\n min: asNumber(pool.min),\n max: asNumber(pool.max),\n };\n};\n\nexport const collectPoolTimeoutDetails = (\n client: KnexClientLike,\n input: CollectInput\n): PoolTimeoutDetails => {\n const config = client.config ?? {};\n\n return {\n code: POOL_TIMEOUT_CODE,\n waitedMs: input.waitedMs,\n // knex writes the effective (smaller) timeout into the tarn pool options\n acquireTimeoutMs: asNumber(client.pool?.acquireTimeoutMillis),\n acquireConnectionTimeout: asNumber(config.acquireConnectionTimeout),\n poolAcquireTimeoutMillis: asNumber(config.pool?.acquireTimeoutMillis),\n pool: readPoolState(client.pool),\n // knex 3.3 keeps tarn's error as `cause`; its message is all tarn keeps of a failed attempt\n poolReason: input.cause instanceof Error ? input.cause.message : undefined,\n eventLoopDelay: input.eventLoopDelay,\n phase: input.phase,\n hostname: input.hostname,\n pid: input.pid,\n };\n};\n"],"names":["POOL_TIMEOUT_CODE","asNumber","value","Number","isFinite","undefined","hasCounters","pool","numUsed","numFree","numPendingAcquires","numPendingCreates","readPoolState","used","free","pendingAcquires","pendingCreates","min","max","collectPoolTimeoutDetails","client","input","config","code","waitedMs","acquireTimeoutMs","acquireTimeoutMillis","acquireConnectionTimeout","poolAcquireTimeoutMillis","poolReason","cause","Error","message","eventLoopDelay","phase","hostname","pid"],"mappings":"AAEO,MAAMA,oBAAoB;AAuDjC,MAAMC,QAAAA,GAAW,CAACC,KAAAA,GAChB,OAAOA,KAAAA,KAAU,YAAYC,MAAAA,CAAOC,QAAQ,CAACF,KAAAA,CAAAA,GAASA,KAAAA,GAAQG,SAAAA;AAEhE,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AAA,CAAMS,KAAK,YAAYC,KAAAA,GAAQV,MAAMS,KAAK,CAACE,OAAO,GAAG3B,SAAAA;AACjE4B,QAAAA,cAAAA,EAAgBZ,MAAMY,cAAc;AACpCC,QAAAA,KAAAA,EAAOb,MAAMa,KAAK;AAClBC,QAAAA,QAAAA,EAAUd,MAAMc,QAAQ;AACxBC,QAAAA,GAAAA,EAAKf,MAAMe;AACb,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Sampling interval of the event loop delay histogram. */
|
|
2
|
+
export declare const EVENT_LOOP_RESOLUTION_MS = 20;
|
|
3
|
+
/** Every rotation drops the older half, so a report covers the last 30 to 60 s. */
|
|
4
|
+
export declare const EVENT_LOOP_ROTATION_MS = 30000;
|
|
5
|
+
export interface EventLoopDelay {
|
|
6
|
+
/** Longest delay seen in the window, in ms, sampling interval removed. */
|
|
7
|
+
maxMs: number;
|
|
8
|
+
p99Ms: number;
|
|
9
|
+
/** Length of the window the values cover. */
|
|
10
|
+
windowMs: number;
|
|
11
|
+
}
|
|
12
|
+
export interface EventLoopMonitor {
|
|
13
|
+
read(): EventLoopDelay | undefined;
|
|
14
|
+
stop(): void;
|
|
15
|
+
}
|
|
16
|
+
export interface EventLoopMonitorOptions {
|
|
17
|
+
/** Injectable clock for tests. */
|
|
18
|
+
now?: () => number;
|
|
19
|
+
/** How often the older histogram is cleared and reused. */
|
|
20
|
+
rotateEveryMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/** The histogram records the time between samples, so an idle loop reads one sampling interval. */
|
|
23
|
+
export declare const toDelayMs: (nanoseconds: number) => number;
|
|
24
|
+
/**
|
|
25
|
+
* A starved process fires timers late, so an acquire can time out even though the database
|
|
26
|
+
* answered. Two histograms take turns so a report covers the last one to two rotation periods,
|
|
27
|
+
* not everything since the process started. Neither the histograms nor the rotation timer keep
|
|
28
|
+
* the process alive.
|
|
29
|
+
*/
|
|
30
|
+
export declare const createEventLoopMonitor: ({ now, rotateEveryMs, }?: EventLoopMonitorOptions) => EventLoopMonitor;
|
|
31
|
+
//# sourceMappingURL=event-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-loop.d.ts","sourceRoot":"","sources":["../../src/pool-diagnostics/event-loop.ts"],"names":[],"mappings":"AAEA,2DAA2D;AAC3D,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,mFAAmF;AACnF,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,cAAc,GAAG,SAAS,CAAC;IACnC,IAAI,IAAI,IAAI,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,mGAAmG;AACnG,eAAO,MAAM,SAAS,GAAI,aAAa,MAAM,KAAG,MACuB,CAAC;AAQxE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,0BAGpC,uBAA4B,KAAG,gBAmCjC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_perf_hooks = require('node:perf_hooks');
|
|
4
|
+
|
|
5
|
+
/** Sampling interval of the event loop delay histogram. */ const EVENT_LOOP_RESOLUTION_MS = 20;
|
|
6
|
+
/** Every rotation drops the older half, so a report covers the last 30 to 60 s. */ const EVENT_LOOP_ROTATION_MS = 30000;
|
|
7
|
+
/** The histogram records the time between samples, so an idle loop reads one sampling interval. */ const toDelayMs = (nanoseconds)=>Math.max(0, Math.round(nanoseconds / 1e6 - EVENT_LOOP_RESOLUTION_MS));
|
|
8
|
+
const startHistogram = ()=>{
|
|
9
|
+
const histogram = node_perf_hooks.monitorEventLoopDelay({
|
|
10
|
+
resolution: EVENT_LOOP_RESOLUTION_MS
|
|
11
|
+
});
|
|
12
|
+
histogram.enable();
|
|
13
|
+
return histogram;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A starved process fires timers late, so an acquire can time out even though the database
|
|
17
|
+
* answered. Two histograms take turns so a report covers the last one to two rotation periods,
|
|
18
|
+
* not everything since the process started. Neither the histograms nor the rotation timer keep
|
|
19
|
+
* the process alive.
|
|
20
|
+
*/ const createEventLoopMonitor = ({ now = ()=>Date.now(), rotateEveryMs = EVENT_LOOP_ROTATION_MS } = {})=>{
|
|
21
|
+
let older = startHistogram();
|
|
22
|
+
let newer = startHistogram();
|
|
23
|
+
let olderStartedAt = now();
|
|
24
|
+
let newerStartedAt = olderStartedAt;
|
|
25
|
+
const rotate = ()=>{
|
|
26
|
+
older.reset();
|
|
27
|
+
[older, newer] = [
|
|
28
|
+
newer,
|
|
29
|
+
older
|
|
30
|
+
];
|
|
31
|
+
olderStartedAt = newerStartedAt;
|
|
32
|
+
newerStartedAt = now();
|
|
33
|
+
};
|
|
34
|
+
const timer = setInterval(rotate, rotateEveryMs);
|
|
35
|
+
timer.unref();
|
|
36
|
+
return {
|
|
37
|
+
read () {
|
|
38
|
+
if (older.count === 0) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
maxMs: toDelayMs(older.max),
|
|
43
|
+
p99Ms: toDelayMs(older.percentile(99)),
|
|
44
|
+
windowMs: now() - olderStartedAt
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
stop () {
|
|
48
|
+
clearInterval(timer);
|
|
49
|
+
older.disable();
|
|
50
|
+
newer.disable();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.EVENT_LOOP_RESOLUTION_MS = EVENT_LOOP_RESOLUTION_MS;
|
|
56
|
+
exports.EVENT_LOOP_ROTATION_MS = EVENT_LOOP_ROTATION_MS;
|
|
57
|
+
exports.createEventLoopMonitor = createEventLoopMonitor;
|
|
58
|
+
exports.toDelayMs = toDelayMs;
|
|
59
|
+
//# sourceMappingURL=event-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-loop.js","sources":["../../src/pool-diagnostics/event-loop.ts"],"sourcesContent":["import { monitorEventLoopDelay, type IntervalHistogram } from 'node:perf_hooks';\n\n/** Sampling interval of the event loop delay histogram. */\nexport const EVENT_LOOP_RESOLUTION_MS = 20;\n\n/** Every rotation drops the older half, so a report covers the last 30 to 60 s. */\nexport const EVENT_LOOP_ROTATION_MS = 30_000;\n\nexport interface EventLoopDelay {\n /** Longest delay seen in the window, in ms, sampling interval removed. */\n maxMs: number;\n p99Ms: number;\n /** Length of the window the values cover. */\n windowMs: number;\n}\n\nexport interface EventLoopMonitor {\n read(): EventLoopDelay | undefined;\n stop(): void;\n}\n\nexport interface EventLoopMonitorOptions {\n /** Injectable clock for tests. */\n now?: () => number;\n /** How often the older histogram is cleared and reused. */\n rotateEveryMs?: number;\n}\n\n/** The histogram records the time between samples, so an idle loop reads one sampling interval. */\nexport const toDelayMs = (nanoseconds: number): number =>\n Math.max(0, Math.round(nanoseconds / 1e6 - EVENT_LOOP_RESOLUTION_MS));\n\nconst startHistogram = (): IntervalHistogram => {\n const histogram = monitorEventLoopDelay({ resolution: EVENT_LOOP_RESOLUTION_MS });\n histogram.enable();\n return histogram;\n};\n\n/**\n * A starved process fires timers late, so an acquire can time out even though the database\n * answered. Two histograms take turns so a report covers the last one to two rotation periods,\n * not everything since the process started. Neither the histograms nor the rotation timer keep\n * the process alive.\n */\nexport const createEventLoopMonitor = ({\n now = () => Date.now(),\n rotateEveryMs = EVENT_LOOP_ROTATION_MS,\n}: EventLoopMonitorOptions = {}): EventLoopMonitor => {\n let older = startHistogram();\n let newer = startHistogram();\n let olderStartedAt = now();\n let newerStartedAt = olderStartedAt;\n\n const rotate = () => {\n older.reset();\n [older, newer] = [newer, older];\n olderStartedAt = newerStartedAt;\n newerStartedAt = now();\n };\n\n const timer = setInterval(rotate, rotateEveryMs);\n timer.unref();\n\n return {\n read() {\n if (older.count === 0) {\n return undefined;\n }\n\n return {\n maxMs: toDelayMs(older.max),\n p99Ms: toDelayMs(older.percentile(99)),\n windowMs: now() - olderStartedAt,\n };\n },\n\n stop() {\n clearInterval(timer);\n older.disable();\n newer.disable();\n },\n };\n};\n"],"names":["EVENT_LOOP_RESOLUTION_MS","EVENT_LOOP_ROTATION_MS","toDelayMs","nanoseconds","Math","max","round","startHistogram","histogram","monitorEventLoopDelay","resolution","enable","createEventLoopMonitor","now","Date","rotateEveryMs","older","newer","olderStartedAt","newerStartedAt","rotate","reset","timer","setInterval","unref","read","count","undefined","maxMs","p99Ms","percentile","windowMs","stop","clearInterval","disable"],"mappings":";;;;AAEA,4DACO,MAAMA,wBAAAA,GAA2B;AAExC,oFACO,MAAMC,sBAAAA,GAAyB;AAsBtC,oGACO,MAAMC,SAAAA,GAAY,CAACC,WAAAA,GACxBC,IAAAA,CAAKC,GAAG,CAAC,GAAGD,IAAAA,CAAKE,KAAK,CAACH,WAAAA,GAAc,MAAMH,wBAAAA,CAAAA;AAE7C,MAAMO,cAAAA,GAAiB,IAAA;AACrB,IAAA,MAAMC,YAAYC,qCAAAA,CAAsB;QAAEC,UAAAA,EAAYV;AAAyB,KAAA,CAAA;AAC/EQ,IAAAA,SAAAA,CAAUG,MAAM,EAAA;IAChB,OAAOH,SAAAA;AACT,CAAA;AAEA;;;;;AAKC,IACM,MAAMI,sBAAAA,GAAyB,CAAC,EACrCC,MAAM,IAAMC,IAAAA,CAAKD,GAAG,EAAE,EACtBE,aAAAA,GAAgBd,sBAAsB,EACd,GAAG,EAAE,GAAA;AAC7B,IAAA,IAAIe,KAAAA,GAAQT,cAAAA,EAAAA;AACZ,IAAA,IAAIU,KAAAA,GAAQV,cAAAA,EAAAA;AACZ,IAAA,IAAIW,cAAAA,GAAiBL,GAAAA,EAAAA;AACrB,IAAA,IAAIM,cAAAA,GAAiBD,cAAAA;AAErB,IAAA,MAAME,MAAAA,GAAS,IAAA;AACbJ,QAAAA,KAAAA,CAAMK,KAAK,EAAA;QACX,CAACL,KAAAA,EAAOC,MAAM,GAAG;AAACA,YAAAA,KAAAA;AAAOD,YAAAA;AAAM,SAAA;QAC/BE,cAAAA,GAAiBC,cAAAA;QACjBA,cAAAA,GAAiBN,GAAAA,EAAAA;AACnB,IAAA,CAAA;IAEA,MAAMS,KAAAA,GAAQC,YAAYH,MAAAA,EAAQL,aAAAA,CAAAA;AAClCO,IAAAA,KAAAA,CAAME,KAAK,EAAA;IAEX,OAAO;AACLC,QAAAA,IAAAA,CAAAA,GAAAA;YACE,IAAIT,KAAAA,CAAMU,KAAK,KAAK,CAAA,EAAG;gBACrB,OAAOC,SAAAA;AACT,YAAA;YAEA,OAAO;gBACLC,KAAAA,EAAO1B,SAAAA,CAAUc,MAAMX,GAAG,CAAA;gBAC1BwB,KAAAA,EAAO3B,SAAAA,CAAUc,KAAAA,CAAMc,UAAU,CAAC,EAAA,CAAA,CAAA;AAClCC,gBAAAA,QAAAA,EAAUlB,GAAAA,EAAAA,GAAQK;AACpB,aAAA;AACF,QAAA,CAAA;AAEAc,QAAAA,IAAAA,CAAAA,GAAAA;YACEC,aAAAA,CAAcX,KAAAA,CAAAA;AACdN,YAAAA,KAAAA,CAAMkB,OAAO,EAAA;AACbjB,YAAAA,KAAAA,CAAMiB,OAAO,EAAA;AACf,QAAA;AACF,KAAA;AACF;;;;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { monitorEventLoopDelay } from 'node:perf_hooks';
|
|
2
|
+
|
|
3
|
+
/** Sampling interval of the event loop delay histogram. */ const EVENT_LOOP_RESOLUTION_MS = 20;
|
|
4
|
+
/** Every rotation drops the older half, so a report covers the last 30 to 60 s. */ const EVENT_LOOP_ROTATION_MS = 30000;
|
|
5
|
+
/** The histogram records the time between samples, so an idle loop reads one sampling interval. */ const toDelayMs = (nanoseconds)=>Math.max(0, Math.round(nanoseconds / 1e6 - EVENT_LOOP_RESOLUTION_MS));
|
|
6
|
+
const startHistogram = ()=>{
|
|
7
|
+
const histogram = monitorEventLoopDelay({
|
|
8
|
+
resolution: EVENT_LOOP_RESOLUTION_MS
|
|
9
|
+
});
|
|
10
|
+
histogram.enable();
|
|
11
|
+
return histogram;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A starved process fires timers late, so an acquire can time out even though the database
|
|
15
|
+
* answered. Two histograms take turns so a report covers the last one to two rotation periods,
|
|
16
|
+
* not everything since the process started. Neither the histograms nor the rotation timer keep
|
|
17
|
+
* the process alive.
|
|
18
|
+
*/ const createEventLoopMonitor = ({ now = ()=>Date.now(), rotateEveryMs = EVENT_LOOP_ROTATION_MS } = {})=>{
|
|
19
|
+
let older = startHistogram();
|
|
20
|
+
let newer = startHistogram();
|
|
21
|
+
let olderStartedAt = now();
|
|
22
|
+
let newerStartedAt = olderStartedAt;
|
|
23
|
+
const rotate = ()=>{
|
|
24
|
+
older.reset();
|
|
25
|
+
[older, newer] = [
|
|
26
|
+
newer,
|
|
27
|
+
older
|
|
28
|
+
];
|
|
29
|
+
olderStartedAt = newerStartedAt;
|
|
30
|
+
newerStartedAt = now();
|
|
31
|
+
};
|
|
32
|
+
const timer = setInterval(rotate, rotateEveryMs);
|
|
33
|
+
timer.unref();
|
|
34
|
+
return {
|
|
35
|
+
read () {
|
|
36
|
+
if (older.count === 0) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
maxMs: toDelayMs(older.max),
|
|
41
|
+
p99Ms: toDelayMs(older.percentile(99)),
|
|
42
|
+
windowMs: now() - olderStartedAt
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
stop () {
|
|
46
|
+
clearInterval(timer);
|
|
47
|
+
older.disable();
|
|
48
|
+
newer.disable();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { EVENT_LOOP_RESOLUTION_MS, EVENT_LOOP_ROTATION_MS, createEventLoopMonitor, toDelayMs };
|
|
54
|
+
//# sourceMappingURL=event-loop.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-loop.mjs","sources":["../../src/pool-diagnostics/event-loop.ts"],"sourcesContent":["import { monitorEventLoopDelay, type IntervalHistogram } from 'node:perf_hooks';\n\n/** Sampling interval of the event loop delay histogram. */\nexport const EVENT_LOOP_RESOLUTION_MS = 20;\n\n/** Every rotation drops the older half, so a report covers the last 30 to 60 s. */\nexport const EVENT_LOOP_ROTATION_MS = 30_000;\n\nexport interface EventLoopDelay {\n /** Longest delay seen in the window, in ms, sampling interval removed. */\n maxMs: number;\n p99Ms: number;\n /** Length of the window the values cover. */\n windowMs: number;\n}\n\nexport interface EventLoopMonitor {\n read(): EventLoopDelay | undefined;\n stop(): void;\n}\n\nexport interface EventLoopMonitorOptions {\n /** Injectable clock for tests. */\n now?: () => number;\n /** How often the older histogram is cleared and reused. */\n rotateEveryMs?: number;\n}\n\n/** The histogram records the time between samples, so an idle loop reads one sampling interval. */\nexport const toDelayMs = (nanoseconds: number): number =>\n Math.max(0, Math.round(nanoseconds / 1e6 - EVENT_LOOP_RESOLUTION_MS));\n\nconst startHistogram = (): IntervalHistogram => {\n const histogram = monitorEventLoopDelay({ resolution: EVENT_LOOP_RESOLUTION_MS });\n histogram.enable();\n return histogram;\n};\n\n/**\n * A starved process fires timers late, so an acquire can time out even though the database\n * answered. Two histograms take turns so a report covers the last one to two rotation periods,\n * not everything since the process started. Neither the histograms nor the rotation timer keep\n * the process alive.\n */\nexport const createEventLoopMonitor = ({\n now = () => Date.now(),\n rotateEveryMs = EVENT_LOOP_ROTATION_MS,\n}: EventLoopMonitorOptions = {}): EventLoopMonitor => {\n let older = startHistogram();\n let newer = startHistogram();\n let olderStartedAt = now();\n let newerStartedAt = olderStartedAt;\n\n const rotate = () => {\n older.reset();\n [older, newer] = [newer, older];\n olderStartedAt = newerStartedAt;\n newerStartedAt = now();\n };\n\n const timer = setInterval(rotate, rotateEveryMs);\n timer.unref();\n\n return {\n read() {\n if (older.count === 0) {\n return undefined;\n }\n\n return {\n maxMs: toDelayMs(older.max),\n p99Ms: toDelayMs(older.percentile(99)),\n windowMs: now() - olderStartedAt,\n };\n },\n\n stop() {\n clearInterval(timer);\n older.disable();\n newer.disable();\n },\n };\n};\n"],"names":["EVENT_LOOP_RESOLUTION_MS","EVENT_LOOP_ROTATION_MS","toDelayMs","nanoseconds","Math","max","round","startHistogram","histogram","monitorEventLoopDelay","resolution","enable","createEventLoopMonitor","now","Date","rotateEveryMs","older","newer","olderStartedAt","newerStartedAt","rotate","reset","timer","setInterval","unref","read","count","undefined","maxMs","p99Ms","percentile","windowMs","stop","clearInterval","disable"],"mappings":";;AAEA,4DACO,MAAMA,wBAAAA,GAA2B;AAExC,oFACO,MAAMC,sBAAAA,GAAyB;AAsBtC,oGACO,MAAMC,SAAAA,GAAY,CAACC,WAAAA,GACxBC,IAAAA,CAAKC,GAAG,CAAC,GAAGD,IAAAA,CAAKE,KAAK,CAACH,WAAAA,GAAc,MAAMH,wBAAAA,CAAAA;AAE7C,MAAMO,cAAAA,GAAiB,IAAA;AACrB,IAAA,MAAMC,YAAYC,qBAAAA,CAAsB;QAAEC,UAAAA,EAAYV;AAAyB,KAAA,CAAA;AAC/EQ,IAAAA,SAAAA,CAAUG,MAAM,EAAA;IAChB,OAAOH,SAAAA;AACT,CAAA;AAEA;;;;;AAKC,IACM,MAAMI,sBAAAA,GAAyB,CAAC,EACrCC,MAAM,IAAMC,IAAAA,CAAKD,GAAG,EAAE,EACtBE,aAAAA,GAAgBd,sBAAsB,EACd,GAAG,EAAE,GAAA;AAC7B,IAAA,IAAIe,KAAAA,GAAQT,cAAAA,EAAAA;AACZ,IAAA,IAAIU,KAAAA,GAAQV,cAAAA,EAAAA;AACZ,IAAA,IAAIW,cAAAA,GAAiBL,GAAAA,EAAAA;AACrB,IAAA,IAAIM,cAAAA,GAAiBD,cAAAA;AAErB,IAAA,MAAME,MAAAA,GAAS,IAAA;AACbJ,QAAAA,KAAAA,CAAMK,KAAK,EAAA;QACX,CAACL,KAAAA,EAAOC,MAAM,GAAG;AAACA,YAAAA,KAAAA;AAAOD,YAAAA;AAAM,SAAA;QAC/BE,cAAAA,GAAiBC,cAAAA;QACjBA,cAAAA,GAAiBN,GAAAA,EAAAA;AACnB,IAAA,CAAA;IAEA,MAAMS,KAAAA,GAAQC,YAAYH,MAAAA,EAAQL,aAAAA,CAAAA;AAClCO,IAAAA,KAAAA,CAAME,KAAK,EAAA;IAEX,OAAO;AACLC,QAAAA,IAAAA,CAAAA,GAAAA;YACE,IAAIT,KAAAA,CAAMU,KAAK,KAAK,CAAA,EAAG;gBACrB,OAAOC,SAAAA;AACT,YAAA;YAEA,OAAO;gBACLC,KAAAA,EAAO1B,SAAAA,CAAUc,MAAMX,GAAG,CAAA;gBAC1BwB,KAAAA,EAAO3B,SAAAA,CAAUc,KAAAA,CAAMc,UAAU,CAAC,EAAA,CAAA,CAAA;AAClCC,gBAAAA,QAAAA,EAAUlB,GAAAA,EAAAA,GAAQK;AACpB,aAAA;AACF,QAAA,CAAA;AAEAc,QAAAA,IAAAA,CAAAA,GAAAA;YACEC,aAAAA,CAAcX,KAAAA,CAAAA;AACdN,YAAAA,KAAAA,CAAMkB,OAAO,EAAA;AACbjB,YAAAA,KAAAA,CAAMiB,OAAO,EAAA;AACf,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PoolTimeoutDetails } from './details';
|
|
2
|
+
/** Where the error and the warning point readers. The only place the URL lives. */
|
|
3
|
+
export declare const POOL_TIMEOUT_DOCS_URL = "https://docs.strapi.io/cms/configurations/database#connection-pool-timeouts";
|
|
4
|
+
export declare const appendDocsLink: (message: string) => string;
|
|
5
|
+
/** Facts only, one bullet per fact, in the house style of multi-line warnings. */
|
|
6
|
+
export declare const formatPoolTimeoutWarning: (details: PoolTimeoutDetails, { suppressed }: {
|
|
7
|
+
suppressed: number;
|
|
8
|
+
}) => string;
|
|
9
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/pool-diagnostics/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,gFAC6C,CAAC;AAEhF,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,MAC+C,CAAC;AAQjG,kFAAkF;AAClF,eAAO,MAAM,wBAAwB,GACnC,SAAS,kBAAkB,EAC3B,gBAAgB;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,KACrC,MAsDF,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** Where the error and the warning point readers. The only place the URL lives. */ const POOL_TIMEOUT_DOCS_URL = 'https://docs.strapi.io/cms/configurations/database#connection-pool-timeouts';
|
|
4
|
+
const appendDocsLink = (message)=>message.includes(POOL_TIMEOUT_DOCS_URL) ? message : `${message} See ${POOL_TIMEOUT_DOCS_URL}.`;
|
|
5
|
+
const valueOrUnknown = (value)=>value === undefined ? 'unknown' : String(value);
|
|
6
|
+
// driver errors and labels can span lines; keep each to one bullet
|
|
7
|
+
const singleLine = (text)=>text?.replace(/\s+/g, ' ').trim();
|
|
8
|
+
/** Facts only, one bullet per fact, in the house style of multi-line warnings. */ const formatPoolTimeoutWarning = (details, { suppressed })=>{
|
|
9
|
+
const lines = [
|
|
10
|
+
`[database] connection pool timeout: waited ${Math.round(details.waitedMs)} ms for a connection (acquire timeout ${valueOrUnknown(details.acquireTimeoutMs)} ms)`
|
|
11
|
+
];
|
|
12
|
+
if (details.pool) {
|
|
13
|
+
const { used, free, max, min, pendingAcquires, pendingCreates } = details.pool;
|
|
14
|
+
lines.push(` - connections: ${used} in use, ${free} free, max ${valueOrUnknown(max)}, min ${valueOrUnknown(min)}`);
|
|
15
|
+
lines.push(` - waiting for a connection: ${pendingAcquires}, connections being opened: ${pendingCreates}`);
|
|
16
|
+
} else {
|
|
17
|
+
// a timeout implies a pool exists, so this is a pool without tarn counters
|
|
18
|
+
lines.push(' - connections: pool counters not available');
|
|
19
|
+
}
|
|
20
|
+
if (details.acquireConnectionTimeout !== undefined && details.poolAcquireTimeoutMillis !== undefined) {
|
|
21
|
+
lines.push(` - timeout settings: acquireConnectionTimeout ${details.acquireConnectionTimeout}, pool.acquireTimeoutMillis ${details.poolAcquireTimeoutMillis} (knex applies the smaller)`);
|
|
22
|
+
}
|
|
23
|
+
const reason = singleLine(details.poolReason);
|
|
24
|
+
lines.push(` - reason reported by the pool: ${reason || 'not available'}`);
|
|
25
|
+
if (details.eventLoopDelay) {
|
|
26
|
+
const { maxMs, p99Ms, windowMs } = details.eventLoopDelay;
|
|
27
|
+
lines.push(` - event loop delay over the last ${Math.round(windowMs / 1000)} s: max ${Math.round(maxMs)} ms, p99 ${Math.round(p99Ms)} ms`);
|
|
28
|
+
}
|
|
29
|
+
const phase = singleLine(details.phase);
|
|
30
|
+
const where = [
|
|
31
|
+
phase ? `phase ${phase}` : undefined,
|
|
32
|
+
`host ${details.hostname}`,
|
|
33
|
+
`pid ${details.pid}`
|
|
34
|
+
].filter(Boolean).join(', ');
|
|
35
|
+
lines.push(` - ${where}`);
|
|
36
|
+
if (suppressed > 0) {
|
|
37
|
+
lines.push(` - pool timeouts since the previous report: ${suppressed}`);
|
|
38
|
+
}
|
|
39
|
+
lines.push(`See ${POOL_TIMEOUT_DOCS_URL}.`);
|
|
40
|
+
return lines.join('\n');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.POOL_TIMEOUT_DOCS_URL = POOL_TIMEOUT_DOCS_URL;
|
|
44
|
+
exports.appendDocsLink = appendDocsLink;
|
|
45
|
+
exports.formatPoolTimeoutWarning = formatPoolTimeoutWarning;
|
|
46
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sources":["../../src/pool-diagnostics/format.ts"],"sourcesContent":["import type { PoolTimeoutDetails } from './details';\n\n/** Where the error and the warning point readers. The only place the URL lives. */\nexport const POOL_TIMEOUT_DOCS_URL =\n 'https://docs.strapi.io/cms/configurations/database#connection-pool-timeouts';\n\nexport const appendDocsLink = (message: string): string =>\n message.includes(POOL_TIMEOUT_DOCS_URL) ? message : `${message} See ${POOL_TIMEOUT_DOCS_URL}.`;\n\nconst valueOrUnknown = (value: number | undefined) =>\n value === undefined ? 'unknown' : String(value);\n\n// driver errors and labels can span lines; keep each to one bullet\nconst singleLine = (text: string | undefined) => text?.replace(/\\s+/g, ' ').trim();\n\n/** Facts only, one bullet per fact, in the house style of multi-line warnings. */\nexport const formatPoolTimeoutWarning = (\n details: PoolTimeoutDetails,\n { suppressed }: { suppressed: number }\n): string => {\n const lines = [\n `[database] connection pool timeout: waited ${Math.round(details.waitedMs)} ms for a connection (acquire timeout ${valueOrUnknown(details.acquireTimeoutMs)} ms)`,\n ];\n\n if (details.pool) {\n const { used, free, max, min, pendingAcquires, pendingCreates } = details.pool;\n lines.push(\n ` - connections: ${used} in use, ${free} free, max ${valueOrUnknown(max)}, min ${valueOrUnknown(min)}`\n );\n lines.push(\n ` - waiting for a connection: ${pendingAcquires}, connections being opened: ${pendingCreates}`\n );\n } else {\n // a timeout implies a pool exists, so this is a pool without tarn counters\n lines.push(' - connections: pool counters not available');\n }\n\n if (\n details.acquireConnectionTimeout !== undefined &&\n details.poolAcquireTimeoutMillis !== undefined\n ) {\n lines.push(\n ` - timeout settings: acquireConnectionTimeout ${details.acquireConnectionTimeout}, pool.acquireTimeoutMillis ${details.poolAcquireTimeoutMillis} (knex applies the smaller)`\n );\n }\n\n const reason = singleLine(details.poolReason);\n lines.push(` - reason reported by the pool: ${reason || 'not available'}`);\n\n if (details.eventLoopDelay) {\n const { maxMs, p99Ms, windowMs } = details.eventLoopDelay;\n lines.push(\n ` - event loop delay over the last ${Math.round(windowMs / 1000)} s: max ${Math.round(maxMs)} ms, p99 ${Math.round(p99Ms)} ms`\n );\n }\n\n const phase = singleLine(details.phase);\n const where = [\n phase ? `phase ${phase}` : undefined,\n `host ${details.hostname}`,\n `pid ${details.pid}`,\n ]\n .filter(Boolean)\n .join(', ');\n lines.push(` - ${where}`);\n\n if (suppressed > 0) {\n lines.push(` - pool timeouts since the previous report: ${suppressed}`);\n }\n\n lines.push(`See ${POOL_TIMEOUT_DOCS_URL}.`);\n\n return lines.join('\\n');\n};\n"],"names":["POOL_TIMEOUT_DOCS_URL","appendDocsLink","message","includes","valueOrUnknown","value","undefined","String","singleLine","text","replace","trim","formatPoolTimeoutWarning","details","suppressed","lines","Math","round","waitedMs","acquireTimeoutMs","pool","used","free","max","min","pendingAcquires","pendingCreates","push","acquireConnectionTimeout","poolAcquireTimeoutMillis","reason","poolReason","eventLoopDelay","maxMs","p99Ms","windowMs","phase","where","hostname","pid","filter","Boolean","join"],"mappings":";;AAEA,oFACO,MAAMA,qBAAAA,GACX;MAEWC,cAAAA,GAAiB,CAACC,OAAAA,GAC7BA,OAAAA,CAAQC,QAAQ,CAACH,qBAAAA,CAAAA,GAAyBE,OAAAA,GAAU,CAAA,EAAGA,QAAQ,KAAK,EAAEF,qBAAAA,CAAsB,CAAC;AAE/F,MAAMI,iBAAiB,CAACC,KAAAA,GACtBA,KAAAA,KAAUC,SAAAA,GAAY,YAAYC,MAAAA,CAAOF,KAAAA,CAAAA;AAE3C;AACA,MAAMG,aAAa,CAACC,IAAAA,GAA6BA,IAAAA,EAAMC,OAAAA,CAAQ,QAAQ,GAAA,CAAA,CAAKC,IAAAA,EAAAA;AAE5E,mFACO,MAAMC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42 @@
|
|
|
1
|
+
/** Where the error and the warning point readers. The only place the URL lives. */ const POOL_TIMEOUT_DOCS_URL = 'https://docs.strapi.io/cms/configurations/database#connection-pool-timeouts';
|
|
2
|
+
const appendDocsLink = (message)=>message.includes(POOL_TIMEOUT_DOCS_URL) ? message : `${message} See ${POOL_TIMEOUT_DOCS_URL}.`;
|
|
3
|
+
const valueOrUnknown = (value)=>value === undefined ? 'unknown' : String(value);
|
|
4
|
+
// driver errors and labels can span lines; keep each to one bullet
|
|
5
|
+
const singleLine = (text)=>text?.replace(/\s+/g, ' ').trim();
|
|
6
|
+
/** Facts only, one bullet per fact, in the house style of multi-line warnings. */ const formatPoolTimeoutWarning = (details, { suppressed })=>{
|
|
7
|
+
const lines = [
|
|
8
|
+
`[database] connection pool timeout: waited ${Math.round(details.waitedMs)} ms for a connection (acquire timeout ${valueOrUnknown(details.acquireTimeoutMs)} ms)`
|
|
9
|
+
];
|
|
10
|
+
if (details.pool) {
|
|
11
|
+
const { used, free, max, min, pendingAcquires, pendingCreates } = details.pool;
|
|
12
|
+
lines.push(` - connections: ${used} in use, ${free} free, max ${valueOrUnknown(max)}, min ${valueOrUnknown(min)}`);
|
|
13
|
+
lines.push(` - waiting for a connection: ${pendingAcquires}, connections being opened: ${pendingCreates}`);
|
|
14
|
+
} else {
|
|
15
|
+
// a timeout implies a pool exists, so this is a pool without tarn counters
|
|
16
|
+
lines.push(' - connections: pool counters not available');
|
|
17
|
+
}
|
|
18
|
+
if (details.acquireConnectionTimeout !== undefined && details.poolAcquireTimeoutMillis !== undefined) {
|
|
19
|
+
lines.push(` - timeout settings: acquireConnectionTimeout ${details.acquireConnectionTimeout}, pool.acquireTimeoutMillis ${details.poolAcquireTimeoutMillis} (knex applies the smaller)`);
|
|
20
|
+
}
|
|
21
|
+
const reason = singleLine(details.poolReason);
|
|
22
|
+
lines.push(` - reason reported by the pool: ${reason || 'not available'}`);
|
|
23
|
+
if (details.eventLoopDelay) {
|
|
24
|
+
const { maxMs, p99Ms, windowMs } = details.eventLoopDelay;
|
|
25
|
+
lines.push(` - event loop delay over the last ${Math.round(windowMs / 1000)} s: max ${Math.round(maxMs)} ms, p99 ${Math.round(p99Ms)} ms`);
|
|
26
|
+
}
|
|
27
|
+
const phase = singleLine(details.phase);
|
|
28
|
+
const where = [
|
|
29
|
+
phase ? `phase ${phase}` : undefined,
|
|
30
|
+
`host ${details.hostname}`,
|
|
31
|
+
`pid ${details.pid}`
|
|
32
|
+
].filter(Boolean).join(', ');
|
|
33
|
+
lines.push(` - ${where}`);
|
|
34
|
+
if (suppressed > 0) {
|
|
35
|
+
lines.push(` - pool timeouts since the previous report: ${suppressed}`);
|
|
36
|
+
}
|
|
37
|
+
lines.push(`See ${POOL_TIMEOUT_DOCS_URL}.`);
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { POOL_TIMEOUT_DOCS_URL, appendDocsLink, formatPoolTimeoutWarning };
|
|
42
|
+
//# sourceMappingURL=format.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.mjs","sources":["../../src/pool-diagnostics/format.ts"],"sourcesContent":["import type { PoolTimeoutDetails } from './details';\n\n/** Where the error and the warning point readers. The only place the URL lives. */\nexport const POOL_TIMEOUT_DOCS_URL =\n 'https://docs.strapi.io/cms/configurations/database#connection-pool-timeouts';\n\nexport const appendDocsLink = (message: string): string =>\n message.includes(POOL_TIMEOUT_DOCS_URL) ? message : `${message} See ${POOL_TIMEOUT_DOCS_URL}.`;\n\nconst valueOrUnknown = (value: number | undefined) =>\n value === undefined ? 'unknown' : String(value);\n\n// driver errors and labels can span lines; keep each to one bullet\nconst singleLine = (text: string | undefined) => text?.replace(/\\s+/g, ' ').trim();\n\n/** Facts only, one bullet per fact, in the house style of multi-line warnings. */\nexport const formatPoolTimeoutWarning = (\n details: PoolTimeoutDetails,\n { suppressed }: { suppressed: number }\n): string => {\n const lines = [\n `[database] connection pool timeout: waited ${Math.round(details.waitedMs)} ms for a connection (acquire timeout ${valueOrUnknown(details.acquireTimeoutMs)} ms)`,\n ];\n\n if (details.pool) {\n const { used, free, max, min, pendingAcquires, pendingCreates } = details.pool;\n lines.push(\n ` - connections: ${used} in use, ${free} free, max ${valueOrUnknown(max)}, min ${valueOrUnknown(min)}`\n );\n lines.push(\n ` - waiting for a connection: ${pendingAcquires}, connections being opened: ${pendingCreates}`\n );\n } else {\n // a timeout implies a pool exists, so this is a pool without tarn counters\n lines.push(' - connections: pool counters not available');\n }\n\n if (\n details.acquireConnectionTimeout !== undefined &&\n details.poolAcquireTimeoutMillis !== undefined\n ) {\n lines.push(\n ` - timeout settings: acquireConnectionTimeout ${details.acquireConnectionTimeout}, pool.acquireTimeoutMillis ${details.poolAcquireTimeoutMillis} (knex applies the smaller)`\n );\n }\n\n const reason = singleLine(details.poolReason);\n lines.push(` - reason reported by the pool: ${reason || 'not available'}`);\n\n if (details.eventLoopDelay) {\n const { maxMs, p99Ms, windowMs } = details.eventLoopDelay;\n lines.push(\n ` - event loop delay over the last ${Math.round(windowMs / 1000)} s: max ${Math.round(maxMs)} ms, p99 ${Math.round(p99Ms)} ms`\n );\n }\n\n const phase = singleLine(details.phase);\n const where = [\n phase ? `phase ${phase}` : undefined,\n `host ${details.hostname}`,\n `pid ${details.pid}`,\n ]\n .filter(Boolean)\n .join(', ');\n lines.push(` - ${where}`);\n\n if (suppressed > 0) {\n lines.push(` - pool timeouts since the previous report: ${suppressed}`);\n }\n\n lines.push(`See ${POOL_TIMEOUT_DOCS_URL}.`);\n\n return lines.join('\\n');\n};\n"],"names":["POOL_TIMEOUT_DOCS_URL","appendDocsLink","message","includes","valueOrUnknown","value","undefined","String","singleLine","text","replace","trim","formatPoolTimeoutWarning","details","suppressed","lines","Math","round","waitedMs","acquireTimeoutMs","pool","used","free","max","min","pendingAcquires","pendingCreates","push","acquireConnectionTimeout","poolAcquireTimeoutMillis","reason","poolReason","eventLoopDelay","maxMs","p99Ms","windowMs","phase","where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C,MAAM,CAACC,OAAAA,CAAAA,CACPC,IAAI,CAAC,IAAA,CAAA;AACR3B,IAAAA,KAAAA,CAAMY,IAAI,CAAC,CAAC,IAAI,EAAEU,KAAAA,CAAAA,CAAO,CAAA;AAEzB,IAAA,IAAIvB,aAAa,CAAA,EAAG;AAClBC,QAAAA,KAAAA,CAAMY,IAAI,CAAC,CAAC,6CAA6C,EAAEb,UAAAA,CAAAA,CAAY,CAAA;AACzE,IAAA;AAEAC,IAAAA,KAAAA,CAAMY,IAAI,CAAC,CAAC,IAAI,EAAE3B,qBAAAA,CAAsB,CAAC,CAAC,CAAA;IAE1C,OAAOe,KAAAA,CAAM2B,IAAI,CAAC,IAAA,CAAA;AACpB;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
import { type EventLoopMonitor } from './event-loop';
|
|
3
|
+
export { POOL_TIMEOUT_CODE } from './details';
|
|
4
|
+
export type { PoolState, PoolTimeoutDetails } from './details';
|
|
5
|
+
export type { EventLoopDelay } from './event-loop';
|
|
6
|
+
export { POOL_TIMEOUT_DOCS_URL } from './format';
|
|
7
|
+
export interface PoolDiagnosticsOptions {
|
|
8
|
+
logger: {
|
|
9
|
+
warn(message: string): void;
|
|
10
|
+
};
|
|
11
|
+
getPhase?: () => string | undefined;
|
|
12
|
+
now?: () => number;
|
|
13
|
+
hostname?: string;
|
|
14
|
+
pid?: number;
|
|
15
|
+
intervalMs?: number;
|
|
16
|
+
/** Injected in tests; null turns the event loop measurement off. */
|
|
17
|
+
eventLoopMonitor?: EventLoopMonitor | null;
|
|
18
|
+
}
|
|
19
|
+
export interface PoolDiagnostics {
|
|
20
|
+
dispose(): void;
|
|
21
|
+
}
|
|
22
|
+
/** knex also uses KnexTimeoutError for query timeouts; only pool acquire timeouts are described. */
|
|
23
|
+
export declare const isPoolAcquireTimeout: (error: unknown) => error is Error;
|
|
24
|
+
/**
|
|
25
|
+
* Wraps acquireConnection on the knex client Strapi created. On a pool acquire timeout, the same
|
|
26
|
+
* error object gets a deeper stack, a docs link and `details`; at most one warning block per
|
|
27
|
+
* interval goes to the logger. Facts are collected before the error is changed, so a failure while
|
|
28
|
+
* collecting leaves the error's class, name and message as knex made them (its stack may already be
|
|
29
|
+
* deeper); a failing logger only loses the warning. An error that already carries `details` from
|
|
30
|
+
* an earlier install is passed through.
|
|
31
|
+
*/
|
|
32
|
+
export declare const installPoolDiagnostics: (knex: Knex, options: PoolDiagnosticsOptions) => PoolDiagnostics;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pool-diagnostics/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAIjC,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAI7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AASjD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE;QAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,oGAAoG;AACpG,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,KAGb,CAAC;AAgBnD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,IAAI,EACV,SAAS,sBAAsB,KAC9B,eAkFF,CAAC"}
|