Add bounded progressive split requests and validated outcomes, with engine and metric-engine forwarding and a dedicated client RPC. Keep ordinary sketch queries unchanged and validate controls before acquiring region snapshots.
Signed-off-by: WenyXu <wenymedia@gmail.com>
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>
* feat(log-store): fence object store WAL I/O and recovery
Signed-off-by: WenyXu <wenymedia@gmail.com>
* feat(datanode): bind object store WAL I/O to node leases
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(log-store): scope lease fencing to pre-enablement support
Signed-off-by: WenyXu <wenymedia@gmail.com>
* feat(datanode): wire node lease fencing behind a cluster WAL gate
Signed-off-by: WenyXu <wenymedia@gmail.com>
* refactor(wal): clarify fixed object-store directory generation
Use a deployment-neutral name for the directory generation shared by standalone and distributed WAL stores. Keep the value and persisted prefixes unchanged.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(log-store): refine node lease expiry and retry handling
Report stop failures only for discarded backlog, preserve retry counts for unissued creates, and request route refresh on lease expiry. Install I/O permits once, clarify shutdown semantics, and log permission transitions. Add deterministic regressions for stopped probes and lazy delete polling.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(log-store): observe WAL I/O permission availability
Report unavailable and available permission transitions at info level without treating the first grant as an expired lease. Track unavailable actors with a gauge that is cleared on recovery and exit, and cover repeated checks, both ack modes, and stop/drop cleanup.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* docs(log-store): document WAL permission availability gauge
Describe first-grant, idle, recovery and exit accounting in the RFC and align metric help terminology with the other object store logstore metrics.
Signed-off-by: WenyXu <wenymedia@gmail.com>
---------
Signed-off-by: WenyXu <wenymedia@gmail.com>
* feat(meta-srv): bind candidate region leases to the migration's registration
A region migration now gives its candidate region registration a random non-zero
candidate lease id. Leases granted because of that registration carry it, but only
while the table route exists, and the upgrade instruction carries the same id. The
datanode passes the id of each lease to the engine, and Mito records the lease of
the latest heartbeat per region outside the region instance, so it survives a
reopen during catchup.
The migration also drops the candidate registration before it restores the route
on rollback, and before the procedure leaves the migration tracker when it ends
without a rollback.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): record a lease only while the region stays open
Record a granted lease under the same lock that removes it after the region closes, so a lease recorded during a close does not outlive the region. The metric engine records the data region's lease when the metadata region ignores it. Remove the roles-only extraction of operating regions, and cover a present candidate lease id in the upgrade JSON.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* build: point greptime-proto at the candidate lease id change
Use the greptime-proto commit that adds GrantedRegion.candidate_lease_id (greptime-proto#357), which also brings in the RawSeriesSource Substrait payload message. Rely on the declaration order of RegionMigrationProcedure to drop the candidate registration before the tracker entry, and document it.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(mito2): drop lease records when workers stop
Remove the lease records of the regions a stopping worker closes. Check under the removal lock deterministically in tests, cover a lease that arrives after a region is removed, assert the candidate lease id on the migration's real registration and its retry, and match ids per region in a batched upgrade.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(mito2): drop a redundant helper comment
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(store-api): pin the candidate lease id wire bytes
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs: document candidate registration and lease record lifecycles
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix: keep candidate lease ids through customized lease renewers
The heartbeat handler now sets the candidate lease id of each lease a
customized renewer returns from the renewed region with the same id.
The metric engine records a lease for the data region only when the
metadata region ignored it, since the data region records its own
leases. The countdown reset command carries a named struct instead of
a tuple.
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test(metric-engine): cover a lease the data region ignores
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor: tighten lease id lookups and lease test assertions
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor: align lease naming and share the txn-observing kv backend
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor: tidy lease naming, docs and shared test helpers
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs: drop field comments that restate their names
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs: drop method comments that restate their names
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs: say which heartbeat a lease's send time refers to
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs: drop the reset deadline field comment
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* docs: state when an operating region's role and id reach a lease
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* chore: pin greptime-proto to the merged candidate lease id change
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* test: add the candidate lease id argument to the direct demotion test
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* refactor: order new keeper helpers after public items and test equal send times
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
---------
Signed-off-by: jeremyhi <fengjiachun@gmail.com>
* fix(telemetry): avoid spurious log directory error on first start
Since 0.2.4, tracing-appender prunes old log files when an appender
with max_log_files is built, and it lists the log directory before
creating it. When the directory does not exist yet, it prints "Error
reading the log directory/files" to stderr. GreptimeDB sets
max_log_files by default, so every start with a missing log directory
printed this line.
Create the log directory in build_file_appender before building the
appender. Creation errors are left to the appender build, which
reports them as before. Add a test that checks the stderr of a child
process.
Works around https://github.com/tokio-rs/tracing/issues/3612.
Signed-off-by: shuxiachai <shuxiachai@163.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(telemetry): drop the first-start log directory test
Review feedback: the test is not needed for such a minor change.
Restore the unix-only test imports that it had merged.
Signed-off-by: shuxiachai <shuxiachai@163.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Signed-off-by: shuxiachai <shuxiachai@163.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* test(recordbatch): compare float zero predicates with DataFusion
`SimpleFilterEvaluator` filters SST rows exactly, so it has to agree
with the SQL predicate that DataFusion evaluates above the scan.
DataFusion compares -0.0 and +0.0 as equal. Evaluate comparisons
against both zeros, NaN and NULL in Float64 and Float32 columns, and
check the selected rows against DataFusion's filter.
On main this fails: `v = Float64(0)` selects only the +0.0 row, while
DataFusion selects both zeros.
Signed-off-by: dayan02dev <pawarudayan92@gmail.com>
* fix(recordbatch): compare -0.0 and +0.0 as equal in simple filters
DataFusion 55 normalizes -0.0 to +0.0 before Arrow's comparison
kernels, so SQL compares the two zeros as equal. SimpleFilterEvaluator
called the kernels directly, and for floats they compare bit patterns:
-0.0 != +0.0 and -0.0 < +0.0. Mito applies the evaluator to SST rows as
an exact filter, so after a flush `v = 0.0`, `v >= 0` and `v IN (0.0)`
dropped the rows holding -0.0, and `v = -0.0` dropped the rows holding
+0.0. Rows still in a memtable matched.
Normalize the literal when the predicate is built and the input before
it is evaluated, with the helpers DataFusion uses for the same purpose.
Signed-off-by: dayan02dev <pawarudayan92@gmail.com>
* test(sqlness): cover flushed float rows holding -0.0
Flush rows holding -0.0, 0.0 and 1.0, then filter with `= 0.0`,
`>= 0`, `= -0.0` and `IN (0.0)`. Both zeros have to match every one of
them, as they do while the rows are still in the memtable.
Signed-off-by: dayan02dev <pawarudayan92@gmail.com>
---------
Signed-off-by: dayan02dev <pawarudayan92@gmail.com>
Co-authored-by: dennis zhuang <killme2008@gmail.com>
* feat(query): serialize remote dynamic membership
Recover single-column UTF-8 build-key membership from InList and HashTableLookupExpr producers and send it to remote datanodes using the existing PhysicalInListNode. Non-monotone or unsupported subtrees widen to true; the receiver keeps the live filter authoritative.
Signed-off-by: discord9 <discord9@163.com>
* refactor(query): send lookup membership as a key list
Serialize a HashTableLookupExpr as the existing PhysicalInListNode and preserve the rest of the expression tree. Remove per-subtree monotone and true rewrites; only an unrepresentable lookup or an over-budget payload falls back at the whole-payload level.
Signed-off-by: discord9 <discord9@163.com>
* docs: tighten narrow membership contract
Clarify that the key-list transport is a positive pruning hint, not universal Boolean equivalence, and test that a NULL probe survives the IS NULL wrapper.
Signed-off-by: discord9 <discord9@163.com>
* fix(query): retain safe bounds on membership fallback
When a key-list predicate cannot be shipped, keep top-level conjuncts that contain no membership and re-encode their conjunction. Drop membership-bearing conjuncts whole; fall back to true only when no safe bounds remain.
Signed-off-by: discord9 <discord9@163.com>
* fix(query): skip unrepresentable dynamic filter snapshots
Do not synthesize a true predicate when a runtime hash-table lookup has no wire representation. Capture and fanout skip the affected snapshot, keep the query running, and report PushedDown::No so the parent filter is retained. Safe membership-free conjuncts still travel, and a producer-supplied true remains encodable.
Cover restrictive-to-true updates, unsupported initial registrations with later supported updates, final unsupported cleanup, and NULL build keys.
Signed-off-by: discord9 <discord9@163.com>
* docs(query): clarify 642-key payload budget comment
Signed-off-by: discord9 <discord9@163.com>
* refactor(query): tighten dynamic membership encoding
Preserve static IN conjuncts when only a runtime lookup is unrepresentable, apply the IN-list exclusion only on the over-budget path, and derive the membership count guard from the byte budget before materializing literals. Document that decoded dynamic filters are pruning-only, fix the NOT/CASE contract wording, deduplicate test helpers, and justify the schema-less InList proto encoding.
Signed-off-by: discord9 <discord9@163.com>
* fix(query): reset stale dynamic filters on unsupported updates
Publish an explicit true reset when a producer generation cannot be carried, instead of leaving an older narrower predicate that could prune rows after widening. Keep the unsupported expression unrewritten; the reset is a transport-built invalidation. Type over-budget build-key memberships as DynFilterPayloadTooLarge, accept scalar-subquery IN lists under the conjunct-retention contract, and clarify the no-initial-predicate wording.
Signed-off-by: discord9 <discord9@163.com>
* docs(query): scope no-true rule to the encoder
Clarify that the encoder never substitutes true for a producer node, while the long-lived fanout path publishes an explicit true reset to invalidate a stale region predicate. Point at the fanout caller instead of claiming producers always skip refused generations.
Signed-off-by: discord9 <discord9@163.com>
* docs(query): correct reset wording
Fix the inverted conjunct-retention sentence and describe initial capture versus ongoing fanout resets consistently in the error docs.
Signed-off-by: discord9 <discord9@163.com>
---------
Signed-off-by: discord9 <discord9@163.com>
* feat(common-meta): make RDS metadata backends closable
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>
* fix(common-meta): close RDS connection pools on shutdown
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(common-meta): preserve closable RDS constructors and test shutdown semantics
Signed-off-by: WenyXu <wenymedia@gmail.com>
---------
Signed-off-by: WenyXu <wenymedia@gmail.com>
* feat(function): expose iceberg_hash and iceberg_hash_bounds SQL functions
`iceberg_hash` partition rules could not be evaluated from SQL, so users had no
way to measure a hash distribution or check which bucket a value falls into.
Expose the same UDF that partition rules plan, plus `iceberg_hash_bounds(n)`
which prints the equal-width breakpoints `bi = i32::MIN + floor(i * 2^32 / n)`
as text for copy-paste into `PARTITION ON COLUMNS`.
Both functions are immutable and read-only, and no persisted format changes.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(function): handle untyped NULL and small integer counts
`iceberg_hash(NULL)` arrived as ScalarValue::Null, which becomes a NullArray
that the shared array form had no arm for, so it failed with an unsupported-type
error instead of hashing to NULL. Add a DataType::Null arm in the shared
implementation, so both the SQL function and any future rule evaluation keep the
advertised NULL-to-NULL behavior.
`iceberg_hash_bounds` rejected Int8/Int16/UInt8/UInt16 constants even when the
value was a valid bucket count, because Signature::any leaves the argument width
unchanged. Accept every integer width like the existing Int32/Int64/UInt32/UInt64
arms, and cover them plus the untyped NULL case in unit and SQL tests.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* feat(function): add iceberg_hash_breakpoints SQL function
Equal-width `iceberg_hash_bounds(n)` buckets cannot follow a key distribution:
a handful of hot keys can still land in one bucket, and a uniform split keeps
hashing them together. Add `iceberg_hash_breakpoints(v1, v2, ...)`, which takes
any number of constant values in any order (one shared hashable type, exactly
the values a partition rule compares the hashed column against), hashes them
through the shared implementation, and prints them sorted and deduplicated:
SELECT iceberg_hash_breakpoints('iceberg', 34);
-- 1210000089, 2017239379
The output drops straight into the breakpoint list of a `PARTITION ON COLUMNS`
rule, so buckets can be placed around known key values instead of equal widths.
Columns and NULLs are rejected with explicit errors: a column cannot be hashed
at planning time, and a NULL hash never matches a comparison bound, so a NULL
value cannot be a breakpoint (NULL rows always fall in the lowest bucket).
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* feat(function): add iceberg_hash_ranges_sql SQL function
The helpers so far print bare breakpoint numbers, so a user still had to expand
them into comparison rules by hand: n buckets mean n rules with up to
2n - 1 `iceberg_hash` call sites. `iceberg_hash_ranges_sql(column, n)` renders
the whole list from the same equal-width breakpoints:
SELECT iceberg_hash_ranges_sql('host', 2);
-- iceberg_hash(host) < 0,
-- iceberg_hash(host) >= 0
The output drops straight into the expression list of `PARTITION ON COLUMNS`
(rule per line). It only renders text; it does not create or change partitions.
The breakpoints come from the shared `IcebergHashBoundsFunction` logic, so the
rendered rules and `iceberg_hash_bounds(n)` always agree. NULL name or bucket
count propagates as NULL; columns, non-string names, empty names, out-of-range
counts and wrong arity are rejected with explicit errors.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(function): include function identity in ScalarUdf equality
The ScalarUdf wrapper compared and hashed only the signature, so any two
functions sharing a signature were the same ScalarUDF: isnull, iceberg_hash
and iceberg_hash_bounds all have Signature::any(1, Immutable) and compared
equal. DataFusion compares expressions structurally, and its SQL planner
rewrites SELECT expressions against GROUP BY keys with base_exprs.contains
(rebase_expr); the collision made SELECT isnull(x) FROM t GROUP BY x,
iceberg_hash(x) fail planning, because isnull(x) matched the grouped
iceberg_hash(x) and was rewritten into an aggregate column that does not
exist.
Compare and hash the function name alongside the signature, so functions are
distinguishable while two instances of the same function still compare (and
hash) equal.
Add regressions: same-signature functions stay distinct ScalarUDFs and stay
separable in hash-based containers, and grouping by one while selecting the
other plans and executes in both directions.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(function): quote rendered column names and reject mixed hash domains
`iceberg_hash_ranges_sql` interpolated the column argument verbatim, so a
legal name such as `host-name` produced `iceberg_hash(host-name)`, which parses
as a subtraction; names with spaces, dots, quotes or upper case could not be used
either. Quote the name as a SQL identifier and double embedded quotes, so the
rendered rules stay one identifier and survive parsing. Cover the round trip by
feeding the output back into `CREATE TABLE ... PARTITION ON COLUMNS` for plain,
dashed, upper-case, quoted and spaced names.
`iceberg_hash_breakpoints` accepted values of different types, but strings and
integers hash through different encodings (UTF-8 bytes versus Iceberg longs), so
mixing them yields breakpoints that describe no real column. Require one hash
domain (all strings or all integers, integer widths may mix) and name the
offending argument otherwise. The existing SQL case that mixed
`('iceberg', 34)` now uses two strings.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(function): register the raw hash UDF and tidy the helpers
Registering `iceberg_hash` through a `Function` wrapper built a different
`ScalarUDFImpl` type from the one partition rules plan, so DataFusion compared
the SQL expression and the rule expression as unequal; the wrapper also rebuilt
a `ScalarUDF` per batch. `ScalarFunctionFactory` already has `From<ScalarUDF>`,
so register `iceberg_hash_udf()` directly and add a test that the registered
function and `IcebergHash::to_logical_expr` produce equal expressions.
Also: collapse the arity check and slice destructuring into one `let ... else`;
make the bucket-count helpers associated functions instead of constructing a
`default()` instance; pass the caller name through so an error raised from
`iceberg_hash_ranges_sql` names that function rather than
`iceberg_hash_bounds`; and fetch the SQL test's UDFs from `FUNCTION_REGISTRY`
instead of rebuilding and wrapping each one.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(function): accept every string column name and cover the rules end to end
`iceberg_hash_ranges_sql` matched only `Utf8` and `LargeUtf8` for its
column-name argument, so a valid constant string that arrives as
`Utf8View` (for example `arrow_cast('host', 'Utf8View')`) was rejected as
non-string. `Signature::any` leaves argument types unchanged, so the function
has to accept all string representations itself; use `ScalarValue::try_as_str`
and keep the NULL and empty-name checks. A unit case and a SQL-level case pin
that `Utf8View` renders the same rules as a plain literal.
Add a sqlness case that renders the four buckets for the quoted column
`"host-name"`, creates the table from that exact text, inserts one value per
bucket plus NULL, and checks the row counts implied by the rendered predicates
against the rows each region stored. This closes the gap between rendering the
rules and routing rows with them.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(partition): hash constants through IcebergHash::evaluate_array
`iceberg_hash_values` duplicated `IcebergHash::evaluate_array` line for
line. Call the existing method from `into_hashed_scalar` and drop the extra
public entry point, so the SQL helpers still hash through the code a partition
rule evaluates without a second identical API.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
---------
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* 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>
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>
* 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(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>
* 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>
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>
* fix(function): require ADMIN statement privileges to execute admin functions
Read-only accounts could execute the admin UDFs (flush_table,
compact_table, flush_flow, gc_regions, migrate_region, reconcile_*,
build_index, ...) through ordinary SELECT statements: SELECT is a
read-only statement so it passes the statement-level privilege check,
and the functions were only guarded by the greptime-catalog scope
check inside the UDF. That let read-only users trigger WAL flushes,
manifest version bumps, compactions, flow-sink writes and, in
distributed mode, region GC/migration and SST deletion.
Wrap the privilege check into the admin_fn macro itself, next to the
existing greptime-catalog check: before executing, every #[admin_fn]
function now requires the same privileges as its ADMIN statement. The
check synthesizes the PermissionReq::SqlStatement request an
ADMIN <fn>(...) statement produces and evaluates it with the same
PermissionCheckerRef plugin the frontend installs, so query invocation
(SELECT <fn>(...), EXPLAIN, views, flows) and the ADMIN statement path
are gated identically — in particular read-only accounts are denied
with PermissionDenied (7006), while write-privileged users keep both
invocation styles. With auth disabled (no permission checker), the
functions stay invocable by everyone, exactly like ADMIN statements.
The denial is wrapped as External(BoxedError) so the 7006 status code
survives both the query execution path and the admin statement
executor.
Regression tests: unit tests for the check (no-checker allows,
read-only denied 7006, read-write allowed), an end-to-end test over
the macro-generated flush_table UDF, and an integration test where a
read-only account is denied 7006 on all 13 functions from SELECT while
a read-write account keeps SELECT and ADMIN FLUSH_TABLE working.
Signed-off-by: Ning Sun <sunning@greptime.com>
* fix(function): expose admin privilege check to downstream macros
Signed-off-by: Ning Sun <sunning@greptime.com>
---------
Signed-off-by: Ning Sun <sunning@greptime.com>
* feat(otlp): persist metric exemplars
OTLP metric conversion now emits exemplars through the shared storage contract. It validates timestamps, IDs, values and label budgets, and associates histogram exemplars only with emitted buckets that contain their values. Invalid observations are dropped and counted while valid points and siblings remain ingestible.
Frontend ingestion authorizes the emitted destinations and retains confirmed completions across metric and exemplar writes, including logical-table batching. Includes conversion and schema-failure isolation tests; tests that also query the new Prometheus endpoint land in the final layer.
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
* feat(otlp): bind exemplars to source metric identities
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
* fix(otlp): bound exemplar memory and preserve series
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
* fix(otlp): skip exemplars without metric engine
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
* fix(otlp): skip exemplars for ordinary tables
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
* refactor(exemplar)!: prefix the shared table name
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
* fix(otlp): avoid waiting with body permits held
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
---------
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
Add a loader registration hook to TriggerDdlManager and invoke it
before procedure recovery. Test that registration reaches the
configured trigger DDL manager.
Signed-off-by: fys <fengys1996@gmail.com>
* feat: share streaming range results across scans
Share post-merge range batches across concurrent readers while preserving stream boundaries, cancellation and retry behavior. Encapsulate range ownership, compaction and publication in RangeResultCache, backed by the common SyncCache primitive.
Retain SST retirement fencing and memory accounting. Track live shared-buffer bytes and worker events alongside existing cache metrics.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* fix(mito2): clean up shared range registrations on release
Signed-off-by: WenyXu <wenymedia@gmail.com>
---------
Signed-off-by: WenyXu <wenymedia@gmail.com>
* feat: add relational region engine skeleton and registration
Add a read-only relational RegionEngine (create/open/drop lifecycle) and register it as the 4th engine in build_store_engines alongside mito/metric/file. Add a datanode-level test asserting all 4 engines are registered.
Signed-off-by: tian1220A <1573612521@qq.com>
* feat: add relational connection and idempotent region lifecycle
Move ConnectionInfo into relational-engine (DSN parsing + redacted rendering), place the RelationalOptions/RELATIONAL_META_KEY serialization contract in table::requests, make CREATE idempotent by comparing the persisted manifest definition against the incoming request (RegionExists on mismatch), and drop the empty EngineConfig placeholder.
Signed-off-by: tian1220A <1573612521@qq.com>
* refactor: address review comments on relational region engine
- remove connection.rs (only used by its own tests); it will be
reintroduced when connection handling is wired up
- drop RelationalOptions::version (not validated or used to select a
deserialization format)
- validate an idempotent create against the existing region definition
(region id / schema / primary key / options) and return Unexpected on
mismatch, with a reason field on RegionExists
- use serde.workspace and remove the empty [features] section
- cargo fmt
Signed-off-by: tian1220A <1573612521@qq.com>
* fix: adapt relational engine to latest main
- implement RegionEngine::set_region_role_with_lease (no-op lease, the
engine takes no writes so no lease is needed)
- pass node_id to build_object_store_manager in the registration test
- drop stale url dependency from the relational-engine lock entry
Signed-off-by: tian1220A <1573612521@qq.com>
* ci: register relational-engine in scope rules
Signed-off-by: tian1220A <1573612521@qq.com>
* fix: remove table self-dependency from Cargo.lock
Signed-off-by: tian1220A <1573612521@qq.com>
---------
Signed-off-by: tian1220A <1573612521@qq.com>
Select Discard or Detach when submitting children via Status::Suspended.
Persist the policy from the child's first normal or rollback checkpoint.
Recover detached children as independent roots with their original id and
context, using existing execution and cleanup without rebuilding the graph.
Keep fresh root admission serialized while allowing accepted procedures to
recover above the submission limit. Cover first persistence, repeated
recovery, rollback, cleanup, defaults, and concurrent admission.
Signed-off-by: WenyXu <wenymedia@gmail.com>
* feat(partition): support iceberg_hash in partition rules
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(partition): reject partition column type changes and quote rule identifiers
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(table): keep time index widening for partition columns
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* refactor(partition): replace PartitionFunction with IcebergHash
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs(partition): describe iceberg_hash in the function module
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(meta): validate iceberg_hash partition bounds on ALTER and trim comments
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test: quote partition rule identifiers in SHOW CREATE TABLE expectations
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test(partition): check hash rules in information_schema and repartition target columns
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(partition): coerce hash partition rules against the evaluation schema
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(partition): keep quotes in partition column names when building filters
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
---------
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>