-
Notifications
You must be signed in to change notification settings - Fork 378
fix(connectors): bound source forwarding channel with backpressure #3795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -219,6 +219,21 @@ Emitted fields: | |
|
|
||
| Filter the stream via `RUST_LOG=iggy_connectors::benchmark=info`. The corresponding stage durations are also recorded in the `iggy_connector_stage_duration_seconds` histogram regardless of this flag, so Prometheus dashboards remain available without enabling text events. | ||
|
|
||
| ## Source Channel Capacity | ||
|
|
||
| Each source configuration accepts an optional `channel_capacity` setting that bounds the channel between the plugin's send callback and the runtime's forwarding loop. Capacity is counted in batches (one `poll()` result each, potentially megabytes), not messages or bytes. The default is 1024 batches. | ||
|
|
||
| When the channel is full (Iggy accepts messages more slowly than the plugin produces them), the send callback backs off and retries instead of buffering without bound, so backpressure propagates into the plugin's polling loop. During shutdown, a batch that still cannot be enqueued after the stop signal is dropped and counted in `iggy_connector_errors_total`, so a saturated source may report errors at SIGTERM. Values outside `[1, 65536]` are clamped with a warning. | ||
|
|
||
| ```toml | ||
| type = "source" | ||
| key = "postgres" | ||
| # ... other fields ... | ||
| channel_capacity = 1024 | ||
| ``` | ||
|
|
||
| Environment override: `IGGY_CONNECTORS_SOURCE_<KEY>_CHANNEL_CAPACITY`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only the local config provider wires env overrides - with |
||
|
|
||
| ## Metrics | ||
|
|
||
| The runtime exposes Prometheus-compatible metrics via the `/metrics` endpoint when enabled. The following metrics are available: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,8 +147,11 @@ impl SourceManager { | |
| ) | ||
| }; | ||
|
|
||
| // Order: close FFI (stops callbacks) -> drop sender (unblocks | ||
| // recv_async) -> await tasks. Reversing risks an abort mid-save. | ||
| // Order: signal shutdown (unwedges a callback stuck in its | ||
| // full-channel backoff, which iggy_source_close waits on) -> close | ||
| // FFI (stops callbacks) -> drop sender (unblocks recv) -> await | ||
| // tasks. Reversing risks a deadlocked close or an abort mid-save. | ||
| source::signal_shutdown(plugin_id); | ||
| if let Some(container) = &container { | ||
| info!("Closing source connector with ID: {plugin_id} for plugin: {key}"); | ||
| (container.iggy_source_close)(plugin_id); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return code dropped, and the new ordering's safety argument leans on close actually stopping callbacks - the sdk returns -1 when it can't join the polling task, and then callbacks can outlive the close and land on the removed-entry branch that drops with no metric. |
||
|
|
@@ -229,6 +232,7 @@ impl SourceManager { | |
| key, | ||
| config.verbose, | ||
| config.benchmark, | ||
| config.channel_capacity, | ||
| producer, | ||
| encoder, | ||
| transforms, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this undersells the failure: the drop isn't just an error count - a later batch can still enqueue and persist its state, moving the saved position past the dropped batch, so the data is silently gone (see the send-callback comment). it also happens on connector restart via the api, not only at SIGTERM. once the fix lands this should state the guarantee: replay from the last delivered batch's state - duplicates for offset-mode sources, permanent loss for
delete_after_read/processed_columnones. same wording lives in the connector-runtime skill doc.