Files
greptimedb/tests/compatibility/wire/discard_pending_tails
jeremyhi 0ae7c1826b feat: add an admin function to discard pending WAL tails (#10477)
* feat: add an admin function that discards a datanode's pending WAL tails

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

* fix: refuse a tail discard over an unconfirmed manifest update and address review

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

* test: drop the integration test that repeats the admin function's region form

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

* fix: refuse a tail discard while a tail replay's update is uncertain

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

* build: pin greptime-proto to the branch that adds the pending tails truncate kind

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

* test: record the region id case of the discard_pending_tails sqlness test

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

* fix: track the uncertain replay update only without conditional publication and pin the truncate wire format

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

* test: simplify the truncate wire test

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

* test: cover the discard requests sent to regions and the metric data region

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

* test(mito2): pin the WAL history a discard relies on after a crash

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

* test(common-function): describe the mock pending tails discard

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

* fix(operator): report discard failures per region and clarify pending tails docs

Log each failed region of a by-table pending tails discard with its region id
and the tails the other regions discarded, derive the unsupported message from
the truncate kind, drop the unused feature parameter, document that a discard
raises the flushed entry id to the tail bound, and test discarding a kept tail
after a replay commit with an uncertain result.

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

* fix(operator): warn with the partial discard count and state the WAL history check precisely

Format request.rs, log the tails discarded by the regions that succeeded at
warn level when another region fails, state in the docs that an open checks WAL
history through the flushed entry id where the log store checks history and
that whoever adds a tail ensures it for every node that may lead the region,
and rename two tests after the outcomes they assert.

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

* docs(mito2): note that accepting missing WAL history opens a region past a discarded bound

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

* docs(mito2): rewrap the pending tails discard handler doc

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

* refactor(store-api): discard pending WAL tails with a dedicated region request

Carry the discard as RegionRequest::DiscardPendingTails, decoded from the
DiscardPendingTailsRequest body, instead of a truncate kind. Mito handles it as
a worker control request, so the truncate path no longer special-cases it;
the Metric Engine forwards it to a physical region's data region; the
frontend builds it for a region or for every region of a table, sharing the
table lookup with the discard of unflushed data. The wire fixture now pins the
new request body.

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

* refactor(metric-engine): give the pending tails discard its own error context

Report a failed discard as a pending tails discard rather than a truncate in
the Metric Engine, pin that Mito handles the discard as a worker control
request, state that physical_region_ids returns a logical table's physical
regions, and drop leftovers from the truncate kind in the tests.

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

* build: pin greptime-proto to the dedicated pending tails discard request

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

* build: pin greptime-proto to the merged pending tails discard request

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

---------

Signed-off-by: jeremyhi <fengjiachun@gmail.com>
2026-11-19 10:50:58 +00:00
..

Pending tails discard wire compatibility

A generated protobuf fixture of greptime.v1.region.RegionRequest, not a capture from a released binary.

discard_pending_tails.pb uses the schema at greptime-proto revision 8aa45418597636516410c0c892dbd0269754a02c, which adds DiscardPendingTailsRequest as body field 24. Logical contents: region 4398046511105 (table 1024, region number 1) and datanode 7.

SHA-256: 374e0c28eaee73e4df3f2e79a6345bf70caa589800c9eb5a19314d08a9ef5fa0.

Run the regression:

cargo nextest run -p store-api -E 'test(test_discard_pending_tails_request_wire)'

The test checks that the fixture decodes to a pending tails discard of that region and datanode, and that the decoded message encodes back to exactly the fixture bytes, so the request stays at body field 24.

Reproduce the fixture

With PROTO_ROOT pointing to the proto directory of that revision:

printf '%s\n' 'discard_pending_tails { region_id: 4398046511105 datanode_id: 7 }' |
  protoc --proto_path="$PROTO_ROOT" --encode=greptime.v1.region.RegionRequest \
    greptime/v1/region/server.proto > discard_pending_tails.pb