Files
greptimedb/tests-integration/tests
discord9 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>
2026-11-26 15:27:47 +00:00
..
2026-11-26 18:40:08 +08:00
2026-06-30 07:37:31 +00:00