* fix(config): redact credentials from diagnostic TOML
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(config): redact credentials at their owning fields
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(config): cover skipped SAS tokens and export logs
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(cli): mask SAS tokens before overlapping account names
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(cli): redact SAS tokens before overlapping account fields
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(cli): mask containing credentials before shorter values
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
---------
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(mito2): commit staging edits once when staging ends
Staging edits (the new partition expression, the imported files) were saved
as deltas in the staging directory, each taking a manifest version. The end of
staging listed that directory and merged every delta it found, including
deltas a stale writer wrote late.
Staged actions now stay in memory and take no version. The end of staging
commits them once, as the next version, in a new EndingStaging state that
stalls writes and holds role changes back until the commit returns. If the
commit may have been written and the region stays staging, the encoded commit
is kept: a retried request stages nothing new and commits the same content,
and other staged edits are refused with a retryable error meanwhile.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): settle an uncertain end of staging before later commits
Under overwrite publication a save that may have landed must not be
overwritten, so every commit takes its version before the save and a failed
save leaves that version unused. For the end of staging, the version is now
taken only once the result is known: a failed save is read back at once, and
if the read-back cannot tell, the commit stays unsettled. Every later commit
first reads it back again, applies it to the manifest and the region version if
it landed, and is refused with a retryable error while it still cannot tell.
A follower sync past that version forgets it.
Committed staging actions are applied to the region version through the
manifest context, so the end of staging and a later commit that settles it
share one path.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): settle before checking a commit and keep the lock into the end of staging
- Settle an unknown end of staging when taking the manifest lock, before the
write is checked against the manifest, and fire the hook of a landed one
with the lock released, so a failing commit cannot drop it. Entering staging
settles too; a staging region settles only when staging ends.
- Pass the held manifest lock from the graceful Leader path into the end of
staging, so a queued close cannot abort staging in between.
- Wait for the worker to drain the stalled writes before clearing the staging
directory.
- Let an empty import retry a frozen end commit.
- Count the size of an end delta found by reading it back.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): keep settling out of staging and before a new staging
- Do not settle while the region is staging or a staged edit is running; only
the end of staging settles there, as it also leaves staging.
- Settle before entering staging through a graceful role change, and fire the
hook of a landed result even if entering staging then fails.
- List the end-of-staging outcomes in the order they are decided.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): settle before the metadata backfill and fence the late staging clear
- Settle an unknown end of staging before a graceful Leader on a writable
region checks whether to backfill metadata; a landed result is merged into
the backfill notification.
- Skip the staging directory clear after the end of staging if the region was
closed meanwhile, as it may be open and staging again.
- Clear the staging directory after an end of staging with nothing to commit.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): take the overwrite version before the end of staging is saved
Under overwrite publication the end of staging takes its version before the
save again, as before this change, so a later commit never overwrites a save
that may have landed. After an error that may have written it, the region goes
back to staging with its staged actions and encoded bytes kept, and the retry
writes the same bytes at the next version; a reopen replays both as one commit.
This removes the immediate read-back of a failed end commit, the unsettled mark
and the settling before later commits, the ManifestUnsettled error, and the
region version handle on the manifest context. The end of staging applies the
committed actions to the region version itself again.
A graceful Leader from staging takes the manifest lock again after the end of
staging and runs the metadata backfill, firing one notification for both, as
before this change.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): check the lease and fence conflicts in the end of staging commit
The end of staging commits its staged actions on its own path, so it
skipped the checks other manifest commits make: in conditional
publication it saved after the Leader deadline had passed, and a version
conflict left the region unfenced, so the worker never reloaded it. Run
both commits through one core that makes those checks.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor(mito2): let the worker pass the drain to the end of staging
The end of staging built and sent the worker's StagingEnded notification
itself, so the region module depended on the worker's dispatch types.
The worker now passes the drain as a future that the end of staging
awaits after it drops the manifest lock.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): keep the write order across the end of staging
The end of staging stores the region's next state under the manifest
lock, and the worker handles the writes it stalled meanwhile later, on
StagingEnded. A write that the worker took in between was applied
before the earlier stalled ones. The worker now stalls a region's later
writes behind those until StagingEnded drains them.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* perf(mito2): read and encode the staged actions without copying them
The end of staging copied the staged actions to read them, to encode
them and to commit them. Read and encode them in place, and copy them
for the region hook only when one is registered. The commit keeps its
own copy, so the staged actions survive a failed commit for the retry.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): cover a flush while staging ends and the staging directory clear
Check that a migration flush gets a retryable error while the region
ends staging and succeeds after it. Plant a delta from an older binary
in the staging directory before applying the staging manifest, so the
check that the directory is cleared looks at the target region and
fails if the end of staging leaves it.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* chore(mito2): tidy the end of staging wording and a test helper
Nothing is merged at the end of staging any more, so its log, error
reasons and bindings say staged or committed. Fix the region hook doc
sentence and table cells for actions staged in memory, and move the
import helper of the conditional manifest tests next to the other
helpers.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): drop the staged files of a region that left staging
An end of staging that leaves for Follower or Downgrading kept the staged
actions in the manager, and the SST listing and all_manifest_files merged
them into the files of a region that never committed them. The end of
staging now drops them when it leaves staging, and both readers merge the
staging manifest only while the region is staging.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* perf(mito2): check a resent import against the staged files in linear time
The check that a resent import only adds files that are already staged
walked every staged edit for every file, quadratic in the file count. It
now collects the staged file ids into a set once.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* perf(mito2): apply the committed staged actions without another copy
The end of staging cloned the staged actions to split them for the region
version before the commit, on top of the copy the commit applies. The
commit now hands the staged list back once it succeeds, and the end of
staging checks the staged Change by reference before the commit and splits
the returned list after it. One copy stays, because a successful commit
uses the actions twice: a copy builds the new manifest, and the returned
list updates the region version. The region hook gets its copy only when
one is registered, as before.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* chore(mito2): return the normal version from all_manifest_files and drop a dead fallback
all_manifest_files preferred the staging manifest's version. It now returns
the normal version, as its doc says. A test helper's unreachable
`unwrap_or(path)` after `rsplit` becomes `unwrap_or_default()`.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor(mito2): name the staging helpers after what they do
- Rename is_staging_or_staged_edit to in_staging_session. The Staging and
EndingStaging pair lives in RegionRoleState::in_staging_session, which the
compaction scheduler, region_role, should_abort_index and the region-level
helper use.
- Rename finish_ending_staging to leave_ending_staging, since it can also
land on Follower, Downgrading or Staging, and tie end_staging,
EndingStaging and StagingEnded together in the EndingStaging doc.
- Rename contains_import to only_adds_staged_files and the staged list
field to actions.
- Move the staging paragraph to the public update(), state on end_staging
that the drain is never awaited under the manifest lock, say when
all_manifest_files merges staged files, say that the listings do not rely
on the clear at the end of staging, and count the end of staging in the
flush rule of the mito2 AGENTS.md, naming the predicates the flush paths
test.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor(mito2): keep the end-of-staging drain next to the stalled requests
Move drain_ended_staging into worker.rs, and the set of regions whose writes
wait for it into StalledRequests, which adds, checks and removes them, so
the stall bookkeeping and its release live together.
Rejecting all stalled writes now also forgets these regions. Their stalled
writes are rejected with them, so a later write has nothing to keep order
behind and is handled under the region's current state.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor(mito2): keep the staged view with the staged actions
The manifest with the staged actions applied was a separate field of the
manager, set and cleared next to the actions by hand. It is now a field of
StagedActions, so clearing the staged actions clears it as well, and its
accessor says what it returns.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor(mito2): split EndStagingPending out of RegionBusy
A staged append that arrives while a possibly written end commit waits for
its retry was refused with RegionBusy, which therefore had to be in the
not-written arm of may_have_persisted_manifest_update for every producer.
It now gets EndStagingPending (status RegionBusy, retryable), which alone
takes that place, and RegionBusy keeps its earlier classification.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): cover regions that are ending staging
Check that a region ending staging reports the StagingLeader role and skips
compaction scheduling, and that its bulk writes stall, as do later ones
behind them after staging ended, until the worker drains them. Share the
stall wait and the StagingEnded drain between the tests.
The tests wait for these stalls through a listener on their own engine, so
the end-of-staging stalls notify the test listener as the write buffer
stalls do, and CountingStallListener moves to the shared test listeners.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
---------
Signed-off-by: jeremyhi <fengjiachun@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>
* 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>
Expose live compaction tasks through the datanode inspection path with
node pruning, lazy projected batches, and residual SQL filtering. Reuse
inspection request and plan helpers across compaction and SST tables.
Cover routing, projection, predicates, and lifecycle behavior in datanode,
standalone and distributed integration, and SQL tests. Use the production
information extension in the standalone test fixture.
Signed-off-by: WenyXu <wenymedia@gmail.com>