@sleep2agi/commhub-server 0.9.0-preview.173 → 0.9.0-preview.174
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/package.json +1 -1
- package/src/retention.ts +13 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/commhub-server",
|
|
3
|
-
"version": "0.9.0-preview.
|
|
3
|
+
"version": "0.9.0-preview.174",
|
|
4
4
|
"description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and MCP tools (17 collaboration-core + node/provider ops tools; authoritative list: docs-site/docs/api/mcp-tools.md).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/retention.ts
CHANGED
|
@@ -131,12 +131,12 @@ const DEFAULT_CHUNK_ROWS = 2000;
|
|
|
131
131
|
const INCREMENTAL_VACUUM_PAGES = 200;
|
|
132
132
|
const MAX_TABLE_MS = 10 * 60 * 1000;
|
|
133
133
|
|
|
134
|
-
/** 启动后第一次 sweep 的延迟;默认
|
|
134
|
+
/** 启动后第一次 sweep 的延迟;默认 180 秒(见 startRetentionSweeper 里的实测)。 */
|
|
135
135
|
function readFirstSweepDelayMs(): number {
|
|
136
136
|
const raw = process.env.COMMHUB_RETENTION_FIRST_DELAY_MS;
|
|
137
|
-
if (raw === undefined || raw.trim() === "") return
|
|
137
|
+
if (raw === undefined || raw.trim() === "") return 180_000;
|
|
138
138
|
const n = Number(raw);
|
|
139
|
-
return Number.isFinite(n) && n >= 0 ? Math.floor(n) :
|
|
139
|
+
return Number.isFinite(n) && n >= 0 ? Math.floor(n) : 180_000;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
function readChunkRows(): number {
|
|
@@ -516,7 +516,16 @@ export function startRetentionSweeper(
|
|
|
516
516
|
// ```
|
|
517
517
|
// 同一批删除在稳态是 0.24ms/行,在启动那一分钟是 4.2ms/行(慢 17 倍)——
|
|
518
518
|
// 不是删除变慢了,是它在和重连风暴抢 CPU/WAL。而这一分钟的阻塞最容易被误记成
|
|
519
|
-
// “retention 又卡了”。默认延后
|
|
519
|
+
// “retention 又卡了”。默认延后 180 秒(可用 COMMHUB_RETENTION_FIRST_DELAY_MS 覆盖,0=立即)。
|
|
520
|
+
//
|
|
521
|
+
// 为什么是 180 而不是 60(.173 上线后实测修正):
|
|
522
|
+
// ```
|
|
523
|
+
// 18:55:24 boot
|
|
524
|
+
// 18:55:38 stall 20.6s (served 812) ← 重连风暴
|
|
525
|
+
// 18:56:24 retention(+60s) swept 3894ms, max 1238ms, telemetry=2964 行/2935ms = 0.99ms/行
|
|
526
|
+
// 18:56:26 stall 2.7s · 18:57:28 stall 3.4s · 18:57:31 stall 2.6s ← 风暴 2 分钟还没排空
|
|
527
|
+
// ```
|
|
528
|
+
// 稳态同一批删除是 0.24ms/行 ⇒ 60 秒时风暴仍在,max 单批被推到 1.2 秒(越过 1 秒慢 SQL 阈值)。
|
|
520
529
|
if (firstDelayMs > 0) setTimeout(() => { void sweep(); }, firstDelayMs);
|
|
521
530
|
else setImmediate(() => { void sweep(); });
|
|
522
531
|
return setInterval(() => { void sweep(); }, intervalMs);
|