mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-28 13:44:03 +00:00
d88f5da7bbda2ccb6773a83e223ff8e337d8841a
5594
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d88f5da7bb |
fix(meta): check for a follower on the migration target before opening the candidate (#10684)
* fix(meta): check for a follower on the migration target before opening the candidate Signed-off-by: jeremyhi <fengjiachun@gmail.com> * refactor(meta): propagate route errors in the follower check on the migration target Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com> |
||
|
|
8d4e9464d9 |
feat(mito): store native histograms in narthex samples (#10667)
* feat(mito): store native histograms in Narthex samples A physical table whose single value field is the canonical greptime_native_histogram struct can now use sst_format = 'narthex'. The samples format gets column encoding 8, which lays out a block's histogram field child by child: each struct child is encoded with the nullable XOR codec of encoding 5, integers ZigZag-mapped, and a list as its nullable lengths followed by its flattened items. The chunk header names the child count and child kinds, the manifest records the field type as "native_histogram", and a block whose field chunk encoding does not match its manifest type is rejected. Writers and bulk memtable parts cut a block before a histogram chunk's size bound would pass the 1 MiB chunk limit, and a Narthex region rejects a sample that cannot fit one chunk before accepting the write. The prepared columnar reader now serves histogram fields, so native PromQL raw scans read Narthex histogram regions; float-only projections still skip histogram chunks. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(mito): cover Narthex histogram bulk limits and sidecar reads Add tests for paths the histogram change relies on but no test pinned: the bulk write path refusing an oversized histogram sample before WAL and memtable, the bulk memtable splitting large histograms into blocks whose chunks stay within the samples chunk limit, and native PromQL reading histograms from a columnar series-index sidecar on a Parquet metric table, compared with the plain Parquet answer. Also wrap three long lines in the samples format doc. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(mito): state that the block size formula does not bound histogram buffers Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito): release read-ahead before failing a histogram reservation Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(mito): pin the native histogram chunk layout and child order Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito): check bulk histogram sizes after filling missing columns Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
1819183c51 |
fix(mito2): treat a primary key order change as incompatible (#10326)
fix(mito2): treat a primary key order change as incompatible (#10248) `has_same_columns_and_pk_encoding` compared the primary key encoding but not the primary key order itself, so an SST encoded with another key order could be merged as if the keys were identical. Deduplication compares the encoded key bytes, so such rows are not deduplicated and COUNT/SUM silently drift. Compare `primary_key` as well and route an order change through the compat path, where `is_primary_key_same` rejects it loudly. The compat reader cannot reorder a key - it can only append missing tags or rewrite the encoding. The `TableMeta::add_columns` half of the original report is already implemented on main (the key keeps its order and new key columns are appended in request order), so this change keeps only the remaining gap. Signed-off-by: discord9 <discord9@163.com> |
||
|
|
951dd733b7 |
feat(mito2): hand a region over from its source without replaying in catchup (#10641)
* feat(mito2): hand a region over from its source without replaying in catchup A catchup that makes a region writable and carries the last entry id its source reported, on a region whose manifest is published conditionally, now hands the region over instead of replaying any WAL: - It refuses a region with rows in its memtable with a retryable error, since the handoff floor would skip their entries and a reopen would drop them. Other regions still reopen as before. - It hands the region over to the log store once, with a bound covering the reported entry, the flushed entry id and every pending tail. - Its catchup commit records this node's handoff floor (that bound) and, when the source has entries after where the manifest recovers its WAL from, a reported tail of the source over them, raising the committed sequence by 2^40 so writes accepted during the background replay outrank the replayed rows. The edit applies to the region's version under the manifest lock, before the region is promoted. - It then releases this node's WAL up to where the region now replays it, keeping this node's pending tails. If the source has such entries and the request names no source, the catchup fails without committing. The datanode takes the source from `UpgradeRegion::location_id`, which the metasrv already sets to the region's previous leader; the metric engine passes it to the data region only, since it loads the logical tables from the metadata region when the catchup ends. Other catchups replay this node's WAL after the manifest's replay start, which includes this node's handoff floor, and release it capped by this node's pending tails, as an open does. While a region is in a catchup, a manifest sync and a follower's skip-WAL option change are refused with a retryable error. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(mito2): apply a handover's edit on the region worker The catchup task commits a handover outside the worker and sends the committed edit to the region worker, which applies it in order with the edits of flushes and compactions, seeds the node lease and promotes the region. If the instance was replaced or stopped meanwhile, the worker ends the catchup and clears its registration; a task outside the worker then releases this node's WAL up to the committed manifest's replay start and replies RegionNotFound. A handover is refused while the region's tail replay has not reported its end, and the worker reads whether the manifest is published conditionally without taking the manifest lock. The refusals of a manifest sync and a follower's skip-WAL change follow the instance in a catchup, or a fenced instance while a catchup or reload is registered, so a follower opened after a close is not refused for its predecessor's catchup; a sync applies them before and after its role check. The handover tests are cut, merged and share their support code. Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com> |
||
|
|
fa11a2fea1 |
fix(mito2): allow table compaction publication after adding nullable sparse tags (#10681)
* fix(mito2): allow table compaction publication after adding nullable sparse tags Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(mito2): publish table compaction across schema changes Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |
||
|
|
bceb12f71b |
perf(promql): look the routed identity up once per message (#10549)
`RepartitionStream::poll_next` searched the pending-group map three times for the same identity on every drained message: `contains_key`, then `insert`, then `get_mut`, with no mutation in between. One `BTreeMap::entry` does the same work once and moves the key into the tree instead of cloning it. The charge stays strictly before the insert: the vacant arm registers and calls `try_grow`, and the group only exists when that succeeded, so a refused pool still leaves nothing behind. The entry is confined to one block because `OccupiedEntry` is not `Drop`, so the failure path can call `lease.fail` after the borrow ends. Duplicate detection, the ordered rescan, the `KeyThenTime` watermark and the accounting are untouched. Why this one: profiling (`perf report --no-inline`, 5 s, 999 Hz) puts B-tree comparison at 9.84% of samples on `topk_5_rate_5m` and 8.94% on `sum_by_host_ratio_ignoring_instance`; only the two redundant searches go away, so the realisable saving is below those ceilings, and on `rate_5m` the same comparison is 0.08%, i.e. nothing. Signed-off-by: discord9 <discord9@163.com> |
||
|
|
59b108af84 |
fix(procedure): recover from the last readable checkpoint (#10612)
* fix(procedure): recover from the last readable checkpoint Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(procedure): keep unreadable checkpoints out of GC checks Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(procedure): use the SNAFU selector for corrupt checkpoints Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |
||
|
|
9abcdd7af3 |
fix(table): do not extract time range from mixed IN lists (#10357)
A time-index IN list containing a non-literal item was narrowed to the envelope of its literal items. The non-literal item can match any timestamp, so the scan could prune rows that satisfy the predicate. Abandon the whole IN unless every item is a literal; all-literal lists keep the existing envelope behavior. Signed-off-by: discord9 <discord9@163.com> |
||
|
|
0127d63865 |
fix(mito2): require a region to own its files before a remap (#10646)
* fix(mito2): require a region to own its files before a remap A remap (split or merge) moves file references between regions. Today mito2 checks only that the inputs come from the same table, so a merge can be applied while a participant still holds files another region created; a later compaction then materialises a copy of the same rows and both references survive the file-id dedup, so the merged region reads those rows twice. Reject such a remap instead: every participating region must hold only files whose creation expression equals that region's own partition expression. The error names each offending (region, file, creator expression) so the caller can compact the region and retry. A one-source-to-many-targets split is exempt: no target combines file sets there and the region predicate keeps a split's rows apart. This trades a merge-time error and a compaction for the per-reference row range that #10616 adds. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): treat a file without a recorded creator as the region's own Files written before the partition expression was recorded carry no creator, so their provenance cannot be established and the read path does not narrow them either. The merge guard compared such a file against the region's expression and rejected it, which would break the first repartition of an upgraded table. Also state the remedy as it is: the operator aborts the repartition, compacts and retries; nothing triggers that compaction automatically, and a region in a staging session is skipped by the compaction scheduler, so the abort comes first. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): report only the region and file that a merge must settle The refusal does not need to restate either partition expression: the operator acts on the region, and no production caller parses the message. Drops the expression rendering and its now unreachable None arm. Signed-off-by: discord9 <discord9@163.com> * docs(mito2): drop the comments the trimmed diagnostics left behind Removes the orphaned renderer doc, stops the unit-test comment from promising creator diagnostics, describes the error payload as it is, and corrects the claim that a creator-less file is not narrowed on read. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): reject an unstamped file on merge, and bound the refusal message An unstamped SST can still hold rows of both children of an earlier split, so letting it through a merge re-admits the duplicate: both children inherit it, one compacts into its own file, and the merged region then holds the same rows under two file ids. A split stays exempt, so an unstamped table can still repartition; its regions materialise (compaction stamps the output) before merging. Lists at most eight offending files and counts the rest, so a wide table cannot produce an unbounded message. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): check merge ownership before the target routes are published The remap-time guard fires while fetching manifests, which the procedure does after UpdateMetadata::ApplyStaging has published the target write routes: a reused target can acknowledge a write that the rollback then routes elsewhere, and the row is flushed later under the old expression. Move the decision ahead of publication. Every incoming edge to ApplyStaging now asks each merge source leader, through RemapManifest with a validate-only flag, whether every file it holds records its own expression; the check reads the ordinary manifest, writes nothing and leaves the region out of staging. A refusal therefore keeps the old routes in force. The flag is serde-defaulted, so an older datanode ignores it and its ordinary remap is refused because the region is not in staging - a failure, not a silent pass. The remap-time guard stays as the second line of defence. The failure now reaches the SQL caller with the offending region and file: Collect keeps the sub-procedure errors instead of only their counts. Signed-off-by: discord9 <discord9@163.com> * fix(meta-srv): keep the refusal's cause and its retryability Collect formatted the child failure with Display alone, so ProcedureExec's "Failed to execute procedure" hid the region and file the operator needs; render the whole source chain instead, and assert in the test that the parent error names a known region and file. A mailbox timeout on the pre-publication check became a terminal "compact the region" error, although metasrv treats the timeout as retryable. Propagate anything whose retry hint is retryable, and build the offender list - and its compaction advice - only from non-retryable failures. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): use one predicate for merge ownership at both stages Preflight skipped every single-source group, while the remap guard exempted only a one-to-many mapping: a one-to-one repartition could therefore be refused after the target routes were published. Both stages now read the same rule from the persisted mapping - a group needs the check iff some target is fed by two or more distinct sources - expressed once in store-api and used by the preflight and by is_split. A one-to-one repartition hands its target one source's files and combines nothing, so it is exempt at both stages instead of being refused late. Signed-off-by: discord9 <discord9@163.com> * test: materialise before merging in the repartition integration tests Both tests merge regions that still reference an SST written by an ancestor, which the merge guard refuses. Compact with the strict-window mode first - it rewrites even a lone inherited file - and keep the merges they were written for. Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
5cd42ef86b |
fix(mito2): make table compaction publication retries idempotent (#10651)
* fix(mito2): make table compaction publication retries idempotent Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(mito2): allow table compaction publication across region option changes Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(mito2): preserve exact sequence reads across table compaction publication Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(mito2): guard mixed compaction inputs after sequence preservation is enabled Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(mito2): check sequence policy before verifying compaction outputs Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |
||
|
|
13442db700 |
feat(mito): compact native series indexes within a coverage window (#10649)
* feat(mito): compact native series indexes within a coverage window Signed-off-by: evenyag <realevenyag@gmail.com> * test(mito): allow destination index maintenance after remap Signed-off-by: evenyag <realevenyag@gmail.com> * docs: keep index scheduling policy out of the format spec Signed-off-by: evenyag <realevenyag@gmail.com> * docs(mito): clarify the scope of native format specifications Signed-off-by: evenyag <realevenyag@gmail.com> * style(mito): use a crate-rooted path for the balance predicate Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): merge adjacent index watermarks and rotate past unusable groups Signed-off-by: evenyag <realevenyag@gmail.com> * test(mito): type window timestamps as milliseconds Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): skip incompatible merge groups and reject stale invalidation Signed-off-by: evenyag <realevenyag@gmail.com> * perf(mito): read exact series keys directly from columnar dictionaries Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): rotate after failed index writes and propagate lazy read errors Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): discover series from samples when a window index read fails Signed-off-by: evenyag <realevenyag@gmail.com> * style(mito): use crate visibility for series discovery Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
e8eb093b72 |
fix(mito): refresh the removed-file count when GC clears its records (#10636)
Clearing deleted files from the manifest does not commit a manifest version, and the count reported to metasrv was only recomputed on open, create, commit and checkpoint. A region that goes write-idle after a GC pass therefore kept reporting the files GC had already deleted, indefinitely. That stale count feeds the GC score, so such a region kept winning a candidate slot on a table while it had nothing left to reclaim, and a region with real garbage behind it could stay outside the top-N. Recompute the count at the clearing site, exactly like the other five places that change removed_files. The read path is untouched: region_statistic still loads one atomic. Signed-off-by: discord9 <discord9@discord9.com> |
||
|
|
c887958b03 |
Merge commit from fork
Add query.remote_allowed_hosts and query.allow_server_credentials to frontend, datanode and standalone. - query.remote_allowed_hosts: when set, object stores built from SQL statements send every request, including credential requests, through an HTTP transport that only allows the listed hosts and does not follow redirects. Blocked requests are logged with their host and port. - query.allow_server_credentials = false: an object store without credentials in its connection options cannot use the server's own credentials. Independent of the options, explicit credentials are validated: incomplete S3/OSS key pairs, an S3 session token without keys, an Azure account key without a known account name, and a GCS credential that is not a service account key are rejected. Only the type, private key and client email of a GCS service account key are passed to the signer. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
82dec23d17 |
fix(query): prune logical metric scans by table ID (#10645)
* fix(query): prune logical metric scans by table ID Signed-off-by: evenyag <realevenyag@gmail.com> * perf(query): skip redundant single-region metric pruning Signed-off-by: evenyag <realevenyag@gmail.com> * perf(query): skip table ID pruning for tag-only metric routes Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
4a95c6bb9d |
fix(mito2): run the work held back by the Leader lease wait once the region can run it (#10618)
* fix(mito2): retry the work held back by the wait for a Leader lease A region that a catchup made writable waits for its Leader lease before it commits. When the lease ends the wait while the region is staging, in a change or not a leader, the missing-index pass, the index build retries the wait refused and the save of the backfilled partition expression were dropped, and nothing ran them later. Keep that work per region in the worker (`deferred_lease_work`) until the region is a writable leader with its lease. Every path that makes it one runs it: the end of an ALTER, an edit, a failed EnterStaging, a truncate or discard (after the index build scheduler retires its queued builds), the end of staging, a failed drop, a failed close-time flush, and a promotion outside the worker, which now notifies the worker on an actual transition into a writable leader only. A backfill save that finds the region in another state, such as a change the worker started after spawning it, reports back and the worker defers it. Close and drop remove the work. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(mito2): keep deferred lease work across role changes and late reports A refused index build retry stays due until the region is a writable leader with its lease; the backfill save checks the state once under the manifest lock; a deferral reported by a closed or dropped instance adds no work to a later one; tests replace sleeps with hooks and cover a failed close-time flush. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(mito2): keep deferred lease work a role change stops while it runs An index build retry that a role change outside the worker stops in the scheduling loop stays due, and a missing-index pass that the region's state stops puts the whole deferred work back instead of ending with the save. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(mito2): keep a refused retry where its region's state refuses it Each state check of an index build retry keeps the retry it refuses, so no separate earlier check can disagree with it; a promotion outside the worker notifies it from the state the role change actually replaced; the test gate moves to test_util. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(mito2): cover an index build retry refused by a follower or staging region Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(mito2): end the lease wait a direct promotion counts as a lease A direct conversion to Leader records a Leader lease; the end of the wait it may cause now reaches the worker, which runs the work the wait held back. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * refactor(mito2): run deferred lease work from one sweep after each batch The worker sweeps its deferred work after a batch that may change a region's state, instead of from each handler that makes a region writable. An entry records which of the missing-index pass, the backfill save and the index build retries are due, so a refusal unrelated to the lease records only its retry, and a kept retry's callers are answered at once. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(mito2): keep one deferred lease work test per kind of transition With one sweep after each batch, the completion-point cases tested the same mechanism through different handlers; the redundant cases are dropped, and a test checks that a deferred backfill save does not re-run the missing-index pass. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(mito2): read Promotion in the candidate demotion test Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(mito2): run the work a lease wait held back after its batch The end of the wait only records the work; the sweep after the batch runs it, after whatever the same batch dispatched, such as a truncate or an ALTER. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(mito2): check the stopped missing-index pass with a refused request Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(mito2): keep a refused retry through a catchup replacement Signed-off-by: jeremyhi <fengjiachun@gmail.com> * refactor(mito2): sweep deferred lease work after every batch Signed-off-by: jeremyhi <fengjiachun@gmail.com> * docs(mito2): rewrap the doc of notify_if_became_writable Signed-off-by: jeremyhi <fengjiachun@gmail.com> * docs(mito2): say where the deferred lease work sweep allocates and why the entry is put back whole Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com> |
||
|
|
686005c2c9 |
feat(mito): build native series indexes with certified time-window coverage (#10615)
* feat(mito): stream exact sample keys into native PoC series files Signed-off-by: evenyag <realevenyag@gmail.com> * feat(mito): evaluate native series window frontiers in the pinned scan Signed-off-by: evenyag <realevenyag@gmail.com> * feat(mito): publish native window builds through serialized region edits Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): validate full index coverage across publication and recovery Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): repair incompatible native indexes and isolate sidecar capacity Signed-off-by: evenyag <realevenyag@gmail.com> * test(mito): fill the sidecar budget in native repair coverage Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): remove source file IDs from native series indexes Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): release memtable snapshots before native index I/O Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): preserve local sidecar source list encoding Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): expose Narthex series entry to production writer Signed-off-by: evenyag <realevenyag@gmail.com> * feat: build incremental Narthex series indexes from manifest coverage Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): reuse series indexes across compatible schema changes Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): simplify native series index coverage and publication Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): require a window for native series indexes Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): remove tag rename handling from series index reads Signed-off-by: evenyag <realevenyag@gmail.com> * feat(mito): batch native series index builds by uncovered file count Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): configure the native series index file threshold via TOML Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
83dd79491a |
fix: honor LIMIT when copying a table to a file (#10639)
* fix: honor LIMIT when copying a table to a file Signed-off-by: Alex <alex.castillog33@gmail.com> * test: verify zero-row COPY CSV output Signed-off-by: Alex <alex.castillog33@gmail.com> * style: format COPY LIMIT regression setup Signed-off-by: Alex <alex.castillog33@gmail.com> --------- Signed-off-by: Alex <alex.castillog33@gmail.com> |
||
|
|
d96699c104 |
fix: skip inactive datanodes during inspection and expire stale registrations (#10630)
* fix(metasrv): cap idle datanode registration retention at one minute Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(metasrv): derive datanode registration retention from the lease Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
455acb3461 |
fix: reject primary key encoding options on logical metric tables (#10624)
Signed-off-by: shuiyisong <xixing.sys@gmail.com> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
a6cc055e83 |
refactor(promql): fold legacy histogram aggregates through the native accumulator (#10483)
* refactor(promql): fold legacy histogram aggregates through the native accumulator
The legacy prom_native_histogram_agg_sum/_avg accumulators kept their own sum, weighted
mean, incompatibility flag and reset evidence beside the native HistogramAccumulator that
10199 added, so the two could answer the same aggregate differently. The legacy
accumulator now holds that fold and delegates push, merge, state and size to it; only the
state frame still differs, and its layout, field names and order are unchanged.
The legacy frame declares neither a compensation component nor a mean mode, so a state
carries the fold's answer: the running sum with its compensation folded in, or the running
mean of its samples. That is what a reader of the frame adds or weights, and it keeps the
residual of samples already folded into one position. It is not a lossless Kahan state --
folding the compensation back into one f64 rounds again, so a partition holding [1e16, 1]
still exports 1e16 and merging it with [-1e16] answers 0.
An exponential sample meeting custom buckets poisons the whole position, as the legacy
reconcile() returning None did: the position answers null and the evidence says why,
rather than skipping the sample or failing the query. Reset evidence is OR-ed from the
state's two booleans instead of re-observing the merged histogram's hint, which the fold
already accounted for.
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit
|
||
|
|
82bdd7fd27 |
fix(mito2): keep a caught-up region writable on candidate leases (#10590)
* fix(mito2): keep a caught-up region writable on candidate leases A region that a catchup made writable waits for its Leader lease until the route switch. Meanwhile the metasrv keeps granting it Follower leases that carry a candidate_lease_id, and each of them demoted the region, so the next upgrade attempt had to catch it up again. A Follower lease that carries a candidate_lease_id now leaves a region that awaits its Leader lease alone. It checks the wait under the promotion fence, so a concurrent catchup promotion is either seen or happens after the demotion. Other Follower leases, and candidate leases to a region that does not wait, demote it as before. The store-api contract now says an engine may use the presence of the id this way; it still must not interpret its value. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * docs(mito2): clarify the candidate lease wait and its tests Describe the condition demote_candidate checks, name both lease kinds that end the wait in the store-api contract, and check that a candidate lease keeps a waiting physical region a leader that is not confirmed. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: address review comments on candidate leases Log the expected role mismatch of a migration target that a catchup promoted before the route switch at debug, and explain the candidate-lease branch at its call site. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(meta-srv): check the log level of an operating region's role mismatch Also say that a candidate lease leaves a waiting region's state unchanged, rather than writable, since a catchup again keeps such a region a follower. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(meta-srv): drop a redundant comment Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(mito2): check that a candidate lease counts as applied Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: tighten the candidate lease log and comment Choose the log level only for a role mismatch, say from the engine side why the candidate branch stays out of MitoRegion::set_role, and tidy the test helper. Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(meta-srv): cover a matching Leader with a candidate lease id Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com> |
||
|
|
8e885bfed5 |
feat(promql): read the quantile parameter at every grid point (#10509)
`quantile(scalar(foo), v)` and `quantile(time()/2400, v)` were refused by the native compiler, which
bound the quantile with `constant_argument`. Prometheus reads an aggregate's parameter at every step,
and the kernel already does: `aggregate_quantile(schema, input, q: &Series, grouping)` looks the
quantile up per grid point and answers nothing where the parameter has no sample.
A scalar the statement evaluates now binds as a parameter subtree, in the shape `topk` already uses:
`NativeExpr::ParameterizedAggregate { input, op, parameter }` is appended to the enum (wire index 18;
the enum is append-only), so no field is added to `Aggregate` and the envelope version is unchanged.
`op` keeps its constant quantile unused, exactly as `ParameterizedTopK` ignores the `k` it carries.
A parameter the statement itself decides stays on the constant path - `quantile(0.25 + 0.1 + 0.15, v)`
is one number - and a vector argument keeps the refusal it always had, which the parser now states
first: `quantile(x, y)` is refused at type check before this compiler sees it.
The fold drains the parameter whole before its input, bills the held series in `QuantileInput`'s
bytes and settles what it no longer holds, so the pool is empty at the end. Validation accepts the
node only for a `Complete` quantile whose parameter is a scalar on the output grid, and a split still
declines a quantile, so no `Partial` or `Final` state can exist for it.
Signed-off-by: discord9 <discord9@163.com>
|
||
|
|
883ae6eaf7 |
fix(promql): answer a named selector over a missing table with the empty vector (#10472)
A selector that names a metric whose table does not exist made the native route decline the whole statement, so the existing planner answered it. The route already has that answer when the selector names no metric: a nameless selector that matches no table is planned as the typed empty input and answers the empty vector. `setup_context` reports a missing table by returning the `EmptyMetric` plan, which a native tree cannot bind, and the named path read that as "cannot plan" rather than as "no rows". The named path now pushes the same typed empty input the zero-match nameless path pushes, so Prometheus' answers follow from the ordinary empty-input handling: a bare selector answers no rows, `rate`/`sum`/`count`/`topk`/`sum by (__name__)` answer no rows (`sum` of nothing is empty, not 0), `absent` answers one row holding 1 with a null name, `absent` over equality matchers carries those labels, `absent_over_time` answers the same, and `or`, `and` and `unless` keep, drop or ignore what the other side holds. A `__field__` matcher still declines, exactly as it does over a table that exists: the matcher names the field layout a scan would have decided, so the route's boundary does not depend on whether the table happens to exist. A missing table whose metric is named after a column of the rows layout now answers instead of failing: the free synthetic time-name rule the data-free route already used is shared, so `time` publishes its grid as `native_time_0` beside its own `time` value column, and a value column that would collide with the mandatory row-name column (`__name__`) declines and keeps the existing plan's empty answer. A pointwise chain above an evaluated-input subquery is deliberately NOT admitted here. Cutting a segment replaces the window under the chain with a boundary, and a window that would have collected one label set's contributions stops collecting them once its input is a leaf; a window-local proof cannot establish whole-query uniqueness either, because the outer wrapper drops the metric name again and the duplicate guard is partition-local. Chains keep the plan they had. #10531 tracks the cut defect, and the identity enforcement that a future admission would need. A `__field__` matcher no longer changes the answer for a missing table: a field selection over a table with no rows is empty either way, so the statement answers the empty vector natively, exactly as the existing planner does - it returns the `EmptyMetric` plan before any matcher projection runs. Over a table that exists the matcher still declines this route, because there it narrows a real scan's field set, which a raw-series scan cannot report. The nameless zero-match branch no longer declines a `__field__` matcher either: a selector that matched no table has no field set to narrow, so both spellings answer the empty vector. The synthetic grid name is now chosen before the segmented root is built. `absent(missing{time="x"})` publishes a label named `time` while the route would name its grid column `time` too, and choosing the free name only on the single-input path meant schema construction failed first and the statement left the route; it now answers one sample of 1 carrying the matcher's label. Signed-off-by: discord9 <discord9@163.com> |
||
|
|
f51d01b185 |
fix(datatypes): bounds-check Vector::get and get_ref (#10594)
The indexed accessors checked is_valid() and then called value_unchecked(), but is_valid() is not a bounds check: it returns true for any index when the array has no null buffer. An out-of-range index read past the array buffers instead of panicking. Use the bounds-checked value() accessors. This also covers DictionaryVector, whose lookups go through the item vector's get(). Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
a7693d52b6 |
fix(servers): require authentication for debug endpoints (#10592)
* fix(servers): require authentication for debug endpoints The /debug routes are added after the HTTP middleware stack, so they did not go through the auth layer, and need_auth() only covered /v1/. Apply the auth middleware to the /debug routes and treat the /debug namespace as requiring authentication when a user provider is configured. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs: pass credentials to debug endpoints in profiling guides Let dump.sh read curl credentials from the config file in GREPTIME_CURL_CONFIG, and document authentication for the /debug endpoints in the profiling and log level guides. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
c2a15bdebf |
perf(promql): return a fixed plan-metrics set instead of cloning the live one (#10525)
Signed-off-by: discord9 <discord9@163.com> |
||
|
|
216135381b |
feat(mito): integrate opt-in authoritative Narthex storage (#10526)
* feat(mito): integrate opt-in authoritative Narthex storage Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): restrict Narthex storage to one value field Signed-off-by: evenyag <realevenyag@gmail.com> * fix(cmd): handle Narthex in direct SST fixture writer Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): clarify Narthex encoded bulk part support Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): type Parquet bulk iterator inputs explicitly Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): route Narthex storage by region format Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): address authoritative Narthex review findings Signed-off-by: evenyag <realevenyag@gmail.com> * docs: remove implementation notes from samples format spec Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): rely on canonical metric write keys Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): refine Narthex scan and copy semantics Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): reject raw sparse writes and exclude series scans from windowed sort Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): allow sparse bulk companion tags and simplify manifest admission Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): make Narthex scan preparation optional Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): prune Narthex samples in stored time units and share bulk blocks Signed-off-by: evenyag <realevenyag@gmail.com> * test: track sparse exemplar write failures Signed-off-by: evenyag <realevenyag@gmail.com> * test: track remaining observed sparse exemplar failures Signed-off-by: evenyag <realevenyag@gmail.com> * test: isolate sparse write regressions across ingestion paths Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
f796889bbd |
feat(postgres): jsonl COPY FROM STDIN via the arrow-json engine (#10109)
* feat(postgres): Prometheus Remote Write protobuf ingest via COPY FROM STDIN COPY FROM STDIN WITH (FORMAT promwrite [, version 2] [, <options>]) ingests one Prometheus Remote Write request body over the postgres wire protocol — a GreptimeDB-specific, binary COPY format (wire format code 1). The payload is byte-for-byte the body a remote-write client POSTs to /v1/prometheus/write, compression included: buffered until CopyDone and completed through the exact ingestion core that endpoint runs. To share that core, the HTTP handlers' ingestion bodies are extracted into axum-free functions (ingest_remote_write_v1/v2 plus the context extension stamping), and the HTTP routes become thin wrappers — their behavior is unchanged, and the copy layer runs the identical decode, validation, conversion, batched/prepared write paths, per-batch write-progress accounting and context extensions, under the connection's regular postgres context. The WITH options carry what the HTTP endpoint takes as its content-type/-encoding and query parameters; session-provided values (database, user) are not repeated: - version 1|2 (default 1), matching the content-type's proto - zstd, matching Content-Encoding: zstd (snappy by default) - physical_table, matching the ?physical_table= parameter - pipeline_name/pipeline_version, matching the pipeline headers (v1 only; for v2 they are accepted and ignored, exactly like the HTTP route ignores them) Table-less like the other ingestion formats; one COPY statement is one bounded request (shared 64 MiB limit); the row count reports written rows (v1) or written samples plus histograms (v2). The flush enforces the frontend's shared request-memory quota (max_in_flight_write_bytes) — the same limiter the HTTP ingestion protocols use, so COPY cannot bypass the aggregate budget. Wiring: PostgresServer::with_prom_remote_write carries the handler, metric-engine flag, validation mode and shared memory limiter. e2e: v1 body chunked across CopyData boundaries; v2 samples with readback; physical_table option routing; garbage-body decode failure with connection reuse; a tiny-quota regression where a compressed body whose decompressed size exceeds the budget fails like the HTTP route. Signed-off-by: Ning Sun <sunning@greptime.com> * feat(postgres): jsonl COPY FROM STDIN via the arrow-json engine COPY tbl [(cols)] FROM STDIN WITH (FORMAT jsonl) ingests newline-delimited JSON objects through arrow-json's incremental Decoder — the same engine behind file-based COPY ... FROM 'file.json' — so both COPY routes accept identical data. One JSON object per record; keys address the targeted columns by name, absent keys become NULL, and offset-free timestamp strings parse in the session timezone (the same schema substitution the csv codec makes), like SQL INSERT. The streaming contract mirrors arrow-csv's exactly (decode returns consumed bytes; a short read means a full batch), so the parser is a twin of the csv one: objects may span CopyData chunk boundaries, records surface in COPY_IN_FLUSH_ROWS batches, and a trailing object without its newline is accepted. Table-bound like csv (a named table is required; the column list fixes the target order); no options (the file format's layout options are writer-side; the reader parses date-times natively). The two table-bound codecs share the table path through a small TableBoundCodec trait (check_column_type + create_parser); csv's behavior is unchanged. e2e: chunked object-boundary ingest with absent-key NULLs; session-timezone parity against SQL INSERT; malformed JSON failure with table-left-clean and connection recovery. Signed-off-by: Ning Sun <sunning@greptime.com> * feat(postgres): address jsonl COPY review — codec names, nullable-aware errors, docs and tests - `TableBoundCodec::name()` drives the codec name `CopyInState` logs instead of the hardcoded "csv"; `table_bound_state` reuses the query context `begin_copy_in` created; the csv/jsonl trait impls hold their bodies and share one supported-type check. - jsonl: the decode schema marks every field nullable, so a NULL in a non-nullable column is reported by column name instead of arrow-json's "unmasked nulls in non-nullable StructArray child" error; errors map to 22P02/22P04 by semantics (field value vs. syntax), never XX000; the no-op `decode(&[])` EOF signal is gone; a top-level JSON array under `FORMAT json` fails with a specific hint instead of `expected { got [`. - Module docs describe what arrow-json really accepts: numeric strings for numeric columns, numeric timestamps taken in the column's unit, unknown keys ignored (strict mode stays off so column subsets work). - Tests: multi-batch sweep through the mid-stream flush path, trailing and truncated records, column subset/reorder with extra keys, missing and null ts, the `json` alias, error classes. Signed-off-by: Ning Sun <sunning@greptime.com> --------- Signed-off-by: Ning Sun <sunning@greptime.com> |
||
|
|
5072612b77 |
chore: fix cargo-shear warnings in common-telemetry and session (#10595)
Signed-off-by: fys <fengys1996@gmail.com> |
||
|
|
3b2b67212a |
fix(servers)!: validate UTF-8 in unchecked Prometheus validation mode (#10593)
fix(servers): validate UTF-8 in unchecked Prometheus validation mode prom_validation_mode = "unchecked" built Strings from request bytes with String::from_utf8_unchecked. Invalid UTF-8 in label values produced invalid Strings, and the rows were written to WAL entries that fail to decode on replay. Make unchecked behave like lossy: invalid sequences are replaced with U+FFFD. The config value is kept for compatibility. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
8863133d88 |
fix(function): align INSERT negative len handling with MySQL (#10519)
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com> Co-authored-by: Boaz Shuster <boaz.shuster.github@gmail.com> |
||
|
|
f1b4dc695e |
fix(query): stop reporting CTEs as missing tables in range queries (#10397)
* test(query): cover range queries over derived inputs without a time index A range query over a CTE or an aliased subquery whose columns carry no time index fails with `Table not found: greptime.public.<alias>` (#5839), while the same input without an alias reports `Cannot find time index column`. Plan all three shapes in a planner test and expect the time index error, and add the CTE case to the `range/error` sqlness case. Signed-off-by: dayan02dev <pawarudayan92@gmail.com> * fix(query): report missing time index for range queries over CTEs `RangePlanRewriter::get_index_by` resolves each field qualifier of the range input as a table. A CTE or subquery alias is not a table, and the resulting `TableNotExist` was skipped only when some field still carried time index metadata. Without that metadata it was returned as is, so a range query over such a CTE failed with `Table not found: greptime.public.<cte>` (#5839). Skip qualifiers that are not tables in every case. The input then falls through to the existing time index metadata fallback or to `TimeIndexNotFound`, which the same input already gets without an alias. Signed-off-by: dayan02dev <pawarudayan92@gmail.com> * test(query): drop derived-input time index unit test covered by sqlness Signed-off-by: dayan02dev <pawarudayan92@gmail.com> --------- Signed-off-by: dayan02dev <pawarudayan92@gmail.com> Co-authored-by: dennis zhuang <killme2008@gmail.com> |
||
|
|
f15fd9a706 |
fix: reject JSON integers outside the u64/i64 range instead of rounding them (#10481)
* test: reject JSON integers outside the u64/i64 range Signed-off-by: dayan02dev <pawarudayan92@gmail.com> * fix: bump jsonb to reject integers outside the u64/i64 range Signed-off-by: dayan02dev <pawarudayan92@gmail.com> --------- Signed-off-by: dayan02dev <pawarudayan92@gmail.com> |
||
|
|
b26b87f914 |
perf(mito2): split seq scan ranges of files with disjoint primary keys (#10561)
* perf(mito2): split seq scan ranges of files with disjoint primary keys Seq scan merged every SST whose time range overlapped another into one partition range. Compaction outputs split by max_output_file_size cover the same time range with disjoint primary keys, so a compacted window was read and deduplicated by a single partition. Ranges are now merged only when both their time ranges and their primary key ranges overlap. Memtables and files without key statistics still overlap every key. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * perf(mito2): index open seq scan groups by primary key Grouping compared each range with every open group, so n files with disjoint keys in one time window took n(n-1) checks. Open groups now sit in a BTreeMap keyed by their min primary key; their key ranges are disjoint, so one range lookup finds every group to merge. Groups that ended before the current range are closed when a lookup reaches them. Per-series scans keep grouping ranges by time only. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * perf(mito2): merge the smaller seq scan range into the larger one A range that joined many groups, such as a memtable overlapping many files with disjoint keys, was appended to each group in turn and copied its growing index lists every time. Merges now append the smaller range to the larger one, so each index is copied O(log n) times. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(mito2): clarify the seq scan grouping invariant and lookup cutoff State that grouping keeps every version of a (primary key, timestamp) pair together, instead of "ranges in different groups never share a key", which read as if one key could not appear in two groups. Explain why the reverse BTreeMap walk can stop early: disjoint key ranges order their upper bounds the same as their lower bounds. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito2): split seq scan ranges by primary key only without a distribution TimeWindowed scans advertise (ts, primary key) ordering. Key-disjoint ranges that partition assignment reorders inside one partition would not keep it, so scans with any distribution keep grouping ranges by time. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(mito2): state that SeqScan does not keep the TimeWindowed ordering today Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito2): locate the primary key column by its top-level path A nested field such as a JSON child named __primary_key has the same leaf name and comes first, so the bounds and the primary key projection could read the wrong column. Closes #10582 Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(mito2): rename files_time_range_pruned to files_manifest_pruned Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
cdc1ec6b16 |
fix(table): restore dynamic statistics pruning for nullable keys (#10502)
* fix: restore dynamic statistics pruning for nullable sort keys Checkpoint: requires the complete DataFusion #25579 producer fix before integration. Local validation uses upstream-backport commit 92d537be1ee8395311daa4dce61d6e13fd0a458f; dependency pin is intentionally unchanged pending final acceptance. Signed-off-by: discord9 <discord9@163.com> * docs(table): remove empty line after dyn filter doc Signed-off-by: discord9 <discord9@163.com> * fix(table): keep PhysicalBinaryExpr import Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
b948fb78b1 |
fix(promql): plan absent_over_time over a nameless multi-metric selector (#10512)
`absent_over_time({job="x"}[20m])` was declined by the native route, and the plan it fell back to
answers with an error, so the shape produced no answer at all: the existing planner needs one
`__name__` equality matcher to read a table from (`Expect a metric matcher, but not found`).
The guard that declined it assumed that a nameless selector's tree declares `__name__` while binding
no metric name, and that the fused node refuses such a tree. That is not the shape: a discovered
selector's prepared input is the `Union` of one `RawSeriesSource` per metric, so the node is handed
explicit-label frames, and only its bare-region-scan arm reads the binding's name - an arm a nameless
selector never reaches, because a successful scan always binds one metric. A statement such as
`sum by (__name__) ({tag_0="x"})` over discovered metrics already builds and runs exactly this
combination.
The guard now declines only a nameless input that is not already sourced, which keeps the bare-scan
arm closed if that invariant ever regresses. The presence fold keeps the metric name, so two metrics
sharing ordinary labels stay two series and `absent` answers the empty vector, as Prometheus does;
a fold that dropped the name would have folded them into one series and answered wrongly.
`is_sourced_plan` is the existing predicate factored out of the child mapping, so the guard and the
mapping ask the same question. `FusedSeriesBinding::metric_name`'s doc no longer claims the logical
node requires a name whenever `tags` declares `__name__`; the requirement belongs to the bare-scan
arm of the physical planner.
A statement that mixes a multi-metric discovery with a single-metric selector was admitted and then
failed at physical planning: `build_inner_segment`'s multi-source arm wrapped every prepared plan in
a new `RawSeriesSource`, including plans that were already sources, and built
`RawSeriesSource(RawSeriesSource(TableScan))`, which the physical planner refuses after the statement
has been committed to this route. The arm now hands an already-sourced plan to the segment as it is
and wraps only real table scans (`is_sourced_plan`).
Regression: `absent_over_time({job="api"}[5m]) or ({probe_label="y"} + on(job) absent_a)` was
unanswerable before that fix and now runs a `FusedSeriesExec` and answers
`(120000, {job="api"}, 7.0)` and `(400000, {job="api"}, 1.0)`.
Not changed: a statement whose discovered table is partitioned still declines, because
`remote_raw_boundary` skips this builder and the alternative does not recognise a `Union`.
Signed-off-by: discord9 <discord9@163.com>
|