Replace the adaptive write watermark and hourly reclaimability checks
with two write-driven triggers. After committed writes, file size is
sampled at most every five minutes and a database at or above the size
watermark is checked for reclaimable space. Every writesPerCheck
writes, reclaimability is checked for any database above sizeWatermark,
so space released by deletions is found even when the file does not
grow. Idle databases are not polled.
After a successful compaction the size watermark is set to the
compacted size plus sizeGrowthPercent, with sizeWatermark as the
minimum, and persisted with the write counter. Compaction is pending
when either reclaim threshold is met. Share the threshold logic
between the scheduler, the compactor and the debug endpoint.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Expose database measurements through GET /debug/compaction and stream a single manual attempt through POST. Resolve requests against registered databases rather than opening user-supplied paths, reject cross-origin browser POSTs, and return busy measurements instead of blocking inspection behind maintenance.
Allow manual compaction whenever the debug listener is enabled, independently of automatic scheduling. Bypass the write watermark while retaining the idle period, reclaimability thresholds, free-space checks, and serialization across databases.
Cancel manual attempts cooperatively when writers arrive, clients disconnect, or the scheduler stops. Reject duplicate requests and deliver progress without blocking database maintenance on a slow HTTP client. Reuse the idle timer and share the scheduler's checkpoint cadence while waiting for a manual attempt.
Document the endpoints in the developer guide and test manual-only and combined modes, inspection during maintenance, origin checks, idle waiting, cancellation, duplicate requests, checkpoint timing, and shutdown.
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>