sql_materialize holds the per-session scratch lock for the whole remote source read, blocking all other scratch work
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 30/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- sql, typescript
- Domaine
- databases, performance
Piste de recherche
Start in packages/opencode/src/altimate/tools/sql-materialize.ts around lines 373-380 and 472-480 to see which work sits inside withScratchConnection, then read exclusive() and the per-session queue in packages/opencode/src/altimate/native/connections/scratch.ts. Done means preflight and the source read run outside the lock, only the write phase takes it, and a SELECT 1 on scratch returns in under a second during a slow materialize. The fix changes concurrency semantics, so confirm the design with maintainers first.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Problem
While one sql_materialize reads from a slow remote source, every other scratch operation in the session (sql_execute on scratch, sql_check, schema_inspect, another sql_materialize from a different source) queues behind it, including calls from sub-agents.
Mechanism
sql_materializerunspreflight()andexecuteSource()against the remote source insidewithScratchConnection(...)(packages/opencode/src/altimate/tools/sql-materialize.ts:373-380).- That callback is
exclusive()(packages/opencode/src/altimate/native/connections/scratch.ts:107), a single promise chain per root session shared by all sub-agents (:51-61,:170). - Only the write phase (
BEGIN/CREATE/INSERT/COMMIT,sql-materialize.ts:472-480) needs the lock. - Reported tool
durationMsincludes queue time, which also misleads timing analysis.
Evidence
Recorded sessions:
- One session was blocked for 1,464 s: three SQLite reads that take 0.6 s alone, issued from 4 parallel sub-agents, all finished together with a multi-minute remote read.
- Other blocks of 706, 404, 376, 129 and 43 s; 10,753 call-seconds of waiting across 7 sessions, none of which produced a correct answer.
- Up to 96 scratch calls in flight at once, completing in bursts; one-row
COUNT(*)queries waited 140-280 s. - In another set of sessions 824 s of queueing across 59 sessions; a 4-row lookup waited 115 s behind an unrelated materialization; a 6-row aggregate took 48.7 s because it queued behind a 48.3 s materialization; an estimated 370 s of wall time lost in 89 generations.
Impact
Time (and, under a time budget, answers): it prevents fan-out from running in parallel and adds directly to budget pressure. Observed with both Claude Opus and gpt-5.6-sol sessions, worst under sub-agent fan-out.
Proposed fix
- Run preflight and the source read outside the lock (stream to a staging file or buffer); take
exclusive()only for the write phase. - Serve read-only scratch queries on separate DuckDB connections to the same file so reads do not queue behind writes.
- Report
queue_msandexec_msseparately in tool metadata and traces.
Acceptance check
- Test: while a materialize from a deliberately slow source is running, a
SELECT 1on scratch from another sub-agent returns in under 1 s. - Two concurrent materializations from different sources overlap their read phases.
Related: #1479 (Mongo byte-bounded reads fetched one document per round trip; fix in #1480).
- Langage dominant
- TypeScript
- Étoiles
- 810
- Forks
- 121
- Merge moyen
- 1 j 12 h
- PR mergées (30 j)
- 94
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de AltimateAI/altimate-code
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
AltimateAI/altimate-code#1454 ·
Les mainteneurs répondent en général sous 1 jour
-
test: MCP tests fail when the developer's ~/.claude.json has MCP servers (HOME is not sandboxed)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
AltimateAI/altimate-code#1386 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
AltimateAI/altimate-code#1384 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
AltimateAI/altimate-code#1323 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
AltimateAI/altimate-code#1288 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de AltimateAI/altimate-code
Issues similaires
-
area: app type: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
ExpidetGames/code-reviewer#585 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 83/100
module-federation/core#5205 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
LanternOps/breeze#9392 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
engine-rs P3 review-deferral wasm
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
maniator/verticopolis#1154 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour