ISSUE DESCRIPTION Time series: concurrent single-row SQL INSERTs silently lose samples…
- User
ISSUE DESCRIPTION
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 out of 80000 across runs. - Observed on
Assistant
Good, mvnw works with HOME set. Let's run the test.
Assistant
Let's revert the diagnostic changes first, then implement the real fix cleanly.
Assistant
Now let's add the new methods to TimeSeriesBucket.java: a partial-page-aware range reader and a page sample count getter.
Assistant
Now let's apply the fix:
Assistant
Now let's compile and run the test with real changes (maintenance scheduler restored to default, no diagnostics).
Assistant
Good, this is exactly what's needed per the issue (enable the test once fixed). Let's fix indentation and unused import.
Assistant
Now let's compile and run the test.
Assistant
Test passes now. Let's run it multiple times to check flakiness (since concurrency bugs can be intermittent).
Assistant
Passes consistently across 3 runs (each ~16-17s, well past the 5s compaction trigger). Now let's run the broader TimeSeries test suite to make sure we haven't broken anything else, especially compaction-related tests.
Assistant
No failures. Now let's check
TimeSeriesConcurrentAppendCompactTest.javaspecifically since it's directly relevant to what we fixed.Assistant
Compiles fine. Let's view the full diff so far to review correctness.
Assistant
All pass. Now let's also run the full engine test suite (broader) to check no other breakage, though this may take a while. Let's check total test count/time estimate first.
Assistant
Good. Let's view the final diff overview and clean up any leftover temp files.
Assistant
Let's do a final full review of the diff to make sure it's clean and well documented.
Assistant
This looks clean. Let's run the target test one final time to confirm everything is in order before submitting.
Assistant
Let's also run the full timeseries suite once more as a final sanity confirmation.
Assistant
All tests pass with EXIT=0 (COUNT(*) result: 50,000,000 confirms no data loss in this large benchmark too). Let's finalize the git status.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.