Defer later closes behind a pending close even when they do not request a flush themselves. Reuse the existing close-time flush and waiter handoff.
Cover ordinary WAL writes with mixed flush_on_close values and verify committed SSTs before reopening.
Signed-off-by: WenyXu <wenymedia@gmail.com>
(cherry picked from commit 327f6ed9dd)
Reject pending lifecycle requests when retiring a region. Give each completion one dispatch owner while preserving stalled-write ordering, edit-before-compaction dispatch, and fenced-region reload handling.
Cover edit retirement with queued requests; the regression times out when removal only rejects edits.
Signed-off-by: WenyXu <wenymedia@gmail.com>
(cherry picked from commit a243f570ca)
Extend the pending ALTER queue to defer lifecycle requests blocked by region edits. Preserve scheduler handoffs and drain accepted edits before entering staging, rejecting new unbound imports at that boundary.
Keep ApplyStagingManifest's asynchronous execution and close-time flush behavior. Cover queue bounds, failures, staging transitions, close/reload races, and flush concurrency.
Signed-off-by: WenyXu <wenymedia@gmail.com>
(cherry picked from commit 1e08f05ed0)
The metric engine derives the columns to add from the cached physical
schema, and `DataRegion::assemble_alter_request` assigned every given
column `max(non-reserved column id) + 1` without checking the existing
names. That cache can lag behind: Mito reads its in-memory metadata
without going through the region worker, and a caller future dropped on a
client timeout does not withdraw the request that is already queued. A
retry then treats an installed column as new and Mito rejects it, because
the name exists with a different id.
Recheck the real metadata in `assemble_alter_request`, validate an
existing column with `validate_shared_column` and drop it from the
payload, assign ids only to genuinely new columns, and skip the alter when
nothing is new. Serialize the existence check, the id allocation and the
physical alter per physical data region: the mutex lives in
`PhysicalRegionState` and is held by the metric engine orchestration, so
concurrent requests on logical regions sharing the region cannot allocate
one id to different columns. `DataRegion` stays a stateless adapter.
Build the logical mapping and the cached physical columns from the
metadata read after the alter, and report a missing column as an error
instead of panicking.
Signed-off-by: Wenyu Xu <wenymedia@gmail.com>
(cherry picked from commit 04ee42eb6f33c03e3fbe9c23c9d18ef4456db3b9)
Reject query planning during repartition handoff and keep new targets pending until all manifests have been applied. Carry planned partition versions to datanodes and validate the pinned scan snapshot, including retiring merge sources. Preserve retryable read errors and cover cached routes, transport, metric mapping, and scope changes.
Signed-off-by: WenyXu <wenymedia@gmail.com>
Add optional file-sampling requests and unscaled sample diagnostics, validate limits, and preserve the fields through region RPC conversion. Pin the published proto revision in the standalone OSS workspace; retain Cargo-generated lockfile dependency-edge normalization.
Signed-off-by: WenyXu <wenymedia@gmail.com>
Standalone closes the metadata backend on shutdown, and
`MetadataKvBackendCreator` now returns a `ClosableKvBackendRef`. Only the
raft-engine backend implemented `ClosableKvBackend`, so external metadata
backends could not be wired into the standalone creator.
Implement `ClosableKvBackend` for `RdsStore` and return
`ClosableKvBackendRef` from `with_mysql_pool`/`with_pg_pool` and the
metasrv RDS builders. The stores only hold reference-counted connection
pools that are released with the last backend handle, so `close()` has
nothing to release explicitly.
Signed-off-by: WenyXu <wenymedia@gmail.com>
CreateLogicalTables copies every physical partition column into the logical
schema as a nullable String tag. After a physical metric table is repartitioned
by the internal `__table_id` column, that column reached the region create
request and the metric engine rejected it with "Internal column __table_id is
reserved", so no logical table could be created.
Filter engine-owned identity columns while merging, reusing
`is_metric_engine_internal_column`. Filtering at the merge point also protects
procedures that persisted an unfiltered `physical_partition_columns` list.
User partition columns keep the previous behavior.
Write routing for a physical table partitioned by `__table_id` is still
tracked by #10352; this change only unblocks logical table creation.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* perf(mito2): prefilter dynamic join membership
Read the narrow dynamic-membership column before the full projection and use a stable per-row-group mask to select rows. The live filter above the scan stays authoritative; bounds-only and unsupported shapes keep all rows.
Signed-off-by: discord9 <discord9@163.com>
* test: cover dynamic prefilter cache and generations
Prove the prefilter-result cache keeps the static mask but never reuses a dynamic mask across producer generations. Document why a superseded dynamic mask is discarded rather than assumed monotone.
Signed-off-by: discord9 <discord9@163.com>
---------
Signed-off-by: discord9 <discord9@163.com>
The synchronous FlushRegions handler wrapped the error returned by the
flush task into Unexpected before building the reply. InstructionError
then only copied the Unexpected status code and the default NonRetryable
hint, so metasrv could not tell a transient flush failure from a
non-retryable one.
Return the task error unchanged so its status code and retry hint reach
FlushRegionReply, and rebuild the reply message with the same debug chain
the previous wrapper produced to keep the diagnostics unchanged.
Add handler-level tests covering RegionBusy, RegionNotFound and Unexpected
task errors under both FailFast and TryAll.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(log-store): skip objects collected below the boundary in WAL reads
The read-only WAL reader lists the source prefix and then reads the
header and footer of every listed object. While the store writing the
prefix is still collecting objects, a listed object can be deleted
before its footer is read. The NotFound failed the whole read, even when
the object lay below the reclaim boundary and was off the chain the read
replays, so reads of a large prefix under steady writes failed often.
Apply the rule startup recovery already uses. An object gone below the
reclaim boundary at which the chain of the read stops is skipped. Any
other vanished object, on the chain or off it, still fails the read: it
may be the object that completes a later chain or carries the largest
epoch. Startup recovery and the reader now share one NotFound split and
one boundary check.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(log-store): cover unreadable objects in listed WAL reads
A NotFound below the boundary is skipped, but any other error reading a
header or footer must still fail the read. Cover it with a corrupted
header below the boundary in both modes.
Describe the boundary in `ensure_vanished_below` and `read` in terms
that also fit the `LastEntry` mode, where the chain can stop at the
object of `after` instead of a reclaim boundary.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs(log-store): describe where WAL reads stop following links
In the `LastEntry` mode a later object can carry a reclaim boundary
above the object of the reported entry. The read then keeps that object
as its tip below the boundary and follows no link from it. Say that the
boundary stops the links to predecessors, and that the tip is the one
object below it a read can need.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(log-store): pin the outcomes of vanished-object reader tests
The unreadable-object test now asserts the InvalidWalObject error for
object 1 inside the index cache's wrapper, instead of any error other
than NotFound. The vanished chain-object test states the outcome it
guards against: without object 2 a listed read could select the chain
ending at object 1 and succeed with no entries.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
---------
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
information_schema.tables.create_options (and SHOW TABLE STATUS) printed
object store credentials of external tables verbatim, and SHOW CREATE TABLE
masked only access_key_id and secret_access_key. Mask all four credential
keys in both paths, and sort extra options in create_options by key.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix: honor the pipeline version header and URL parameter in Elasticsearch _bulk
The Elasticsearch _bulk handlers read only pipeline_name and msg_field and
hardcoded the pipeline version to None, so the x-greptime-pipeline-version
header and the version URL parameter were silently ignored and the latest
version was always used.
Resolve the version from the version query parameter, falling back to the
x-greptime-pipeline-version header, and pass it to
PipelineDefinition::from_name; an unparsable version now fails the request
instead of being ignored. Without either source the latest version is used,
as before.
Signed-off-by: fengyue-xve <1759519137@qq.com>
* fix(elasticsearch): reject invalid pipeline version headers and use HTTP item status
Signed-off-by: fengyue-xve <1759519137@qq.com>
---------
Signed-off-by: fengyue-xve <1759519137@qq.com>
* fix(log-store): close raft-engine engines on shutdown
raft-engine preallocates the active log file and only trims that tail when the
Engine is dropped. GreptimeDB never dropped its engines before exiting, so every
start after a clean shutdown truncated the tail as a broken batch and logged
"Truncating log file due to broken batch".
RaftEngineBackend::close and RaftEngineLogStore::stop now release the engine;
standalone closes the metadata backend last, and the datanode stops the
raft-engine WAL after the region server.
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* refactor: address review on raft-engine shutdown
- Add ClosableKvBackend to common-meta; the standalone metadata backend creator
returns one and Instance closes it explicitly instead of downcasting to
RaftEngineBackend, so wrappers forward the close.
- Record a failed metadata backend close as a shutdown error.
- Sync and drop the engine on a blocking thread.
- Only check tail trimming when raft-engine preallocated, and check reopening
after close/stop on every platform.
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* fix: release raft-engine engines on every shutdown path
- Stop the raft-engine WAL when the datanode build fails after opening it.
- Purge and sync tasks hold the engine weakly, so dropping the last backend or
log store reference (as the CLI tools do) closes the engine.
- Fix needless borrows reported by clippy.
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* fix: drop unused ClosableKvBackend import
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* fix: cancel log store readers on stop; address review
- RaftEngineLogStore tracks the tasks feeding read streams and cancels and
joins them on stop, so a retained, unconsumed stream no longer keeps the
engine open past shutdown.
- Tests: stop with a retained read stream; datanode shutdown with a failing
region engine and after a normal shutdown reopens the raft-engine WAL;
standalone stop with failing steps reopens the metadata directory.
- entries_to_batch no longer takes self; rename opened to get_open_engine,
log_files_len to log_files_size and PREALLOCATED_LEN to
PREALLOCATION_THRESHOLD; mod declarations before imports; rename the
standalone shutdown closure to record_shutdown_error.
Model: claude-opus-5-5
Tokens: 15.8k input, 148k output, 2.9M cache write, 103M cache read
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* fix: update Cargo.lock for tokio-util's rt feature
The rt feature makes tokio-util depend on futures-util, which the lock file
has to record for `cargo check --locked`.
Model: claude-opus-5-5
Tokens: 15.9k input, 162k output, 3.0M cache write, 124M cache read
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* refactor: close the raft-engine WAL by ownership instead of a lock
Per review, RaftEngineLogStore holds the engine as a plain Arc<Engine> again:
- MitoEngine drops its Wal raw entry reader once its workers are stopped,
so it no longer holds the log store after stop.
- RaftEngineLogStore::close(self) stops the tasks and readers and closes the
engine. Datanode::shutdown takes the log store after stopping the region
server and closes it if it holds the last reference; otherwise it logs a
warning and only stops it.
- A failed build stops the region server it created before closing the log
store, so the engines release it there too.
Model: claude-opus-5-5
Effort: medium
Tokens: 78, 19161, 107293, 4916570 del commit
Cost: 2.23 USD del commit
Session: 82696960-1984-4432-bcf1-33bfece8b526
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* test: drop the index argument from LogStore::read in the raft-engine tests
#9563 removed it from the trait.
Model: claude-opus-5-5
Effort: medium
Tokens: 16, 3715, 6600, 1706794 del commit
Cost: 0.47 USD del commit
Session: 82696960-1984-4432-bcf1-33bfece8b526
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* fix: end a cancelled WAL read with an error; test a written region
- A raft-engine read cancelled by stop now ends its stream with an
IllegalState error instead of an end of stream, so a replay cannot take a
truncated WAL as fully read. The reader flags the cancel instead of sending
the error, since it is usually blocked on a full channel at that point.
- Datanode test: a raft-engine datanode with a created region and writes
shuts down cleanly and its WAL reopens, which fails if anything still
holds the log store.
- Move the doc comment of is_stopped back onto it.
Model: claude-opus-5-5
Effort: medium
Tokens: 42, 10316, 407027, 4108529 del commit
Cost: 4.28 USD del commit
Session: 82696960-1984-4432-bcf1-33bfece8b526
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* fix(log-store): drop the no-op sync before closing the raft-engine engine
Per review: on raft-engine 0.4.2 `Engine::sync` writes an empty batch, and
`Engine::write` returns before the fsync, so the sync in `close_engine` read
as a final flush that never ran. The active log file is trimmed and synced
by `LogFileWriter::close` when the last reference is dropped, so
`close_engine` now only drops it on a blocking thread.
Model: claude-opus-5-5
Effort: xhigh
Tokens: 120, 33613, 182918, 7511982 del commit
Cost: 3.64 USD del commit
Session: 57ca77a8-f6fe-4fa2-a55a-dda31e5c541f
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
---------
Signed-off-by: Silvio <62994417+AbstractBike@users.noreply.github.com>
* chore: update proto for opening region heartbeats
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix: reset failure detectors during background region initialization
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix: preserve detector history for opening regions
Signed-off-by: WenyXu <wenymedia@gmail.com>
* chore: update opening region proto revision
Signed-off-by: WenyXu <wenymedia@gmail.com>
* chore: update opening region proto to merged main
Signed-off-by: WenyXu <wenymedia@gmail.com>
---------
Signed-off-by: WenyXu <wenymedia@gmail.com>
`or` inferred the qualifier of an operand plan from its first field
(`schema.qualified_field(0)`). A binary operation with an explicit matching
modifier derives its result labels from the left operand when the match
reduces the label set, so its projected plan carries two qualifiers: the
labels are `lhs.<label>` while the time index keeps the context table's
qualifier (`rhs.<greptime_timestamp>`). Prefixing the time index with the
first field's qualifier then referenced a column that does not exist, and
planning failed with
Internal error during building DataFusion plan: No field named
lhs.greptime_timestamp. Did you mean 'rhs.greptime_timestamp'?
for e.g. `sum by (l) (f(a) / ignoring(x) group_left() f(b))` used as the
right operand of `or on (l)`. `f(a) / ignoring(x) f(b)` triggers it as
well, so this is not specific to a group modifier. Without a matching
modifier every projected column takes the right operand's qualifier, which
is why plain `a / b` never hit this.
Resolve the time index against the actual operand schema: keep the
preferred qualifier when it really holds the column (uniform schemas, so no
plan changes), otherwise take the qualifier of the column found by name and
let DataFusion report ambiguity instead of guessing.
Signed-off-by: discord9 <discord9@163.com>
* fix(mito2): check the lease before manifest commits and reload regions after conflicts
In conditional manifest mode, refuse a commit whose Leader deadline has
passed before its PUT, and fence a region whose commit hits a manifest
version conflict, then reload it in the background and swap the new
instance in.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): release the flush status when the WAL release after a flush fails
handle_flush_finished failed the flush's waiters and returned when the WAL
release after a committed flush failed, but left the flush registered in the
flush scheduler, so every later flush of the region, and the reload of a
fenced region, waited behind it forever. Handle the failure as a failed
flush, which removes the registration and answers the pending requests.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): cover staging saves after the deadline and a fence during catchup
Add a listener hook before a catchup reopens the region, and test that a
fence landing there makes the catchup answer RegionBusy without replacing
the instance. Also test that entering staging after the Leader deadline
saves no staging manifest.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs(mito2): note that set_region_role does not check the reload mark
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
---------
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(datatypes): decode jsonb before rendering it as text
jsonb_to_string serialized the bytes through RawJsonb's Serialize impl,
which panics with an out-of-range slice index on JSON text such as
"hello world" or " null" (stored by COPY FROM and MySQL text
parameters) and on truncated jsonb. Its text fallback was also stricter than
the extended parser reads used before.
Decode with jsonb::from_slice, as reads did before #10112, then write the
value out with serde_json escaping for keys and strings.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* perf(datatypes): keep streaming jsonb serialization in jsonb_to_string
Decoding into a jsonb::Value tree allocates per array, object and key on
every JSON cell returned over PostgreSQL and MySQL. Go back to serializing
the raw bytes with RawJsonb's Serialize impl, and bump jsonb to a rev whose
Serialize returns an error instead of panicking on out-of-range payloads
(GreptimeTeam/jsonb#2). Bytes that fail to serialize are parsed as JSON
text with the extended parser, as jsonb::from_slice does.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test(datatypes): pin text values that used to read back as false
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* chore: bump jsonb to reject scalar headers with non-zero length bits
JSON text over ~2 MB could still pass the payload bounds check and read back as a wrong value (GreptimeTeam/jsonb#2).
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(datatypes): report the text parse error when JSON bytes are neither jsonb nor text
Also pin jsonb_to_serde_json on JSON text scalars that used to decode as false.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* chore: pin jsonb to the merged commit on main
GreptimeTeam/jsonb#2 reached main through GreptimeTeam/jsonb#3.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
---------
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* chore(deps): bump datafusion to ae04160b
Move all 16 `[patch.crates-io]` DataFusion pins from `cc5534492` to
`ae04160b`, the merge commit of GreptimeTeam/datafusion#42.
That fork commit backports six upstream apache/datafusion fixes:
- #26452 timestamp-to-time casts no longer drive statistics pruning
- #24675 memory-limited NLJ fallback refuses left-emission joins with a
multi-partition probe side instead of emitting wrong unmatched rows
- #24891 RepartitionExec spill-pool deadlock with two open files
- #25076 null-aware anti join no longer emits rows after a sibling probe
partition saw NULL
- #25339 correlated NOT IN with a non-equality correlation
- #26578 null-aware anti join drops build rows with a dictionary NULL key
The first three are faithful backports. The last three are re-implementations:
upstream restructured `hash_join/stream.rs` before writing them, so the patches
do not apply to this fork's older copy of that file. `#25339` covers the
single-equi-key plus residual-filter shape; multi-key correlated `NOT IN` still
fails at planning as before.
`Cargo.lock` is regenerated (35 `datafusion*` packages).
No runtime acceptance has been run against this pin; see the PR description for
the three checks worth doing before shipping.
Signed-off-by: discord9 <discord9@163.com>
* fix(common-query): pass the pruning bitmap to HashTableLookupExpr::new
#39 added a fifth parameter to `HashTableLookupExpr::new`; the dynamic-filter
payload round-trip test still constructed it with four arguments, which breaks
`--all-targets` builds even though the library itself compiles.
Signed-off-by: discord9 <discord9@163.com>
* chore(deps): bump datafusion to 70f84c5b
Move the pins from `ae04160b` to `70f84c5b`, the head of
`greptimedb-55.1-thin-fork` after GreptimeTeam/datafusion#37 was merged on top of
#39/#41/#42.
`ae04160b` did not contain #37, so the reverse-cast constraint propagation
guard was lost and `tests/cases/distributed/optimizer/partition_pruning_cast`
failed: the filter `CAST(k AS BIGINT) = 1` made the planner treat the float
column `k` as a singleton and drop the requested `ORDER BY k DESC`.
The new pin carries both the reverse-cast guard and the six release backports,
so the regression is covered again.
Signed-off-by: discord9 <discord9@163.com>
---------
Signed-off-by: discord9 <discord9@163.com>
* feat(mito2): record pending WAL tails in the region manifest
Adds `pending_tails` and `handoff_floors` to the region manifest and its
checkpoint, and an optional `pending_tails` / `handoff_floor` pair to
`RegionEdit`. An edit without them leaves the records unchanged. A floor is
dropped once the flushed entry id reaches it; a tail stays until a commit
removes it. Neither is written when empty, so manifests without them encode
as before.
Opening a region replays its WAL after this node's tails and floor, and WAL
releases at open and after a flush stay below this node's tails. Nothing
writes these records yet, so every region behaves as before.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* feat(mito2): hold back reads and region changes while WAL tails are pending
A region with pending WAL tails is missing data that only those tails hold.
Until they are recovered, scans and memtable and SST stats fail with the
retryable `RegionPendingTails` error. Truncate, entering staging, a
repartition flush, a close-time flush on request, and ALTERs other than
adding nullable columns without a default or changing options are rejected
before they change any region state. Compaction pauses. A full-listing GC
pass skips the region while it has pending tails, or while a newer manifest
may exist or the manifest listing fails.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs(mito2): name the WAL releases that keep pending tails
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): reject no-op ALTERs of restricted kinds while WAL tails are pending
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): check that reopening restores the pending-tail read gate
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): pin what the pending-tail fixtures and rejections promise
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor(mito2): name the replay start in the open log and share the pending-tail check
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs(mito2): state the per-node order of pending tails and who keeps later writes out of them
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): check that a cancelled compaction starts nothing while WAL tails are pending
When a compaction cancelled by task id finishes, the queued manual request goes through handle_pending_compaction_request, whose pending-tails check replies Ok(0). The reply is read with try_recv so that a dispatched request fails the test at once instead of hanging it.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): drop the pending compaction task state when WAL tails skip it
Skipping a pending manual compaction while WAL tails are pending replied Ok(0) but left its task state in place, so task inspection kept listing it as queued and cancelling it by id still succeeded. Clear the pending task state and publish before replying.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
---------
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
The object store WAL restart test and the skip-WAL tests built on
MockInstanceImpl assume only the tables they create write to the WAL.
The event recorder also writes greptime_private.events into the same
WAL, so when it flushes during the test (the first tick of its interval
lands after the first DDL event on Windows), the extra region keeps WAL
objects from being collected or shows up in the WAL snapshot.
Record no events in these tests.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* feat(mito2): add shared SST storage and reclamation foundations
Add shared-level isolation, receipt replay and recovery, migration support, and fail-closed file protection. Keep coordinator submission and verified publication in the next stack layer.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): isolate table compaction manifest semantics
Keep atomic manifest extension envelopes and lifecycle safety in the common engine. Gate table-specific receipts and remap admission with enterprise, preserving their wire format and rejecting unsupported state before replay or GC.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): remove manifest-backed compaction task state
Keep file-only edits, shared-reference admission and GC safety. Task retries no longer require persisted receipts or task epochs; reject unpublished prototype task-state records rather than silently dropping them.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): guard staging manifests and reclaim shared range indexes
Reject prototype task state when decoding staging blobs, matching checkpoint and delta decoding. Delete the region-scoped range index when a shared SST reference is retired, while leaving the shared object to global GC. Document the level-2 merge-split rationale and bind the delta guard's action tag with a test.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): simplify GC deletion and lingering rules
Require unknown files in a directory without a manifest to pass the lingering window before deletion, so an unpublished table-compaction output cannot be reclaimed out from under an active attempt. Replace the per-batch deletion loop with a single publication recheck taken before remote deletion, and drop the batching constant, the deferred-deletion accounting, and their test.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): keep regions open after manifest validation rejection
Classify InvalidRequest from pre-write applicability checks as definitely not persisted. Cover both shared-removal and unsupported-level rejections without stopping the manifest manager, while keeping ambiguous storage errors conservative.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): reject ambiguous shared SST reclassification
Reject edits that both add a shared SST and remove the same file ID before admission and under the manifest lock. Keep ordinary edit semantics and verify add-only L0 reclassification survives reopen without diverging from the live Version.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* test(mito2): define truncate semantics for shared SST references
Keep explicit truncation applicable to shared references and document the distinction from physical reclamation. Exercise full and time-range truncation with real shared SSTs, an old query, another referencing region, and reopen.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): define shared copy results and reject metadata imports
Document copied_file_ids as installed logical references, including no-op retries. Reject shared SSTs in metadata-region copies before copying any objects or changing the target, and cover shared, mixed and repeated copy behavior.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* style(mito2): unify shared SST level references and bounds docs
Use module-qualified shared-level constants consistently and document MAX_LEVEL as an exclusive bound for SST version operations. No runtime behavior changes.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): move the shared SST level to a max sentinel
Use the u8 maximum as the shared classification so future ordinary levels can never collide with it, and map wire levels to fixed storage slots instead of indexing by value. Shared metadata, admission and filters keep their semantics; unallocated levels stay rejected.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): keep dropped-region tombstones while files are deferred
Young unknown objects and hook-protected candidates on a dropped region must report needs_retry so the meta tombstone survives until they are actually reclaimed; reporting success would let the procedure drop the tombstone and orphan the retained objects. Cover both deferral paths plus the eventual clear.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): reject adopting an existing L1 SST as shared
Adopting a shared reference is L0-only: the manifest would replace an existing L1 entry while the live version keeps both handles, duplicating rows until reopen. Reject the edit at admission before any state change and cover the rejection with a real SST.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
---------
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): keep rows written during staging in the WAL
A flush during staging committed its SSTs to the staging manifest, then
dropped the memtable and released the WAL. If staging did not end
successfully those rows were gone. A flush that committed after staging
had ended lost its rows even though staging succeeded.
Staging regions no longer flush. They are skipped by memory-pressure,
periodic and region-limit flushes, and their writes are rejected instead
of queued at twice the region limit or when the node's staging memtables
reach half of the engine's flush limit. A manual or repartition flush on
a staging region with data gets a retryable error; the migration
pre-flush and the WAL prune flush reply success without flushing. Closing
a staging region leaves staging first, so skip-WAL rows are flushed to
the normal manifest.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): keep accounting and closing staging regions during staged edits
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): track staged edits without relying on the partition info
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): synchronize staging close tests with worker admission
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): observe the manifest lock wait when closing staging regions
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): detect staged edits through the staging partition info
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs(mito2): record that staging regions must not flush
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): do not restore staging after a close abandons the edit
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): reject region edits during a close-time flush
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* style(mito2): format the staging tests
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): reject staging edits once staging is abandoned
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): bind apply-staging edits to their partition expression
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs(mito2): note that staging regions pin their topic's prune point
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
---------
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor(log-store): extract shared WAL reading helpers
Move object indexing, chain traversal, history checks, segment prefetching and object I/O out of the writable store. Preserve local recovery and read policies.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* refactor(log-store): separate read-only WAL object access
Introduce WalObjectRead as the read capability shared by indexing and prefetching. Keep writes and startup listing on WalObjectIo, and adapt writable-store test doubles without changing their behavior.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* feat(log-store): add a read-only object store WAL reader
Validate source identity with NodeWalPrefix and share readers by source. Read known-last-entry or listed ranges using fresh listings and bounded footer concurrency, without holding the cache lock across I/O.
Evict indexes outside the current listing, keep release extraction in startup recovery, and cover bounds, history, cache lifetime, prefix validation and concurrent reads.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(log-store): coalesce remote WAL footer loads with shared cache
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(log-store): report missing source WAL history separately
Signed-off-by: WenyXu <wenymedia@gmail.com>
* test(log-store): cover remote WAL chain and listing boundaries
Signed-off-by: WenyXu <wenymedia@gmail.com>
* test(log-store): wait for asynchronous WAL index release
Signed-off-by: WenyXu <wenymedia@gmail.com>
* test(mito2): align WAL recovery assertions with shared history messages
Signed-off-by: WenyXu <wenymedia@gmail.com>
---------
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(mito2): publish manifest deltas by conditional create under a lease
A late old leader and the region's new holder can commit the same manifest
version. For a region whose writes require a lease and whose WAL is the object
store WAL, the manifest now behaves as follows. Every other region keeps its
behaviour and issues no extra request.
- Each delta has one fixed name, `{version:020}.json.gz`, written by a
conditional create. Without `compress_manifest` the delta is written at gzip
level 0, so that all writers share the name.
- On an existing object, the writer reads it from storage: identical content is
a retry of a write that landed, anything else is a retryable
`ManifestVersionConflict` that keeps the output files.
- The version advances only after a successful save.
- Recovery loads the highest checkpoint found by LIST and uses the checkpoint
pointer only for its checksum, because a stale writer's checkpoint task can
leave the pointer at an older version.
- Checkpoint cleanup frees names, so a late create can still succeed on a
deleted name. A commit whose save returns after the region's Leader deadline
lists the checkpoints once: a checkpoint at or above its version, or a LIST
error, is a conflict; otherwise it applies but starts no checkpoint. A commit
within the deadline does one conditional PUT and no LIST.
`RegionManifestManager::update` becomes the one commit entry and takes
`allow_checkpoint` and `must_verify` as required parameters. A backend that does
not declare conditional create is refused at open.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): treat every LIST error as a conflict when verifying a commit
The listing helper turned a NotFound from lister creation into an empty result,
so the check after a late commit could read a failed LIST as proof that no
checkpoint covers the version. List the checkpoints directly, so that any LIST
error reaches the caller. Recovery still treats a missing directory as having no
checkpoint.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): keep the LIST failure in manifest conflicts and follow the style guide
A failed LIST during commit verification was reported as "OpenDAL operator
failed", because the conflict reason used the display of the wrapper error.
Report the root cause through `output_msg` and assert it in the test.
Align the change with docs/style-guide.md: name boolean methods `is_*`, name
the listing helper `list_highest_checkpoint` and move it after the public
methods, qualify `encode_gzip_stored` through its module, and name the mode
setter after the field it sets, which is now `pub(crate)`. Move the shared test
helpers to `crate::test_util` and `manifest/tests/utils.rs` so that the manifest
test modules stay private.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): order the manifest test helpers public before private
Move the private `NotFoundReader` and `CheckpointTaskBlocker::block_write`
below the public items next to them, and document
`fail_manifest_delta_reads_layer`.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): fail recovery when a listed checkpoint disappears
Recovery treated a checkpoint that LIST found but that cleanup removed before
the read as no checkpoint at all. It then replayed from the first version over
deltas that were already deleted, and could report an empty region or build a
manifest from the surviving tail. Return a retryable version conflict instead.
Record the size of the stored object when a retry finds an identical delta, as
the other writer may have encoded it differently. Reopen the region in the test
of a commit that crosses its deadline, and reduce the AGENTS.md entry to the
invariant.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): verify conditional commits from callers without a deadline
Restore `RegionManifestManager::update(action_list, is_staging)`. Without a
Leader deadline a caller cannot show that its commit returned in time, so a
normal commit under conditional publication is now always verified on this
path and starts no checkpoint.
Only `ManifestContext::update_locked` has a deadline, so the variant that takes
`allow_checkpoint` and `must_verify` becomes `update_with_verification` and is
crate private. `sst-replace` and the existing tests return to the two-argument
call.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): name the verifying manifest update in the hook docs
`ManifestContext::update_locked` now calls `update_with_verification`, and the
public `update` also calls it, so neither doc can call `update_locked` the sole
caller of `RegionManifestManager::update`.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): keep the conditional publication rule in region options
Move the rule that decides which regions publish manifests conditionally
to RegionOptions, so the manifest options only hold the result. Report a
checkpoint that vanished after LIST with its own error instead of a
version conflict, and keep the stored gzip encoder with the other
CompressionType helpers.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
---------
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
A prepared statement keeps its logical plan, and that plan holds the
table as it was at prepare time. The analyzer reads the partition
columns from that table while the regions to scan come from the current
route. After a table's partition columns change, the analyzer can
consider a query safe to push down, so each region runs the whole query
and the frontend concatenates their results. The same happens to the
source of a prepared INSERT ... SELECT, which then stores wrong values.
Before executing a kept plan, compare each scanned table's partition
columns with the current table found by id. Scans of a table whose
columns changed get the current table when the schema is unchanged.
Otherwise they keep their schema, because a scan's projection holds
indices into it, and report the current columns as absent from it, so
the query keeps merging on the frontend.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* perf(mito2): reuse static manifest checks for cached readers
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test(mito2): drop redundant pruner test and release entry lock early
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* perf(mito2): cache static manifest keep verdicts directly
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
---------
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>