Repository navigation
fix(delivery): bound webhook/stream backlogs, fix duplicate listeners, wire ignored config (#64 W4) - #69
Merged
Conversation
…, wire ignored config (#64 W4) - H11: update_webhook swaps the config in place; removing or re-adding a webhook or stream stops its old listener (ListenerHandle drop signal). - H12: at most max_pending_deliveries per webhook and BufferConfig::max_events per stream are pending; listeners wait, overflow is dropped oldest-first and counted in dropped_events. Retry backoff no longer holds a concurrency slot. - H13: the webhook timeout covers the response body, which is read up to max_response_body_size. - M9: subscribe before add_webhook/add_stream return; remove the test sleeps. - M7: InMemoryStatsCollector uses a time-ordered VecDeque, O(1) amortised inserts and in-place window aggregation. - M3: deprecate PriorityWeights::with_fairness_factor (never applied; the weighted pick already prevents starvation). - M4: wire default_timeout_secs, global_flush_interval_secs, MetricsConfig::update_interval, StatsConfig max_event_age_secs and collect_timing, and [logging] (LoggingConfig::try_init); deprecate idle_timeout, cleanup_interval_secs, custom_thresholds and web request_timeout; document JobBatch::with_batch_size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodingAnarchy
force-pushed
the
fix/delivery-config
branch
from
October 9, 2026 23:50
4a4bb20 to
02210d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #64 (workstream W4): H11, H12, H13, M3, M4, M7, M9.
Fixes
update_webhookduplicated deliveryupdate_webhooknow swaps the config in the map in place. The one listener reads the current config on every event, and statistics are kept. Each listener selects on a stop signal (task_tracker::ListenerHandle, a oneshot whose sender is dropped). Removing a webhook or stream, or callingadd_webhook/add_streamagain with the same id, stops the old listener at once, even while it waits inrecv(). Streams had the same bug for re-adds.WebhookManagerConfig::max_pending_deliveries(default 1000, alsowebhooks.global_settings.max_pending_deliveries). Streams have a per-stream semaphore ofBufferConfig::max_eventsevents, so the existing setting now bounds in-flight events. Policy: backpressure. When a webhook or stream is full, its listener waits. New events stay in theEventManagerbroadcast buffer, and once that overflows the oldest are dropped for that listener, logged atwarn, and counted in the newWebhookStats::dropped_events/StreamStats::dropped_events. Memory stays bounded however long the endpoint is down. Retries now take the globalmax_concurrent_deliveries/max_concurrent_processorspermit per attempt, so a dead endpoint waiting out backoff no longer starves the other webhooks.timeout_at) covers send and body read. The body is read chunk by chunk up tomax_response_body_size, then the connection is dropped. If the status arrived but the body timed out, the attempt counts by its status, so a 2xx is not retried and duplicated.add_*add_webhook/add_stream, and its receiver moves into the listener task (noresubscribe()). The 100 ms "let the listener start" sleeps are gone from the webhook and stream tests. The remaining waits poll a condition.InMemoryStatsCollectorkeeps a timestamp-orderedVecDeque. Inserts are amortised O(1): append, with a rare near-back insert for late events, and pruning from the front by age and size. A query binary-searches the window start and aggregates in one pass by reference, with no 100k-event clone per alert poll.with_fairness_factorignoredWebhookManagerConfig::default_timeout_secsapplies when a webhook hastimeout_secs = 0, which is now also the serde default.StreamManagerConfig::global_flush_interval_secscaps every stream's buffer time.MetricsConfig::update_intervalsets the worker monitoring interval, previously hard-coded to 30 s, with a 1 s minimum.StatsConfig::max_event_age_secsis applied on insert.StatsConfig::collect_timingworks.[logging]is applied by the newLoggingConfig::try_init(): EnvFilter level, JSON, file/line, and OTLP export with thetracingfeature (init_tracing's provider setup was factored intoinstall_tracer_provider).JobBatch::with_batch_sizeis documented as what it actually is, theinto_chunkssize. Deprecated (no sound meaning):AutoscaleConfig::idle_timeout,StatsConfig::cleanup_interval_secs(pruning now happens on every insert),AlertingConfig::custom_thresholds, and webDashboardConfig::request_timeout. warp 0.4 has no request-timeout hook, and wiring one would need a custom hyper server. All of these keep compiling and parsing, and are#[serde(default)]where they were required. Note:request_timeoutwas not wired by W1 on master. Websession_timeoutand the WebSocket limits were.M3: why deprecate rather than implement
Weighted selection (
pick_weighted_priority, andTestQueue's equivalent) already picks each priority that has runnable jobs with probabilityw / Σw, so a non-zero weight cannot starve. A fairness blend such as(1-f)·w/Σw + f/nis well defined. But implementing it would:PriorityWeights::new()already sets 0.1;src/queue/*, which W2 is editing.Raising a weight already does what users wanted. The value still parses from config files and is stored, but is documented as having no effect.
Behaviour changes
update_webhook, and an unknown id is still added.timeout_secs = 0uses the manager default; before, it timed out immediately.min(max_buffer_time_secs, global_flush_interval_secs). The listener sleeps until that deadline instead of polling every second. Before, a lone event after an idle period was flushed immediately.update_interval(15 s default) instead of 30 s.InMemoryStatsCollectordrops events older thanmax_event_age_secs(1 h default) automatically.WebhookManagerConfig,WebhookGlobalSettings,WebhookStatsandStreamStats.tracing-subscriberenablesjson, which addstracing-serdetoCargo.lock.add_webhookalready did.Coordination with W2
src/worker.rshas a small diff (+23/−7):start_monitoring_task, where W2's M8/M10 also work;idle_timeoutdeprecation attributes inAutoscaleConfig, next to W2's H9;idle_timeout.Nothing in
src/queue/*or migrations changed. Expect at most trivial conflicts.Tests
New tests:
max_pendingin flight, then delivered + dropped = published and dropped > 0 (webhook and stream).ListenerHandle/clamp_permits.collect_timing, priority and queue aggregates.Results:
cargo fmt --all --checkandcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo clippy -p hammerwork --lib --tests --no-default-featureswith"",postgres,postgres,webhooks,postgres,streamingandmysql,tracing: clean.cargo test -p hammerwork --lib --no-default-featureswith""(266 tests),postgres,webhooks(337) andpostgres,streaming(334): pass.cargo test --workspace --all-features --no-fail-fast -- --include-ignored --skip mysql: 1816 passed, 0 failed.-- --include-ignored mysqlwith both URLs set to MySQL: 150 passed, 0 failed.--features postgres,mysql,test,encryption,tracing,streaming,kafka: 525 passed.There is no automated "unread config field" guard. I didn't find a cheap, reliable way to write one.
🤖 Generated with Claude Code