* feat: add a dedicated http api server port
* fix: integration test
* refactor: make http-api-port opt-in
* refactor: rename attribute to http-api-server
* feat: use middleware to check different http server port
* refactor: rename config option
* refactor(mito2): run compaction picking in background with plan tracking
Move the compaction picker out of the region worker's critical path by
dispatching planning to a background task and reporting the result back
via CompactionPickFinished. CompactionStatus now tracks an explicit
picking phase keyed by a monotonic plan id, so stale planning results
are rejected and duplicate regular triggers coalesce while picking.
Before submitting a prepared compaction, the picker output is refreshed
against the current SST version (file handles are re-resolved and
conflicts roll back reservations), ensuring the plan still matches live
state. CompactionExecution identifies the running task by
(plan id, kind, version control) so finish/cancel/fail notifications
from outdated executions are ignored.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): notify pick finished even when compaction planning panics
The worker only leaves the picking phase after receiving the
CompactionPickFinished notification. Previously the planning task was
spawned fire-and-forget: if it panicked before sending the notification,
the region would be stuck in the picking phase forever, blocking all
future compactions and pending DDLs (e.g. entering staging) of the
region.
Wrap the planning future with catch_unwind so a panic is converted into
a CompactionPlanningResult::Error and the notification is always sent,
letting the worker run the normal error cleanup path.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): dec inflight compaction gauge after re-entrancy guard
DefaultNotifier::notify decremented INFLIGHT_COMPACTION_COUNT before the
re-entrancy guard, so a duplicate notify (which should never happen, but
the guard exists to defend against it) would decrement the gauge an
extra time and let it drift negative. Move the decrement after the
guard, matching the local compaction path's guard-then-account order.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): remove idle compaction status to prevent zombie state
When a compaction finished within min_compaction_interval with no
pending requests, on_compaction_finished left an idle status
(phase = None) behind. The worker then skipped chaining the next
compaction due to the interval gate, and the leftover status made
schedule_compaction swallow all future triggers of the region: regular
waiters were queued but never woken, and manual requests stayed pending
forever. The region stopped compacting until close/drop/truncate.
Add CompactionScheduler::remove_idle_status and call it from
handle_compaction_finished when the interval has not elapsed and no
chained planning is scheduled. The chain-until-no-plan semantics for
compactions that outlast the interval is preserved.
Also drops an unused import left by the previous commit.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): make compaction scheduling methods synchronous
schedule_compaction, handle_pending_compaction_request and
schedule_next_compaction no longer await anything after compaction
planning became fire-and-forget. Drop the async signature to make the
no-suspension-point invariant explicit: these methods always run to
completion on the worker loop without reentrancy.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): report stale compaction execution instead of region closed
When a compaction finishes but its execution no longer matches the
current one, the region may have been reopened or truncated, or the
compaction was superseded. Reporting RegionClosed to waiters is
misleading; introduce a neutral StaleCompactionExecution error (same
Cancelled status code) for this case.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): serialize truncate with compaction
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): avoid panic-based compaction status lookups
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): keep in-flight compaction plan when scheduling next
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): notify cancelled compaction pending ddl
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* typo: rename prefence to pre_fence to bypass typo check
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* test(mito2): trim redundant compaction tests
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* test(mito2): move compaction tests to dedicated file
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix: typo and format
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* Revert "test(mito2): move compaction tests to dedicated file"
This reverts commit e202f1f5
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* chore: revert test movement
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): remove redundant compaction status lookups
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix: typo
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* test(mito2): remove duplicate compaction test file
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* test(mito2): prune redundant compaction tests
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): simplify compaction plan identity
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* docs(mito2): design pending regular state simplification
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* docs(mito2): plan pending regular state simplification
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): simplify pending regular compaction state
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* remove: plan files
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): clarify compaction completion handling
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): inline compaction phase execution lookup
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): warn instead of panic on pending DDL for non-compacting region
add_ddl_request_to_pending unwrapped the region status and panicked when
the region was not compacting. Log a warning and skip the request instead,
and inline the now-trivial CompactionStatus::queue_ddl helper.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): dispatch pending DDLs before chaining regular compaction
A DDL queued behind a TooLateToCancel compaction (commit started or
remote execution) was deferred behind a whole extra plan/execution
cycle when a regular trigger had been retained during picking. Dispatch
the pending DDLs as soon as the current task finishes instead: satisfy
the retained regular waiters with the just-finished compaction, remove
the region status, and return the DDLs immediately.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): demote stale compaction failure logs to debug
Check region presence and execution staleness before logging, so a
superseded execution's terminal failure no longer emits a misleading
error log.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): atomically queue compaction DDLs
Combine compaction cancellation and dependent DDL enqueueing under one
status borrow. Return the typed request unchanged when no compaction is
running, avoiding both an unreachable warning branch and silent DDL
loss if the invariant changes.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* docs(mito2): explain why picker output handles are re-resolved
Addresses review question on refresh_picker_output: picking runs in
background on a possibly-stale version snapshot, so handles must be
re-resolved against the current version at accept time to detect
removed files and to read/reserve the up-to-date handle.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): keep compaction gate in test module
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* style(mito2): format compaction DDL helper calls
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): group active compaction state
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): fence compaction triggers behind pending DDL
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* refactor(mito2): simplify pending DDL collection in compaction scheduler
Replace the take-and-restore dance of the active compaction state with
an up-front busy check before handling pending compaction requests,
then take the active state once to drain DDL waiters.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* docs: clarify that pending_request only carries manual StrictWindow compaction in production
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(mito2): arm DDL gate before cancellation
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
---------
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(prometheus): make remote write timeout retryable
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(prometheus): enforce pending row timeout budget
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(prometheus): skip pending-row timeout fallback when batcher is disabled
PendingRowsBatcher::try_new returns None when max_batch_rows,
max_concurrent_flushes, worker_channel_capacity or max_inflight_requests
is zero, meaning remote writes bypass batching entirely. The timeout
fallback predicate now mirrors these enablement conditions so the HTTP
timeout is not raised when no request can wait for a pending-row flush.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
* fix(prometheus): skip pending-row timeout fallback in async batch mode
With PENDING_ROWS_BATCH_SYNC=false, pending-row submissions return right
after enqueue and no request waits for a flush, so raising the global
HTTP timeout only delays unrelated routes. Export the batch sync mode
predicate from the servers crate and consult it in the frontend's
effective_http_options so the fallback is skipped in asynchronous mode.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
---------
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
Align the shortened trailing evaluation bound relative to the query start so non-epoch-aligned queries retain their final valid window.
Signed-off-by: discord9 <discord9@163.com>
When a compaction finishes with no pending request/DDL, on_compaction_finished
leaves the region's CompactionStatus in the map with no active compaction. If
the worker then skips schedule_next_compaction because min_compaction_interval
has not passed, the stale status is never cleaned up: all subsequent compaction
requests are swallowed by the "status exists" branch (regular waiters hang,
manual StrictWindow requests pend forever) and the region never compacts again
until restart.
Add CompactionScheduler::remove_inactive_status() and call it from
handle_compaction_finished when the interval gate skips scheduling the next
compaction, restoring the invariant that a status in the map always has an
active compaction.
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
Parse PostgreSQL DSNs (URL or libpq keyword) with tokio_postgres::Config —
the backend's own parser — and log its Debug, which redacts the password.
This matches the backend grammar exactly (multi-host URIs, backslash
escapes, any Unicode whitespace, percent-encoded query keys, and '&'/';'/
'://' inside values) rather than approximating it by hand. Other URLs are
redacted via the url crate; a best-effort keyword fallback covers inputs
neither parser accepts.
Signed-off-by: raphaelroshan <raphaelroshan@gmail.com>
* docs: add entity relationships and graph query RFC
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: revise entity-graph RFC after review
- Zero-configuration declarations: the Prometheus-on-Kubernetes convention
pack (job/instance per the OTel-Prometheus compatibility spec, k8s SD
labels, *_info descriptors, target_info enrichment) alongside the OTLP
trace auto-stamp, plus Remote Write 2.0 inline metadata.
- Calls endpoints follow the service entity declaration; self-calls
compare full endpoint ids; no silent identity fallback.
- Strict time-window contract: the source window is never narrower than
the query's observed_at range; unsafe-to-extract predicates error
instead of silently defaulting.
- scope removed from the relationship schema (kept on entities as a
display property); entity row contract restated per projected
observation; endpoint encoding documented as the v1 storage-level key
with its known collision limitation.
- Sampling caveats corrected (ratios are representative only under
unbiased sampling); snapshot relation synthesizes endpoint-only
vertices; shared attributes provide join keys while co-declaration
provides relationship semantics.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: align entity-graph RFC contracts and tighten prose
- Metric/trace service unification is promised only when service.namespace
is empty and job is not relabeled (the compatibility spec renders job as
<namespace>/<name>); otherwise alignment needs pipeline normalization or
explicit declarations.
- Entity row contract stated once (per projected observation); the calls
defining SQL is marked as the single-column simplification of the
declaration-derived endpoint ids; Remote Write 2.0 metadata intake and
the Prometheus implicit declarations are listed as M1 work.
- Compress survey/example/reference prose.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: pin down the k8s convention pack rules and edge directions
- kube_pod_owner implicitly declares k8s.workload with id
(namespace, owner_kind, owner_name) and derives pod part_of workload;
target_info's non-job/instance labels are implicit service descriptive
columns — fixed rules, no new declaration syntax.
- One direction for pod placement: k8s.pod runs_on k8s.node (pod added to
runs_on sources; node->pod removed from contains).
- Drop the remaining 'canonical' wording for the v1 storage-level id.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: make contains/part_of a true inverse pair
part_of covers service.instance->service and k8s.pod->k8s.workload with
contains as its inverse; has_instance is dropped.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: rewrite entity-graph RFC as a design narrative
Restructure for human review: mainline first, cases illustrate the
design instead of specifying it.
- New Architecture and Benefits and Drawbacks sections; the calls
derivation stays expanded as the flagship example while schema
enumerations, window-rule listings, and executor edge-case handling
move out of the document.
- The cross-signal promise is stated honestly: neighbours and their
source tables are discovered first, their telemetry is the next
query — one engine, two statements; the worked example shows the
full declaration -> entity -> edge -> telemetry flow.
- Default materialisation added as the most direct alternative to
read-time derivation, with its costs.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: final wording pass on the entity-graph RFC
Mark the property-graph DDL as illustrative rather than settled M2
syntax, credit standards as foundations rather than claiming wholesale
alignment, and clean up punctuation-heavy prose.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: keep the RFC at design altitude
Demote the convention-pack rule details and snapshot property-merge
semantics to the implementing changes; correct the single-trace-table
assumption (traces can be routed to multiple tables); record
attribute-key participation in entity equality as an open question.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* docs: correct service graph terminology
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
---------
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>