You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
code.symbol returns no lessons when the memory_code_links reads exceed code_enrich_timeout_s #644
code.symbol returns no lessons for a symbol that has a fresh link in memory_code_links, because the lessons read takes longer than code_enrich_timeout_s (0.5 s) and _bounded swaps it for [] without saying so.
code_plane_reads.lessons_for_symbol reads memory_code_links FINAL three times, by path, by former.path and by anchored_path. On a deployment with about 1M link rows (8 parts, 94 MiB):
Read
Duration
Rows read
Rows returned
path IN (...)
934 ms
6,497
9
anchored_path IN (...)
559 ms
950,572
9
hasAny(former.path, ...)
70 ms
0
0
The anchored_path read scans almost the whole table: anchored_path is not in the sort key, and its bloom_filter skip index does not prune under FINAL. When the reads finish, the excerpt read of the matched memories has not started yet, and the 0.5 s bound has already passed.
A symbol whose file has many linked memories goes over the bound on the excerpt read as well: for one file with 176 links, served_excerpts took 871 ms.
Does it reproduce on the latest release or main?
Yes. Server 1.2.0, the code path is unchanged on main.
How to reproduce
On a deployment whose memory_code_links holds many rows, save a memory in a repository's code namespace that names a symbol in backticks and lists its file in files.
Wait until memory_code_links has a fresh row for that memory.
Call code.symbol for that symbol with include_lessons: true (the default).
The definition has no lessons. In system.query_log, the memory_code_links reads of that request (its log_comment is code.symbol <request id>) add up to more than 500 ms, and no excerpt read follows them.
Expected behavior
The linked memory comes back under lessons. When the read is cut off by its bound, the reply says that lessons were not read, so a caller can tell this apart from a symbol that has no lessons.
Environment
Loom 1.2.0, ClickHouse 26.10, ClickHouse Cloud service, one server instance.
How this was found
An agent testing an MCP client against a running server.
Additional context
Possible fixes: read anchored_path without FINAL and deduplicate in the query, or add a projection sorted by anchored_path; then take the matched memory ids down to limit before the excerpt read.
The anchored_path bloom filter does prune under FINAL (27/984 granules), but use_skip_indexes_if_final_exact_mode widens it to every granule intersecting them by primary key (282).
current_links also reads loom.memory FINAL by memory_id, like served_excerpts; random ids touch nearly every granule.
Fix: your first suggestion, with one change. Deduplicating rows read without FINAL would still return a link whose newest version moved away or was deleted, so the read without FINAL only selects the matching keys, and FINAL reads just those. The memory reads filter by the identity stored on the link plus memory_id, which follows loom.memory's sort key. I skipped the projection (not used under FINAL, needs a migration) and the cut to limit (the ranking needs pinned and confidence from the excerpt read).
Rows read on a local reproduction (1M links, 1M memories, merges stopped), same rows returned:
Read
main
fix
links by anchored_path
306,176
35,840
memory heads, 176 memories
1,009,984
70,784
excerpts, 176 memories
1,009,984
70,784
The path read already reads few rows, so its 934 ms is not explained by this and the change does not touch it.
Activity
code.symbol's lesson reads narrow by the sort key, so they finish wit…
enricoconvento98 commentedon Nov 18, 2026
I'd like to work on this.
Two additions to the cause:
anchored_pathbloom filter does prune underFINAL(27/984 granules), butuse_skip_indexes_if_final_exact_modewidens it to every granule intersecting them by primary key (282).current_linksalso readsloom.memory FINALbymemory_id, likeserved_excerpts; random ids touch nearly every granule.Fix: your first suggestion, with one change. Deduplicating rows read without
FINALwould still return a link whose newest version moved away or was deleted, so the read withoutFINALonly selects the matching keys, andFINALreads just those. The memory reads filter by the identity stored on the link plusmemory_id, which followsloom.memory's sort key. I skipped the projection (not used underFINAL, needs a migration) and the cut tolimit(the ranking needspinnedandconfidencefrom the excerpt read).Rows read on a local reproduction (1M links, 1M memories, merges stopped), same rows returned:
The
pathread already reads few rows, so its 934 ms is not explained by this and the change does not touch it.code.symbol's lesson reads narrow by the sort key, so they finish wit…
code.symbol's lesson reads narrow by the sort key, so they finish wit…
code.symbol's lesson reads narrow by the sort key, so they finish wit…
code.symbol's lesson reads narrow by the sort key, so they finish wit…
code.symbol's lesson reads go through the sort key and finish within …