PGlite wasm: multi-row `INSERT ... ON CONFLICT` under DELETE+INSERT churn probabilistically never returns — main-thread JIT spin, SIGTERM-proof, kill -9 only
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 静か
- 技術スタック
- bun, postgres, wasm
- 領域
- databases
調査の方向性
レポートで言及されている完全な E5 pure-SQL 再現手順とサニタイズ済みデータベースを入手し、フリーズする条件を記録しながら PGlite 0.4.3 に対して実行する。除外マトリクスに記載されているとおり、HNSW インデックスがない場合と、アプリケーションの同時実行数を 1 に設定した場合の実行を比較する。無限ループが再現され、その原因が回帰テストと範囲を限定した修正を定義できる程度に切り分けられれば完了とする。
索引モデルが issue の本文から書いたものです。
説明
Version: @electric-sql/pglite 0.4.3 (bundled pgvector 0.8.1) · Runtime: Bun 1.3.14 · Platform: macOS 26.5.2, arm64 (Apple Silicon)
Summary
Under a sustained stream of per-page DELETE + multi-row INSERT ... ON CONFLICT
operations (~30 rows per INSERT, 18 columns including a vector(1024) column and
a generated tsvector column backed by a GIN index), PGlite probabilistically
enters an infinite loop inside the INSERT execution itself. The query never
returns, the JS main thread spins at ~99% CPU in JIT-generated code, SIGTERM is
never delivered (the event loop is wedged), and the process requires kill -9.
Reproduced 5 times on 2026-07-25: 4× inside the gbrain embedding pipeline
(with API-driven embedding), and — decisively — 1× in a pure offline SQL
storm with zero network, zero API, zero application code: just PGlite and raw
SQL against a copy of a real 47k-row database.
The decisive pure-SQL repro (E5)
Script shape (full script available; pseudocode):
const db = new PGlite('/path/to/copy-of-real-db', { extensions: { vector } });
// 70,555 rows with embeddings across 40,089 pages.
// For each page (20-way Promise-interleaved; PGlite single connection serializes):
// SELECT page's rows (embedding::text)
// DELETE FROM content_chunks WHERE page_id = $1
// INSERT INTO content_chunks (18 cols incl. $n::vector) VALUES (...N rows...)
// ON CONFLICT (page_id, chunk_index) DO UPDATE ...
Result: froze after ~19,300 of 40,089 pages (~48%), ~80 seconds into the
storm. CPU 97.7%, zero log growth, process wedged until kill -9.
Table/index state at freeze time (HNSW vector index had been dropped
beforehand — it is NOT required):
content_chunks_pkey, content_chunks_stale_idx, idx_chunks_embedding_image,
idx_chunks_embedding_null, idx_chunks_language, idx_chunks_page,
idx_chunks_page_index, idx_chunks_search_vector (GIN FTS, ~104MB),
idx_chunks_symbol_name, idx_chunks_symbol_qualified,
idx_content_chunks_edges_backfill, idx_content_chunks_symbol_lookup
Exclusion matrix (every hypothesis tested live, same database)
| Hypothesis | Result |
|---|---|
| Zero / NaN vectors breaking HNSW | ❌ 100 zero-vectors inserted fine; vectors at freeze all healthy (len=1024, nan=0, inf=0, nonzero=1024, max≈0.2) |
| Statically corrupted index | ❌ full replay of pending inserts exits cleanly |
| Poisoned page content | ❌ freeze pages (4 different ones across runs) re-run individually in seconds |
| Concurrency race | ❌ also freezes with application concurrency = 1 |
| API returning degraded vectors during rate-limit storms | ❌ vector health check at freeze instant: all healthy |
| HNSW index bloat / dead-tuple cliff | ❌ churn raises latency sub-linearly (153→405ms over 1500 rounds), no cliff; and a fresh REINDEX'd 438MB index froze at 11%; and with DROP INDEX idx_chunks_embedding it still froze |
| pgvector / HNSW involvement at all | ❌ falsified — freeze reproduced with the HNSW index absent |
The only common factor across all 5 freezes: a multi-row INSERT (31–33 rows,
with tsvector generated column + 4KB vector column) into the churned table,
executed by the PGlite wasm build. Page content, index type/presence/age,
concurrency, and vector health are all irrelevant.
Stack fingerprint (identical across all 5 captures)
sample(1) shows 100% of samples on the main thread in a ~50–90-frame chain of
anonymous JIT frames (addresses inside the JSC "JS JIT generated code" region,
which also hosts compiled wasm), via the Bun→JS trampoline (bun+0x32642b8).
All other threads idle. Zero open network connections (lsof). The inspector
protocol also dies: WS handshake succeeds but Debugger.enable/Debugger.pause
get zero responses — consistent with a tight JIT/wasm loop with no safepoint.
Real-world impact
In gbrain (which embeds via exactly this DELETE+INSERT pattern), this manifests
as gbrain embed --stale silently freezing mid-run — observed in production at
16% and 65% progress, one process spinning 92 minutes before manual kill.
SIGTERM-based supervisors cannot recover it.
Suspected areas (unverified pointers)
idx_chunks_search_vectorGIN FTS index — fastupdate pending-list flush
pathology under wasm during high-churn INSERT.- PGlite wasm memory growth / executor defect on large multi-row INSERTs with
wide rows (tsvector + vector(1024)).
Environment
- @electric-sql/pglite 0.4.3 (pgvector extension 0.8.1 bundled; upstream is 0.8.5)
- Bun 1.3.14, macOS 26.5.2 arm64
- Database: single PGlite data dir, ~532MB RSS at freeze, no autovacuum (PGlite),
never VACUUM/REINDEX except where noted - Forensics archive: 5×
samplestack dumps, 5× run logs, repro scripts
(happy to share the full bundle + a sanitized database copy)
- 主要言語
- TypeScript
- スター
- 16.3k
- フォーク
- 474
- 平均マージ
- 23時間 53分
- マージ済み PR(30日)
- 53
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
electric-sql/pglite のほかの issue
-
Feature request: Nitro 3 support (`unwasm` export condition)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
electric-sql/pglite#1120 · コメント 16 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
electric-sql/pglite#1200 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
electric-sql/pglite#1192 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]: syncToFs() resolves immediately, without syncing, when another sync is already queued対応中かも @PrabalParihar が 11 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
electric-sql/pglite#1191 ·
メンテナーはふだん 1 日以内に返信
-
Feature request: live: allow pausing the notify triggers during bulk writes (e.g. pglite-sync applies) and refresh once on resume対応中かも @tdrz が 13 日前に担当しました。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
electric-sql/pglite#1184 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
electric-sql/pglite の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
langchain-ai/langchainjs#12239 ·
メンテナーはふだん 1 日以内に返信
-
Board view: the Monitoring column is always empty because compact issue rows drop displayStatusオープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
paperclipai/paperclip#21837 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
code-yeongyu/senpi#6813 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 93/100
lingdojo/kana-dojo#34169 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100