Repository navigation
fix: follow-ups from the review of #28 to #37 (#38) - #40
Conversation
…ng share within its limit files.failing_reported is now the last finish's failing count, so a load fixed by a Retry raises its alert again when it regresses. The rejected_share clear message no longer rounds 9.96% up to the 10% limit. A contact also refuses the invisible format characters. Refs HeliosSoftware#38
…ut an unknown zone Refs HeliosSoftware#38
A negative limit listed every alert on SQLite under the store's only connection. limit is now 0 to 1000; anything else answers 400 invalid_query with field limit, and every alert is read by following next_cursor. Refs HeliosSoftware#38
…tion start_all opened a write transaction per source on every start; on a shared SQLite file, a lock held past the busy timeout failed the start. The birth is read first, and only a source never seen writes. Refs HeliosSoftware#38
…objects With bulk_from auto, a passthrough NDJSON or Bundle source hands HFS its objects untouched, so stamp_source cannot tag them. Each start of such a source now says so. The docs say the stamping reset is store-wide. Refs HeliosSoftware#38
… held The ten-second slack before an untagged REST request was measured from before the wait for the store's only connection, so another source holding it twice in a row failed REST delivery. The instant is now taken once the connection is held, and checked right before the request leaves. Refs HeliosSoftware#38
…er changes nothing The submission guards keyed on attempts, which a successful kick-off sets back to 0: after a takeover's failure and success, the late answer of the earlier runner matched again and could fail an accepted submission, log a spurious failure or replace the status URL. A submission now has an epoch that only goes up: claimed before each kick-off and poll, and moved by every state change. Each write of an answer holds only under its own claim. Also updates the finish test to the lowered failing mark. Refs HeliosSoftware#38
A deleted source's open delivery alert was never cleared, so a source created again with its id raised no alert for its first outage. Once the runner has ended, a delete clears the source's open delivery and credential alerts, unless another instance holds the source. (Reworked later in this branch: see the commit that simplifies it.) A replace that waited for the lock while the source was deleted now answers 404. Refs HeliosSoftware#38
…go between
Each /api/loads page aggregated every row of up to 200 loads while
holding the store's only connection. The page's ids are now chosen in
one statement and each load is read in one of its own, with the
connection let go and a short pause between two: a concurrent store call
waits for about one load's count (570 ms to 3 ms measured on 200 loads
of 10 000 rows). /api/sources/{id}/loads takes limit 1 to 1000, and
/api/loads refuses parameters it does not read.
Refs HeliosSoftware#38
A family filter was a LIKE that SQLite's kind index cannot serve, and a filter matching rarely walked the whole log under the store's only connection. A family is now its exact kinds, and a request reads at most 50 000 events past where it starts: stopping there, it answers has_more with next_cursor at the last event read, even with nothing listed. since only filters; without a cursor reading starts at the oldest event kept. Refs HeliosSoftware#38
covered_from came from this instance's retention, so on a store shared with an instance that keeps less, purged days read as complete. A purge records its cutoff in the store, and covered_from takes it into account, read after the counts. Refs HeliosSoftware#38
…he answer before it counts A delivery that timed out or lost its connection let the idle probe flip reachable back to true when HFS still answered /metadata; it now outweighs the probe as 502 to 504 do. A REST answer counts only once its body is read whole: a connection broken while it arrived is a lost connection, and the attempt may pass. Refs HeliosSoftware#38
- A submission is claimed only while no other instance holds its source's lease, so a runner whose lease lapsed mid-pass cannot take it from the one that took the source over. - The alert sweeps of a deleted or created source take the lease (replaced by the next commit, which drops the create sweep). - A truncated 401 or 403 still invalidates the engine's token. - Pages of loads are read on a blocking thread. - An unfiltered /api/events request reads no span: its LIMIT bounds it. - Tests: two instances claiming at once, a lapsed lease, the kind index. Refs HeliosSoftware#38
…runner's own lease - A deleted source's delivery and credential alerts raised before the delete are cleared once its runner has ended, with the lease checked in the same statement; the sweep takes no lease. An alert raised after the delete is never its to clear. - No sweep at create: an outage alert from before the source's birth no longer keeps it from raising its own, and its first recovery clears both. This drops the deferred sweep and its races. - A runner that runs under the source's lease claims a submission only while it still holds that lease. - The EXPLAIN test reads the statement list_events builds; a truncated 401 or 403 ends the in-flight request before the token is refreshed. Refs HeliosSoftware#38
…ts once its runner has ended - A runner stopped by a delete or a replace raises no delivery or credential alert, even for a request that fails after the stop. - The delete's clearing takes its cutoff once the runner has ended, and asks for the lease in each clearing statement. - A runner under the lease renews it before moving its submissions, and its claim takes the instant once the store is held. Refs HeliosSoftware#38
|
Thanks, this is careful work. Items 2 to 6 of #38 are fixed, and I traced each scenario through the new code. #39 is merged. Two things to fix before this merges. Line numbers are at 1248018. 1. A lease that lapses mid-pass stops the remaining submissions from being claimed.
2.
Minor:
|
… warning; docs for the review
…t and pages read their index; drain bulk successes
…o; docs for the review
…ource or kind through its index; keep only refusal bodies
|
Thanks for tracing it through. Everything below is in 1. The lease lapsing mid-pass. Fixed.
2.
Minor points:
One more change. Since your review, I found that a source file holding a contact with one of the invisible characters this PR refuses would stop the engine from starting. Only pre-release builds could have saved one.
Checks on
|
Closes #38: items 2 to 6 and the remaining minors. Item 1 and the #30 minors landed in #39. This PR also answers the review on this PR (see the comment below it).
What changes
Item 2: a late kick-off answer can no longer change a submission.
submissionsgainsepoch, a counter that only goes up.attemptsstays in the guard, so an earlier version sharing the store (which moves attempts but not the epoch) is still fenced. A refusal is logged only once it took.Item 3: a deleted source's outage alert no longer stays open for good.
deliveryorcredentialalert, even for a request that fails after the stop.deliveryalerts (with a rule or without) and itscredentialalert are cleared with the reason<id>: the source was deleted. Each clear checks, in its own statement, that no other instance holds the source's lease.deliveryorcredentialalert raised before the source's birth no longer keeps it from raising its own. (A create through the API sets the birth again.) A source created again raises its own alert and webhookfired. Its first successful delivery, or its credential loading, clears both.PUTthat waited for the source's lock while the source was deleted now answers404.Item 4: the untagged-write slack counts the write, not the wait for the store. The instant is taken once the store's connection is held, and checked right before the request leaves. The database's own lock waits still count.
Item 5: one
/api/loadspage no longer holds the store for the whole page.The page's ids, and whether more match, come from one statement.
Each load's row and counts come from one statement of their own. Between two loads the connection is released, with a 100 µs pause: the store's mutex is not fair, and without the pause the reading thread takes it straight back.
The page is read on a blocking thread.
Measured on SQLite with 2 million rows, the longest wait of a concurrent store call during a page:
That is about one load's count. A page takes about 20 ms longer.
Item 6:
/api/eventsreads a bounded part of the log per request.kind IN (...)), which theevents_kindindex serves.sourcealone, or one exact kind read through the primary key,events_sourceorevents_kind, and stop atlimit. SQLite is told the index. PostgreSQL gets the range as a row value over the index's columns, which only the index can serve.sincestarts just before the lowest id among the events fromsinceto five minutes after the first of them, found throughevents_aton both stores. An event stored after another carries anatat most that far behind it. Instances sharing a store already need closer clocks than that: a lease lasts 30 s at least.sinceonly filters.since, asourcewith akind, and several kinds read at most 50 000 events past the start. A request that stops there before the newest event answershas_more: true, withnext_cursorat the last event read, even with nothing listed.Minors.
/api/alertslimitis 0 to 1000. A negative value or one above 1000 answers400 invalid_querywithfield: limit.events_purged_before, only ever later)./failurestakes it intocovered_from, read after the counts./api/loadsrefuses a parameter it does not read, instead of ignoring it.$bulk-submitor$bulk-submit-statusanswer, counts only once its body has been read whole. A truncated 401 or 403 still renews the token.warnonce per rule and zone. Amissing_byclear names the day the file arrived on. A pushed deadline's alert clears at the next pass that finds a file of the current day, like any openmissing_byalert; this is now documented.warnnaming the source.stamp_sourcecannot tag logs a warning at start. The docs say the stamping reset is store-wide.failing_reportedis the last finish's count, so a load that fails again after a fix raises its alert again. The clear message shows the share within the limit (9.96% against 10% reads9.96%).Not done, for you to decide:
safe_reason. A URL's path can carry a submission token or credentials, and anidentifier=value can be a patient identifier. Which ones are safe to keep whole is a policy call.firedandcleared, and the claim leases.main);/metrics(feed_counts) and the monitoring statussentcount also aggregate under the one connection;Docs: amendments to decisions 38, 39, 42, 43, 44, 45 and 47, plus
docs/api.md,docs/sources.md,docs/running.mdanddocs/development.md.In plain words
A slow answer from HFS can no longer undo what a newer runner did with a bulk submission, or keep the runner from moving the next ones. A deleted source no longer leaves alerts that hide the next ones. Large stores no longer stall the engine while someone lists loads or reads the event log.
Side effects checked
/api/sources/{id}/loadsand/files:limitis 1 to 1000. 0.2.0 took any value, and listed every load for a negative one on SQLite. Another value answers400 invalid_query,field: limit./api/alerts:limitis 0 to 1000. 0.2.0 took any value: a negative one listed every alert on SQLite and answered500on PostgreSQL. Read every alert by followingnext_cursor./api/loads: a parameter it does not read answers400 invalid_query, a cache-buster such as?_=<time>included. This list is in no release (git show v0.2.0:src/api.rshas no/api/loadsroute), so this breaks only builds ofmain./api/events(in no release): a page can be empty withhas_more: true. Keep reading whilehas_more, and stop onfalse, not on an empty page. A family no longer matches a kind that a newer version adds to it. An event whose instance's clock was more than five minutes ahead may be left out of asinceread without a cursor, and of the pages that follow from it./api/loads: a load's fields may be newer than the choice of its page: a load listed understatus=failedcan showfailed: falseif a Retry fixed it in between.submissions.epochand theevents_purged_beforemark are added in place.covered_from.4xxrejected the records or failed the submission. A cut-off bulk kick-off is sent again; HFS answers the repeat with409, read as already held.How to verify
The CI commands, with
CI=trueand default parallelism, on this tree (Linux):Every suite ran twice more on SQLite and twice against a throwaway PostgreSQL 16:
Each fix has a test that fails without it:
tests/events.rs, on both stores):tests/api.rs: a deleted source's outage and credential alerts are cleared once its runner ends. Left open: another kind, an alert raised after a later delete, and one while another instance holds the source. A delivery held across a delete and a create, which then fails, raises nothing for the stopped runner.tests/destination.rs: an outage alert from before the source's birth does not hide its outage, and recovery clears both.src/pipeline.rs: the same for acredentialalert, cleared with the earlier one once the credential loads.src/db.rs): with another thread holding the store's connection for 400 ms, the slack starts once the connection is held, and the bound is from after the wait.src/db.rs: another caller's write lands between two loads' reads, and the next load sees it;src/db.rs, on both stores):sincewithout a cursor lists its first event on the first page, past more than a span;atincluded;limit; a purged gap costs nothing;events_kindandevents_sourcefor one kind or source whose events first appear late in the log, andevents_at, not the primary key, for wheresincestarts, before and afterANALYZE.tests/alerts.rs,tests/events.rs;tests/loads.rs;src/destination.rs, a server that cuts the body off intests/destination.rs, and the same for a bulk kick-off insrc/bulk.rs;src/alerts.rs,tests/alerts.rs;src/db.rsunder a held SQLite write lock;src/config.rsandtests/api.rsfor the contact (refused on write, loaded from a saved file);src/config.rs;tests/pipeline.rs(fixed then failing again),tests/events.rs,src/pipeline.rs.Links