Commit Graph
6784 Commits
Author SHA1 Message Date
aumnertic 510ceae638 merge: sync the SST listing test into aggregate execution
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 01:41:51 -05:00
aumnertic 7de6b41847 merge: sync the SST listing test into partial COUNT
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 01:41:51 -05:00
aumnertic 382f829aa2 test(mito2): verify listed SST sizes against object storage
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 01:41:24 -05:00
aumnertic ea869b4735 merge: sync partial COUNT changes into aggregate execution
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 00:43:11 -05:00
aumnertic 782bcfa352 merge: preserve the published partial COUNT branch history
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 00:35:44 -05:00
aumnertic 979dc5d3a0 merge: sync replacement validation into partial counts
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 00:28:37 -05:00
aumnertic 0f4dd2e901 refactor(cmd): reuse the replacement SST reader during validation
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 00:28:33 -05:00
aumnertic 66034d69e4 merge: sync partial metadata counts with the SST replacement fix
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 00:22:54 -05:00
aumnertic 42517b37e3 fix(mito2): keep SST replacements coherent with metadata counts
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-26 00:22:42 -05:00
aumnertic 6c7fe85e91 test(mito2): check scan names in partial COUNT fallback
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 23:29:53 -05:00
aumnertic 1b5fa8d082 test(mito2): match displayed scan names in COUNT fallback
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 23:29:49 -05:00
aumnertic 81df9c9e66 fix(mito2): carry owned SST input checks into partial counts
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 23:24:12 -05:00
aumnertic e9db5f339a fix(mito2): own SST inputs to asynchronous bound checks
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 23:24:08 -05:00
aumnertic 08796fb31f fix(mito2): verify residual SST bounds for partial counts
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 23:19:37 -05:00
aumnertic ad73c8dff6 fix(mito2): verify SST time bounds before metadata count
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 23:18:55 -05:00
aumnertic a27250ff7d test(mito2): cover stale SST bounds in residual scans
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:44:00 -05:00
aumnertic b935655ecb feat(mito2): split metadata COUNT from residual scans
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:43:48 -05:00
aumnertic c74862720f fix(mito2): validate SST key bounds before metadata count
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:43:35 -05:00
aumnertic c9172e25ca Merge branch 'refs/heads/review/metadata-count-partial' into review/metadata-count-aggr-exec
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:09:32 -05:00
aumnertic 882a5d0076 fix(mito2): retain decoded byte accounting for frozen memtables
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:09:30 -05:00
aumnertic f31922cc93 Merge branch 'refs/heads/review/metadata-count-partial' into review/metadata-count-aggr-exec
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:04:10 -05:00
aumnertic dd8a1a7589 Merge branch 'refs/heads/feat/non-append-metadata-count' into review/metadata-count-partial
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:04:10 -05:00
aumnertic d0df9854a8 test(mito2): use valid sequence fences and SST owners
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 22:04:07 -05:00
aumnertic 7b227596c6 Merge branch 'refs/heads/review/metadata-count-partial' into review/metadata-count-aggr-exec
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:58:21 -05:00
aumnertic 351fbabb4e Merge branch 'refs/heads/feat/non-append-metadata-count' into review/metadata-count-partial
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:58:21 -05:00
aumnertic bee6953670 fix(mito2): keep lazy footer reads sendable
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:58:09 -05:00
aumnertic 8afbc0ed51 test(mito2): verify tightened partition bounds and source estimates
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:57:38 -05:00
aumnertic 5d5fa0c5fc Merge branch 'refs/heads/review/metadata-count-partial' into review/metadata-count-aggr-exec
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:53:05 -05:00
aumnertic 26037763c8 Merge branch 'refs/heads/feat/non-append-metadata-count' into review/metadata-count-partial
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:53:05 -05:00
aumnertic c0876c3fc8 test(mito2): add SQLness coverage for the SST footer marker
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:50:38 -05:00
aumnertic 711b03a6c7 Merge current metadata COUNT proof into aggregate execution
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:49:18 -05:00
aumnertic 6aa29b4e02 Merge metadata COUNT core fixes into partial scans
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:48:41 -05:00
aumnertic be7f6e6dcd fix(mito2): prove SST row counts before publishing exact statistics
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:47:22 -05:00
aumnertic 8d3b05dd7a Merge upstream main into metadata COUNT core
Signed-off-by: aumnertic <aumnertic@gmail.com>
2026-11-25 21:40:08 -05:00
discord9 51082c6d4e feat(promql): answer the shapes the native route refused for want of a rule (#10611)
* feat(promql): answer the shapes the native route refused for want of a rule

Three refusals in the native fused route were admissions, not missing
capability. Each is answered here against main's own structure.

**Grouping by `__name__` over several sources.** A tree reading more than one
named source could not report the label a `by (__name__)` keeps, because only a
discovered source declared it. Every metric-bound input now declares its name as
a source tag when the tree reads more than one, and the two refusals that
guarded this - in the planner and in `segment_tree` - are gone with
`groups_by_metric_name`.

**A `__field__` matcher over an input with no table.** The matcher names the only
field layout such an input can declare, so it answers an empty frame of that
field. An operator other than `=` stays refused: it asks what set of fields the
tables carry, and there is no table to ask.

**A canonical merge over a partitioned table.** `per_source_inputs` now covers
`any_partitioned && contains_canonical_merge`, so the boundary's producer runs
above the regions and reads a raw-series source instead of a bare scan, which is
what the distributed planner already does.

Two smaller rules complete the kind walk: `output_field_kind` covered Window,
Instant, Map, Binary and Aggregate and fell through for the rest, so a statement
rooted at a vector operation, `info` or a parameterized map named no kind at all
- each answers a kind already written one arm away, and the catch-all is gone so
a variant added later has to be classified. A comparison between two different
kinds produces no sample (`elem_binop` skips it), so its column is the empty
float layout the arithmetic arm already names.

Finally, a value field is classified by what the raw series scan produces rather
than by its catalog type, and admitted where the statement's shape makes the
existing planner publish `Float64` for it too: arithmetic, `min`/`max`, the
float-answering aggregates and the range functions whose value window is a
float. A `BIGINT` table's `sum(m)` and its bare `m` stay refused - DataFusion's
`sum` answers `Int64`, and a bare selector copies the column's own type, so
admitting either would publish a column the existing plan publishes differently.

Signed-off-by: discord9 <discord9@163.com>

* test(promql): pin a whole-vector operator standing on an aggregate

The kind walk now names what a vector operation answers, so a ranking over an
evaluated aggregate plans on this route - and the split declines it, which keeps
the route rather than losing it: `split_aggregate` answers `None` and segmentation
takes the whole statement.

Both facts are load-bearing enough to pin. The plan-level test asserts a fused
node and no final split for `topk`, `bottomk`, `limitk`, `limit_ratio` and
`sort` over an aggregate, with a bare-scan control; the integration test compares
the rows the two routes answer for the shapes both of them can run, and inspects
the plan that actually executed to confirm the ranking sits above the evaluated
input.

Signed-off-by: discord9 <discord9@163.com>

* fix(promql): an integer fold is not a float once something casts it

The numeric admission asked what type the existing plan publishes for a field,
and read every arithmetic operator as publishing `Float64`. That is true of the
operator, not of what it wraps: `sum(v) * 1` over `BIGINT` sums the integers
first and casts afterwards, so `9007199254740993` and `-9007199254740992` answer
`1.0` there, while the raw scan casts each value before summing and answers
`0.0`. Admitting that shape would have answered a different number.

An arithmetic operator now publishes a float only when the fold under it does
too. `sum(int_field) * 1`, `sum(int_field) + 1` and `count(m) + 1` keep the
existing plan; `sum(rate(m[5m]))`, `m * 2` and the aggregates that answer a float
of their own stay native.

The series-scan preflight refused the raw path for every field of an ordinary
table whenever the store was configured columnar, and nothing above could turn
that refusal into a fallback, so a query `main` answered with 40 became a planning
error. Only the prepared columnar reader is gated now: a table whose region needs
preparation keeps the refusal, and one that merely lacks columnar coverage is
served by the ordinary scan.

The test that pinned the error is replaced by one that pins the answer: a
columnar-configured store over ordinary `INTEGER` and `FLOAT` tables answers
`sum_over_time` and `avg_over_time` from the ordinary scan, equal to the existing
route.

Signed-off-by: discord9 <discord9@163.com>

---------

Signed-off-by: discord9 <discord9@163.com>
2026-11-25 18:18:25 +00:00
dennis zhuang 3ce70bdf57 fix(mito2): release write buffer memory that bulk memtable encoding saves (#10565)
* fix(mito2): release memtable memory that encoding parts saves

BulkMemtable counted every written batch against the write buffer and kept the count after merging parts into encoded parts, which hold a fraction of those bytes. Flushes fired long before the memory limit. Merges now release the bytes they save through AllocTracker::on_deallocation, which keeps the mutable and total write buffer usage consistent with freezing.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* docs(mito2): drop a stale comment on install_merged_parts

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): account bulk memtable part replacements in both directions

Merging can install parts larger than the ones it removes, and sealing
small writes replaces the buffered fragments with one sorted part.
Track both as replacements so the allocated bytes match the held parts.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): keep bulk memtable data charged until its last reader drops

Charge each part of a bulk memtable through a MemoryCharge that the
memtable and the ranges reading the part share. Replacing parts by a
merge, or dropping a flushed memtable, releases the write buffer
budget only after scans that still read the old parts finish. The
memtable statistics report the parts it holds.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): keep charges with memtable iterators and wake workers only when needed

Iterators and encoded data built from a bulk memtable range now hold the
part's charge, since flush drops its ranges before reading them.

A memtable now releases its parts one by one, so release_mem frees
memory without waking every worker unless writes may be stalled on the
global limit. Dropping the tracker still wakes them once, as before.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): charge encoded memtable parts for their parquet metadata

An encoded part keeps its parsed ParquetMetaData next to its bytes, but
its write-buffer charge only covered the bytes. Charge the metadata's
memory size too, so wide schemas and many row groups count toward the
limit. `size_bytes()` still means the encoded data length.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): size flush reads and count written data by decoded bytes

Memtable stats now carry the decoded size of their rows next to the
bytes they hold. An encoded bulk memtable holds far fewer bytes than its
rows decode to, so sizing flush batches and row groups, the region's
written bytes and the WAL estimate by held bytes picked too many rows
and undercounted written data.

A bulk memtable reports the bytes written into it, as before encoding
was charged by held bytes; an encoded range reports its decoded size.
Write buffer accounting and flush selection still use held bytes.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* docs(mito2): explain why flush sizing and written bytes use decoded bytes

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-25 13:54:39 +00:00
dennis zhuang f3f4e31c6f fix(mito2): estimate compaction memory per output (#10566)
* perf(mito2): read compaction inputs concurrently regardless of encode parallelism

Compaction read its inputs with the output encode parallelism, which defaults to 1, so one task fetched and decoded every input. Inputs are now read by at least 8 concurrent tasks; encoding is unchanged.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(mito2): blocked compaction producers must not hold read permits

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): reserve compaction memory for read-ahead of small row groups

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): charge compaction read-ahead per row group and only for merged inputs

A batch never spans row groups, so cap the per-batch estimate at one row
group. An output with a single input reads it without a channel, so it
keeps the row group estimate.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): model compaction admission on the merge of each output

Outputs of a unit merge one after another, so reserve the largest
output instead of every input of the unit. Per output, count each
reader's row group, the batches read ahead when inputs are read
concurrently, the input batches the merge retains until an output
batch, and the batches between the merge and the writer. Inputs
without row group statistics are read serially, since admission cannot
size their read-ahead.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): cap the compaction merge estimate by the input data

The merge output and the batches past the readers can never hold more
rows or bytes than the inputs, so tiny files no longer get charged for
full 64 MiB batches.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): keep compaction reads as on main and size read-ahead by its parallelism

Compaction reads inputs serially again unless the experimental output
parallelism is above 1, as before this branch. Admission charges the
read-ahead of each input only when the inputs are read in parallel.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): bound merged batch estimates by the widest available rows

One wide row in one input made every row of the batches past the readers
count as wide. Fill those batches with the widest rows first, taking no
more rows from an input than it has.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): count the LastNonNull dedup batch and share the merge parallelism

LastNonNull dedup keeps the previous output batch until the next one
arrives; admission now reserves it. Admission and the merge read the
output parallelism from one function, and the estimate notes that inputs
without FileMeta statistics make the batch size approximate.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-25 13:00:42 +00:00
discord9 22807a772e perf(promql): stop building label-set tables where they cannot collide (#10514)
* perf(promql): stop building label-set tables where they cannot collide

Signed-off-by: discord9 <discord9@163.com>

* fix(promql): let a canonical merge sit below a split aggregate

Signed-off-by: discord9 <discord9@163.com>

* test(promql): identify native pieces by what they read, not by rendered text

Signed-off-by: discord9 <discord9@163.com>

* perf(promql): judge a metadata drop by its labels alone

The plan-time proof of whether two series can share a canonical label set asked
two things: whether the labels tell them apart, and whether the scan's key
columns do. The second half was defensive against storage series that differ
only in a nullable tag holding NULL versus an empty string, which canonical
comparison already treats as one label set.

Every tag column of a metric-engine table is nullable, so that half was false
for ordinary tables, and a root merge was inserted above point-wise shapes that
cannot fold two series at all. A deep binary was cut into pieces by it, and a
disjoint scan went from two routers to four.

Judge the drop by the labels only. The physical partition-identity rule keeps
its own copy of the key-column question; the plan no longer reads it, and a
scanner whose pieces one storage series can reach is still collected under its
primary key before any name-dropping kernel sees them.

Signed-off-by: discord9 <discord9@163.com>

* test(promql): admit a histogram fold on a nullable table, name the risk counter

The fold-admission test ran on a stable-key fixture, which hid that the shapes
it names decline on a nullable one; run it on the metric-engine fixture instead.
A drop above a fold needs no collection there, which a new test pins.

Rename what the plan could not prove from "skipped" to "unproved" throughout,
including the test hook, now that the counter counts that rather than a
collection.

Signed-off-by: discord9 <discord9@163.com>

* fix(promql): a kernel that answers one series per label set proves the drop above it

`100 * (1 - avail / size)` kept a canonical merge above its vector-vector match.
The match already files its rows by the result label set and refuses two values
of one field at one point, so the broadcast above it removes a name no two of
its series were told apart by; judging that drop by its sources alone got it
wrong. A fold, a match between two vectors, a set operation, `info`,
`count_values` and the histogram functions answer one series per label set by
construction, and the proof now says so.

A merge is deliberately not one of them: it answers one series per *canonical*
label set, which still carries the name, so a drop above it can fold
`a{job="x"}` and `b{job="x"}` and must be collected.

With the proof fixed, the ranking case no longer collects between the fold and
the sort, so the test that pinned the old shape now reads the fold inside the
ranking's own tree.

Signed-off-by: discord9 <discord9@163.com>

* test(promql): a fold may plan as a collected split

With the drop judged by its labels alone, `sum(label_replace(...))` no longer
keeps a collection above the fold, so the fold plans as partial state per
partition with the canonical merge below it instead of a complete aggregate
over assembled series. The rows, the legacy comparison and the cross-partition
collision all stay the same, so the three assertions that pinned the complete
shape now accept either, and check that the merge is still there.

Signed-off-by: discord9 <discord9@163.com>

* fix(promql): derive a window's labels as the runtime drops them

A window that drops the metric name removes every metadata label at runtime
(`__name__`, `__type__`, `__unit__`), but the plan derived only `__name__` as
gone. A fold above such a window was therefore judged unproved - it could still
see a `__unit__` the runtime had already removed - and collected a canonical
merge. That merge made the segment non-commutative with a bare scan under it,
so the admission gate declined the whole statement and it was quietly replanned
as legacy.

Derive the labels the runtime leaves behind instead. The test that pinned the
old derivation now says both things it was covering: a scan that still carries
`__type__` is still collected, and a map that already removed it is not.

Signed-off-by: discord9 <discord9@163.com>

* test(promql): a single-metric drop needs one fused node, not two

With the drop judged by its labels alone, `histogram_arithmetic * 2` on a
single-metric table needs no root merge, so the statement runs as one fused
node instead of a producer and a consumer. Accept either count and say why.

Signed-off-by: discord9 <discord9@163.com>

* fix(promql): report a cross-partition label-set collision instead of folding it

A label rewrite that gives two series one label set is collected by a canonical
merge, and a split keeps that merge inside its per-partition prefix. Two
colliding series that landed in different partitions were therefore each folded
apart, and the state router added the two partial states - a value no label set
ever stood for - where Prometheus reports `vector cannot contain metrics with the
same labelset`.

Refuse the split across a canonical merge, in `split` and in `admit_prefix`,
so the statement takes the boundary shape instead: each partition's producer
collects what its own scan holds, the canonical router routes every piece of one
label set to one owner, and the fold above reads whole series. Two colliding
series are then reported wherever they were scanned.

A discovered selector is a union of one source per metric, so a segment over it
already reads frames that name their own metric: accept it in
`build_evaluated_segment` the way `build_inner_segment` already does, which
keeps `{host="a"}`-style selectors from declining once the split no longer
carries them.

A histogram fold above a boundary has no execution on this route (only the
split's state carries one), so those statements keep the plan they have on
`main`; the existing route reports their collision through its window function.

Signed-off-by: discord9 <discord9@163.com>

* docs(promql): the drop chain pays one merge, not the key columns

The example claimed the merge was paid over a table whose key columns can spell
the `NULL`/`''` pair. That pair is not part of the labels' proof any more, so no
merge is paid for it: the merge in the example is the one the chain's first drop
pays, and every drop above a merge asks only about the metadata labels. State
that instead of a cause that no longer exists.

Signed-off-by: discord9 <discord9@163.com>

* test(promql): keep the pair the labels cannot prove apart

The window test asked the pass for a metric-less selection, so the collection it
asserted was paid for by the multi-metric guard rather than by the pair the test
is about. `zone=""` and an absent `zone` meet after `rate` even when the metric
name is known, and #10412 caught that with a node-level occupancy tracker.

That tracker is gone here: the drop is judged by the labels alone, and the empty
value a kernel also removes is deliberately outside that proof - collecting it
would put a canonical merge over every statement whose kernel drops the metadata
labels. The pair therefore leaves the window as two pieces of one label set,
which the PR description records under "What this gives up" and "Out of scope".

The case is restored as the shape #10412 approved and marked ignored with that
reason, so the behaviour it pins stays in the record instead of being dropped
again; the metric-less case it had replaced is kept as its own test.

Also drops a disjunct `is_sourced_plan` already covers.

Signed-off-by: discord9 <discord9@163.com>

---------

Signed-off-by: discord9 <discord9@163.com>
2026-11-25 10:40:30 +00:00
dennis zhuang 0813fc3527 fix(mito2): size old SSTs from size statistics and move the downgrade target to v1.2.0 (#10585)
* test(compat): downgrade to v1.2.1 instead of v1.1.4

SSTs written since #10528 can have inverted-index segments that cross row
group boundaries. Readers older than v1.2.0 do not split such segments and
return fewer rows, so v1.1.x is no longer a supported downgrade target.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(cmd): record the decoded row group size of a replacement SST

sst_replace set max_row_group_decoded_size to 0 for the replacement file.
Compute it from the replacement footer with the helper writers use, which
is now public in mito2.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): derive decoded value bytes from size statistics for old SSTs

SSTs written before #10528 have no greptime:max_row_group_value_bytes or
greptime:max_row_value_width footer keys, so a row group of repeated large
dictionary-encoded values was sized by its encoded bytes on the first
compaction and read after upgrade.

When the keys are absent, sum the unencoded_byte_array_data_bytes size
statistic of each row group's byte array column chunks instead, skipping
columns that readers decode as Arrow dictionaries like the writer does.
Parquet writers record the statistic whenever column statistics are
enabled, which mito did by default with parquet >= 53 (v0.12.0).

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): count only top-level var-len columns in the size statistics fallback

The fallback summed every non-dictionary byte array leaf, including leaves
nested in structs such as JSON2 columns, which the footer keys do not
count. New files without var-len values write no keys, so they took the
fallback and got a larger decoded size than before.

Count only leaves that are top-level string or binary columns, which
matches var_len_value_bytes and leaves key-less new files unchanged. Drop
the early exit, which dictionary primary keys defeated anyway.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* perf(mito2): index the Arrow schema by root column in the size statistics fallback

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(compat): look up an inverted index segment that crosses a row group boundary after downgrade

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(compat): also downgrade to v1.2.0, the oldest reader that splits index segments

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): treat unparseable footer size keys as absent

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* docs(compat): state the v1.2.0 downgrade floor

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-25 08:48:16 +00:00
shuiyisong 455acb3461 fix: reject primary key encoding options on logical metric tables (#10624)
Signed-off-by: shuiyisong <xixing.sys@gmail.com>
2026-11-25 07:17:41 +00:00
Chenglong Zheng 0851700911 feat(meta): add object-store authority state machine and single writer (#10588)
* feat: add object-store authority state machine and single writer

Signed-off-by: hahaha <a310608318@gmail.com>

* fix: validate conditional resignations and retry renewal reads

Signed-off-by: hahaha <a310608318@gmail.com>

* refactor: clarify object-store authority naming

Signed-off-by: hahaha <a310608318@gmail.com>

---------

Signed-off-by: hahaha <a310608318@gmail.com>
2026-11-25 06:46:52 +00:00
1110a0af36 fix(meta): preserve table column order and primary key indices during reconciliation (#10251)
* fix(meta): preserve table column order and primary key indices during reconciliation

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* fix(meta): address maintainer review on column order and PK validation during reconciliation

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* style(meta): simplify nested if blocks in reconciliation utils

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* test(meta): use OutputData::pretty_print for SHOW CREATE TABLE verification

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* test(meta): drop unused mut in reconcile_table integration test

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* test(meta): make reconcile SHOW CREATE TABLE assertion formatting-tolerant

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* test(meta): cargo fmt reconcile assertion

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* test(integration): parse quoted SHOW CREATE output in reconcile test

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* style(tests): rustfmt reconcile_table SHOW CREATE assertions

Signed-off-by: Tyagiquamar <104281681+Tyagiquamar@users.noreply.github.com>
Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* style(tests): fix clippy collapsible str replace in reconcile_table

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* fix(meta): address reconcile_table review on tests and docs

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* test(integration): fix q8 SHOW CREATE TABLE assertion with check_output_stream

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(meta): take reconcile primary key order from the region tags

build_table_meta_from_column_metadatas preserved the stale table_meta
primary key order, so a consistent reconcile kept the post-ADD-COLUMN
key (a, b) instead of restoring the regions' [b, a] and a later
UseMetasrv SyncColumns rewrote the region key over SSTs encoded with the
old order. The key order now follows the input tags, which the reconcile
paths feed in region key order; the ResolveColumnMetadata consistent
branch re-applies reorder_tag_columns so the region's key must match its
tag columns. Column order still comes from table_meta for #10249.

cargo test -p common-meta reconciliation: 41 passed.

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* style(meta): wrap the tag-order loop for rustfmt

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* fix(meta): address reconcile_table review on test fixtures and guards

Address review comments from @WenyXu and @killme2008:
- Add ALTER TABLE q8 ADD COLUMN c INT before table reconciliation to exercise stale key repair with added columns.
- Remove redundant else-continue guard in the tag ordering loop.
- Clarify rustdoc explaining physical versus logical table reconciliation paths.
- Share new_test_q8_raw_table_info fixture helper across reconciliation tests.

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>

* test(meta): cover partition key order during reconciliation

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
Signed-off-by: Tyagiquamar <104281681+Tyagiquamar@users.noreply.github.com>
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: dennis zhuang <killme2008@gmail.com>
2026-11-25 01:10:12 +00:00
Samarth Jaiswal f4ff272f37 fix: keep exact DECIMAL and BIGINT UNSIGNED values in COPY FROM csv and json (#10560)
* fix: keep exact DECIMAL and UInt64 values in COPY FROM csv and json

Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com>

* style: format the reader schema test

Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com>

* test: add the expected output of the exact numbers case

Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com>

* fix: round decimals with extra fractional digits in COPY FROM

Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com>

* fix: parse decimals from text in COPY FROM csv and json

Arrow's decimal decoding is wrong for some numbers in scientific
notation and drops the digits beyond the scale. Read a decimal column
as a string and parse it, so that every digit is used and the value is
rounded as the cast from a float did.

Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com>

* fix: read unsigned integers from text and reject empty strings in COPY FROM json

Arrow's json reader parses an integer in scientific notation through a
Float64, so 9007199254740993e0 lost its last digit in a BIGINT UNSIGNED
column. Such a column is now read as text and parsed from every digit,
like a DECIMAL column.

An empty json string loaded into a DECIMAL column as NULL. It is an
error again, and only an empty csv field is read as NULL.

Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com>

---------

Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com>
2026-11-24 18:18:35 +00:00
fys 93ddb89ffc fix(query): correct filtering and ordering for file engine scans (#10547)
* fix(query): retain row filters for file engine scans

Signed-off-by: fys <fengys1996@gmail.com>

* fix(query): skip time-series scan hints for file regions

Signed-off-by: fys <fengys1996@gmail.com>

---------

Signed-off-by: fys <fengys1996@gmail.com>
2026-11-24 18:18:30 +00:00
jeremyhi 0dfd6e70cf feat: hand a region over to the object store WAL during catchup (#10589)
* feat(log-store): hand a region over to the object store WAL

Add LogStore::handoff, called before a region becomes writable on a log
store. Once it returns, every id the log store assigns the region is
above the given entry id and every id it assigned the region before,
also after a restart; no entry became obsolete, and check_region_history
accepts the region. The default does nothing.

The object store WAL raises its next object sequence above the object
holding that id, sealing the open batch first if it holds ids under the
current sequence, and keeps a release record of the region's current
watermark for the next sealed batch. It answers once that object is
durable and indexed, in both acknowledgement modes, and then records
that the region's history starts in the store. Hand-offs within one
flush interval share the object.

A store that is failing or lacks I/O permission keeps the floor and the
record and fails the call with a retryable error. If the open batch
cannot be sealed, a durable store has rolled it back and applies both at
once; an enqueued store keeps the batch and applies the largest deferred
floor of each region once it is sealed, unless the store stops first. A
hand-off handled after stop began fails as stopped and keeps nothing.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* feat(mito2): hand a region over and claim the next manifest version in catchup

A catchup that makes a region writable and carries the entry id its
source reported hands the region over to the log store before the WAL
history check. The hand-off covers the reported id, the flushed entry id
and every pending tail's upto. A catchup that still has to replay entries
above where its replay starts hands nothing over, so if it cannot reach
them it leaves nothing behind; on the object store WAL it cannot read
them from this node's prefix.

Before the region is promoted, the catchup commits an empty edit as the
version after the manifest the region holds. It runs only under
conditional manifest publication and requires a Follower with no pending
reload and not stopped. It skips the Leader deadline check, starts no
checkpoint and applies only if no checkpoint covers its version. A
writer that committed other content at that version conflicts with it;
the conflict fails the catchup with a retryable error and leaves the
region a Follower that is not fenced. Two catchups that start from the
same manifest version are not told apart.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* fix(log-store): prune cancelled hand-off waiters and correct the hand-off docs

A hand-off whose caller stopped waiting left its closed response in the
actor until the record's object was sealed, so repeated cancelled
hand-offs during a long outage accumulated one dead waiter each. Prune
closed responses on admission, as the durability waiters do.

Document that errors other than a failing store or a missing I/O permit
keep the retry hint the object store reports, and that a hand-off pending
when stop begins fails as stopped in the durable mode when its object's
create had not started. Add a test for an issued id in the open batch.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* test(log-store): describe what a hand-off after stop keeps

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* fix(mito2): hand over and commit a region caught up again before its swap

A catchup again replays into an unregistered replacement. It now hands the
region over in that replay and makes the catchup commit of the replacement in
handle_caught_up_again, after the checks of the old instance and under its
manifest lock, so no refusal follows the commit.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* fix(mito2): fire the catchup commit's manifest hook without manifest locks

commit_catchup returns the receipt of its manifest hook. A catchup again fires
it once it no longer holds the old instance's manifest lock, so a hook that
reads the manifest cannot queue behind a writer waiting for that lock.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* docs(log-store): say which object answers a hand-off pending at stop

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* docs(mito2): note when the catchup commit's manifest hook fires

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* test(log-store): cover a hand-off in the open batch when stop begins

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* refactor(log-store): return the hand-off bound and tidy its docs and tests

LogStore::handoff returns the bound it raised the region above; the default
returns the entry id. The object store WAL defers a hand-off only when the
open batch it cannot seal is not empty. The two open-batch seal tests are one
test now, which also checks the returned bound.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* docs(mito2): describe the catchup commit's cost and hook, and guard the hand-off gate

Documents the worker stall of a catchup again's commit, the writable catchup
in the region hook coverage, and the replacement's commit in catch_up_again.
Logs a failed catchup commit. Adds cases for a catchup that does not make the
region writable and for a region that skips the WAL.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* fix(mito2): keep Leader leases off a caught-up replacement while its hook runs

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* docs(mito2): tie the replacement's fence to set_writable and tidy the catchup docs and tests

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* docs(store-api): say which assigned ids the hand-off bound covers

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* docs: describe the replacement's lease fence and the hand-off bound precisely

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* fix(mito2): skip the hand-off for a region without a WAL provider

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* docs(mito2): name the catchup commit as the exception to the manifest fencing rule

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

* test(mito2): cover the hand-off of a region without a WAL provider

Signed-off-by: jeremyhi <fengjiachun@gmail.com>

---------

Signed-off-by: jeremyhi <fengjiachun@gmail.com>
2026-11-24 16:22:18 +00:00
Lei, HUANG 9ecd84f622 fix(mito2): decouple table compaction upload and Arrow budgets (#10607)
* fix(mito2): decouple table compaction upload and Arrow budgets

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* test(mito2): prune redundant table compaction checks

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* fix(mito2): cap GCS compaction objects at 5 TiB

Apply the GCS service limit even when the operator omits its object limit. Keep stricter advertised limits and the multipart part-count limit, and cover all three with geometry tests that perform no uploads.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* test(mito2): require an SST part before its final input batch

Gate the payload of the last source row group on the first Parquet part from its target. A writer that buffers until close can no longer pass the lossless multipart regression.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* refactor(mito2): isolate enterprise buffered uploads

Move the bounded SST and Puffin upload adapter and its regression test behind one gated module declaration. Leave the shared chunk transfer in the Apache-licensed parent and register the new enterprise source in both license lists.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* docs(mito2): describe ObjectStoreWriter bytes as accepted for upload

Bounded uploads stage bytes in a local part buffer before they reach the object store, so output_bytes counts accepted bytes rather than bytes already submitted. The only reader takes the value after a successful close, when both counts agree.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* refactor(mito2): rename the compaction compute estimate

MemoryLimits::compute_bytes returned the estimated working set that admit()
compares against the compute budget, while UploadBudget::compute_bytes holds
that budget. Rename the method to estimate_compute_bytes and name the
admission local accordingly so the estimate and the budget are not read as
the same quantity. The budget field keeps its visibility because source
admission still bounds footer memory by it.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* test(mito2): rename the source-less table compaction fixture

Rename `Fixture::empty` to `Fixture::without_source`. The constructor still creates the scheduler environment, access layer and config and only skips writing the input SST, so the old name suggested a state-less fixture. The new name mirrors `with_source`; both call sites are updated.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* fix(mito2): check the upload object limit inside the bounded writer

Move the object-limit check from the Parquet SST writer into UploadBuffer::write so every caller of the bounded buffer is covered and the remaining-allowance subtraction cannot underflow. Make check_size private; the Puffin adapter keeps its own check and the limit error still surfaces as MultiRegionCompactionResource. Cover writes accepted up to the limit and the rejected next write.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* docs(mito2): document index writer upload policies

IndexWriteBuffer variants select different object-store writers: the default writer, exact-size parts, or a serial upload buffered through the enterprise adapter. Document each policy and explain that IndexObjectWriter boxes the bounded side because that adapter is returned as an opaque type.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

---------

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
2026-11-24 15:33:23 +00:00
shuiyisong 81e60511b5 ci: make nightly merge opt-out and simplify Docbot labels (#10601)
* ci: make nightly merge opt-out and simplify Docbot labels

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* ci: scope nightly label migration and sync to main

Use the saved nightly preference only for PRs targeting main at both
snapshot and apply time. Clean up docs-not-required across all bases.

Restore the skip label when it is removed while the opt-out box is
checked.

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* ci: honor cleared nightly opt-outs on retry

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

---------

Signed-off-by: shuiyisong <xixing.sys@gmail.com>
2026-11-24 10:42:29 +00:00
Yingwen 21d6a25dfb refactor(mito2): share SST reading with multi-region compaction (#10583)
* refactor(mito2): share SST reading with multi-region compaction

Signed-off-by: evenyag <realevenyag@gmail.com>

* fix(mito2): charge only materialized routing columns

Signed-off-by: evenyag <realevenyag@gmail.com>

---------

Signed-off-by: evenyag <realevenyag@gmail.com>
2026-11-24 10:35:40 +00:00
dennis zhuang 890540f248 fix(table): keep the primary key order when adding columns (#10591)
TableMeta::add_columns rebuilt primary_key_indices from column positions,
so ADD COLUMN on a table whose key is not in column order (or with a key
column added FIRST/AFTER) rewrote the table key, while regions keep their
key and append new tags at the end. Keep the existing key order and append
new key columns in request order.

Refs #10248

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-24 10:28:33 +00:00
Weny Xu 044e659b2d fix(meta): persist segmented procedure checkpoints atomically on RDS (#10604)
* fix(meta): persist segmented procedure checkpoints atomically on RDS

Signed-off-by: WenyXu <wenymedia@gmail.com>

* fix(meta): fall back when MySQL packet limit lookup fails

Signed-off-by: WenyXu <wenymedia@gmail.com>

* fix(meta): use atomic checkpoint batches on memory and raft backends

Signed-off-by: WenyXu <wenymedia@gmail.com>

* fix(meta): preserve large KV writes when batching on RDS

Signed-off-by: WenyXu <wenymedia@gmail.com>

---------

Signed-off-by: WenyXu <wenymedia@gmail.com>
2026-11-24 09:18:56 +00:00