Repository navigation
Description
Summary
A JSON-LD query pinned to an earlier transaction ("from": "<ledger>@t:2"), issued after the ledger has moved on to t=3, occasionally returns the right subjects with some of their string values replaced by the pinned commit's own metadata: its commit id (bagaybq…, the same value as commit.hash in the t=2 update receipt) and the ledger alias (<name>:main). Neither string was ever transacted as data. The bad answer is always the first pinned read after the background indexer logs Successfully indexed ledger; the next read at the same pin is correct.
Environment
fluree/server:4.2.4andfluree/server:4.2.5Docker images, default settings, no configuration, a fresh container each.- The script below reproduces it on linux/aarch64 and linux/x86_64 (table under Observed). We first met it on a GitHub Actions runner (
fluree/server:4.2.4as a service container) in our own test suite.
Reproduce
Standard library Python only. Run against a fresh server:
python3 repro_pinned_read.py http://localhost:8090 300
"""Time-travel reads (`from: <ledger>@t:N`) intermittently return commit metadata as data values.
Standard library only. Against a fresh fluree/server (default settings):
python3 repro_pinned_read.py http://localhost:8090 100
For each of N fresh ledgers: three transactions (t=1, 2, 3), each inserting two subjects with string values;
then, for 300 ms after t=3 commits, repeated reads pinned at t=2. Every string value returned is checked against
the set of strings actually transacted up to t=2. A read that returns any other string is printed.
"""
from __future__ import annotations
import json
import sys
import time
import urllib.request
import uuid
CONTEXT = {"ex": "http://example.org/"}
WINDOW_SECONDS = 0.3
def post(url: str, body: dict) -> object:
request = urllib.request.Request(
url, data=json.dumps(body).encode(), headers={"Content-Type": "application/json"}, method="POST"
)
with urllib.request.urlopen(request, timeout=30) as response:
return json.loads(response.read())
def subjects(txn: int) -> list[dict]:
"""Two subjects per transaction, each with a few string values (one JSON-shaped, one hash-shaped)."""
out = []
for k in range(2):
key = f"item-{txn}-{k}"
doc = json.dumps({"key": key, "txn": txn, "payload": "x" * 40}, sort_keys=True)
out.append({
"@id": f"ex:{key}",
"@type": "ex:Item",
"ex:group": "g1",
"ex:key": key,
"ex:digest": uuid.uuid5(uuid.NAMESPACE_URL, key).hex * 2,
"ex:doc": doc,
"ex:version": "v1",
})
return out
def strings(nodes: list[dict]) -> set[str]:
found: set[str] = set()
for node in nodes:
for key, value in node.items():
if key == "@id":
continue
for v in value if isinstance(value, list) else [value]:
if isinstance(v, str):
found.add(v)
return found
def main() -> None:
server, ledgers = sys.argv[1].rstrip("/"), int(sys.argv[2])
base = server + "/v1/fluree"
select = {
"@context": CONTEXT,
"select": {"?s": ["ex:group", "ex:key", "ex:digest", "ex:doc", "ex:version"]},
"where": {"@id": "?s", "@type": "ex:Item", "ex:group": "g1"},
}
reads = bad_reads = 0
for _ in range(ledgers):
ledger = f"repro-{uuid.uuid4().hex[:12]}"
post(f"{base}/create", {"ledger": ledger})
written_to_t2: set[str] = set()
for txn in (1, 2, 3):
nodes = subjects(txn)
receipt = post(f"{base}/update/{ledger}", {"@context": CONTEXT, "insert": nodes})
assert receipt["t"] == txn, receipt
if txn <= 2:
written_to_t2 |= strings(nodes)
committed = time.monotonic()
while time.monotonic() - committed < WINDOW_SECONDS:
answer = post(f"{base}/query", {**select, "from": f"{ledger}@t:2"})
reads += 1
stray = sorted(s for s in strings(answer) if s not in written_to_t2)
if stray:
bad_reads += 1
elapsed_ms = (time.monotonic() - committed) * 1000
print(f"{ledger}@t:2, {elapsed_ms:.1f} ms after t=3 committed, {len(answer)} subjects,"
f" values never transacted: {stray}")
print(f"{ledgers} ledgers, {reads} reads pinned at t=2, {bad_reads} returned values never transacted")
if __name__ == "__main__":
main()Observed
| host | image | reads pinned at t=2 (300 ledgers) |
returned values never transacted |
|---|---|---|---|
| linux/aarch64 | 4.2.4 | 29,557 | 41 |
| linux/x86_64 | 4.2.4 | 15,981 | 9 |
| linux/x86_64 | 4.2.5 | 16,497 | 15 |
First lines of the aarch64 run:
repro-8a9b31be2245@t:2, 22.2 ms after t=3 committed, 4 subjects, values never transacted: ['bagaybqabciqitmzy3yrz2bqfomu47hs3ont4reumthx6ka46g2my7rv2wvq2n3i', 'repro-8a9b31be2245:main']
repro-57197864b1e0@t:2, 21.5 ms after t=3 committed, 4 subjects, values never transacted: ['bagaybqabciqejfz43sg54ioeuoyaisocdujozrg2sipbzh2au2fcr4fcfsdhvui', 'repro-57197864b1e0:main']
repro-b3b6f01908d9@t:2, 19.9 ms after t=3 committed, 4 subjects, values never transacted: ['bagaybqabciqcvokyefchbzpuclsyc3xpy4ixkvub4fnhxjn5hq77mfpap3jkfta', 'repro-b3b6f01908d9:main']
300 ledgers, 29557 reads pinned at t=2, 41 returned values never transacted
Server log for the first ledger above (ANSI codes stripped; the bad read is the query right after index_t=3):
2026-11-05T23:22:43.512278Z INFO commit head published t=1
2026-11-05T23:22:43.515267Z INFO commit head published t=2
2026-11-05T23:22:43.518540Z INFO commit head published t=3
2026-11-05T23:22:43.520946Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.523926Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.525912Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.528798Z INFO Successfully indexed ledger index_t=1 fuel=Some(53.0)
2026-11-05T23:22:43.529446Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.532201Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.534213Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.536393Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.538326Z INFO status="success" query_kind="dataset" result_count=4
2026-11-05T23:22:43.539663Z INFO Successfully indexed ledger index_t=3 fuel=Some(56.0)
2026-11-05T23:22:43.540936Z INFO status="success" query_kind="dataset" result_count=4
Expected
Every value returned by a read pinned at t=2 is a value transacted at or before t=2.
Notes
- Only reads pinned behind the head. In a wider harness that rotated four read forms through the same window, only the read pinned behind the head returned stray values: 31 of 17,415 reads, against 0 of 51,828 for reads pinned at the head (
@t:3), unpinned JSON-LD reads and unpinned Cypher reads. - 4.2.5 is affected too: 4 of 6,939 reads pinned behind the head, against 7 of 6,765 on 4.2.4 on the same host.
- The subject count is right; values are replaced. Only string values were replaced. With the script above, every bad read held both the commit id and the alias (41 of 41). In the wider harness, with more string predicates per subject, the commit id was in all 36 bad reads and the alias in 20.
- Possibly adjacent: Commit
f:sizeholds a different value in novelty than in the index #1998 (commit metadata holding different values in novelty and in the index).
Activity
judepayne commentedon Nov 11, 2026
Proposed fix PR #2331