Time series: concurrent single-row SQL INSERTs silently lose samples (sealed-slot lost…
- User
Time series: concurrent single-row SQL INSERTs silently lose samples (sealed-slot lost update)
Summary
Under many concurrent single-row
INSERT INTO <timeseriesType> SET ts=…, <tag>=…, <field>=…statements (each in its own transaction, as happens over the HTTP/wire protocols), the time series engine silently drops samples. The client receives success on every insert (HTTP 200, no exception, noConcurrentModificationException), yet the stored row count comes up short. Confirmed real data loss: a full table scan returns the same short count ascount(*), and aGROUP BY sensor_idshows specific series missing rows.The batched InfluxDB line-protocol path (
POST /api/v1/ts/{db}/write, which appends many samples in one engine call/transaction) is not affected. Single-threaded inserts are not affected.Impact
Silent, unacknowledged data loss on the time series write path under concurrency. Severity is high because there is no error surfaced to the client — an application doing concurrent per-row ingestion over SQL (HTTP or gRPC) loses samples without any signal.
Environment
- Observed on
26.6.1-SNAPSHOT(== thearcadedata/arcadedb:latestimage at time of writing). - Reproduced both embedded (in-process engine) and over HTTP against the Docker image.
Reproduction
A. Embedded (fast, deterministic at high concurrency)
A disabled regression test is included in PR #4450:
engine/src/test/java/com/arcadedb/engine/timeseries/TimeSeriesConcurrentInsertTest.javaIt creates a
TIMESERIES TYPE … SHARDS 1, runs 48 threads × 5000 single-rowINSERTs (each in its owndatabase.transaction(...)), then assertscount(*) == 48*5000. Result: e.g. 239911 / 240000 — 89 samples lost, with no exception and no failed transaction.Enable it by removing the
@Disabledannotation.B. Over HTTP (against the published image)
CREATE TIMESERIES TYPE sensor TIMESTAMP ts TAGS (sid STRING) FIELDS (v DOUBLE) SHARDS 1Then 16 threads, each POSTing 5000 distinct single-row inserts to
POST /api/v1/command/{db}:{"language":"sql","command":"INSERT INTO sensor SET ts=<unique>, sid='s<thread>', v=<i>"}SELECT count(*) FROM sensorreturns short by 10–22 out of 80000 across runs. - Observed on
- Assistant
Let me look at how the SQL INSERT routes into the engine.
- Assistant
While that compiles, let me trace a couple more paths in the transaction machinery.
- Assistant
Compile finished. Now let me add temporary diagnostics to
TimeSeriesBucket.appendSamplesand create a temporary reproduction test to observe the exact stale-read mechanism. - Assistant
Also add a diagnostic in
getOrCreateActiveDataPageto catch the page-creation path: - Assistant
While that runs, let me review the existing concurrent append+compact test to see why it misses this window:
- Assistant
Now verify the fix with the diagnostic test (compaction enabled, diagnostics still in place):
- Assistant
While it runs, clean up the temporary diagnostics and test files:
- Assistant
The targeted test catches the bug decisively (14777/16000 — 1223 samples lost in 2.5s with the tight compaction loop). Now restore the fix:
- Assistant
Now run the full time series test suite against the fixed code:
- Assistant
Suite is progressing. Wait for completion:
- Assistant
Server TS tests are ITs (integration scope). The engine suite covers the changed code paths (compaction, crash recovery, retention, downsampling, accuracy, concurrency). Waiting for results.
- Assistant
No failures so far (16 classes in). Waiting for completion.
- Assistant
Waiting for the suite; the background monitors will notify when it completes.
- Assistant
The benchmark class is grinding. If the 10-minute task timeout kills the run, I'll rerun the suite excluding benchmarks (which CI skips anyway).
- Assistant
Benchmark finished; suite continuing. Waiting.
- Assistant
35 classes in, zero failures. Nearly done.
- Assistant
- Assistant
That's just a leftover polling helper finishing — it confirms the same suite result already reported (BUILD SUCCESS, 367 tests, 0 failures). No further action needed; the fix and regression tests are complete and verified.
- Assistant
Another leftover progress-polling helper completing — no new information. The work is done: root cause fixed in
TimeSeriesShard.compactInternal, regression tests enabled and passing, full time series suite green (367 tests, 0 failures). - Assistant
Last leftover polling helper draining — all background tasks are now complete. Nothing new; the task remains finished and verified.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.