Skip to content

[connectors] Show which steps an output connector dropped - #8201

Open
bestouff wants to merge 4 commits into
mainfrom
issue-8097
Open

bestouff wants to merge 4 commits into
mainfrom
issue-8097

Conversation

@bestouff

@bestouff bestouff commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Linked Issue

Fixes #8097. Follow-up of #8014, #8017 and the closed #8018.

What changes

When an output connector drops output, a user could not find which input that output came from. A completion token is complete also for dropped output (intended, not changed). The status of the connector had the error text and the counters, and nothing that links a dropped batch to a token.

The output thread knows the steps of each batch that it gives to a connector. This PR records them, as the issue proposes.

New in the API Meaning
dropped_steps in the status of an output connector A list of {first_step, last_step} ranges (both included) of steps whose output the connector did not write completely. Ascending, ranges that touch are merged, at most 100 ranges, current run only
step in a connector error The last step of the batch that the output connector was writing when it reported the error. Not set for input connectors and outside a batch

A client keeps the step that /completion_status returns for the token of each request. A request with step S, whose previous request on the same input connector has step P, can have missing output if a range overlaps [P, S]. The docs of completion tokens have this procedure and its limits.

Design decisions

Question Decision Reason
When is a batch dropped? Between batch_start and the return of batch_end, on the output thread: an encode error, a fatal transport error, a write that returns an error, or an explicit report of the connector (ControllerInner::output_batch_dropped). Delta Lake, Iceberg and DynamoDB make that report where they give up on a batch or on a part of it An error from another thread can belong to an earlier batch, so it gets no step and marks nothing. An error that is not fatal (Postgres pg_batch_start, when the batch is written again) does not count by itself
Which steps does a batch have? From the step after the last total_processed_steps that the endpoint reported, to the step of the batch The same counts already drive completion tokens. The range then has all the steps of a transaction when the batch is its commit, and the steps since the last flush for an output buffer
Snapshot The range starts at step 0 A snapshot has the output of all earlier input
Checkpoint The list is not stored A token is not valid after a restart
Step numbers The same as the step of a completion token, no conversion Both come from the step counter of the circuit thread

Known limits (in the docs)

  • A connector that reports a delivery failure after batch_end returned, or from a thread of its own, is not covered. The Kafka output connectors can do this. The deferred commit of distributed Delta Lake is not covered either.
  • An error that a checkpoint restored has no step: the list covers the current run.
  • The check can name a request whose output was written (several requests in one step, a batch that was written in part, a flush of the output buffer while a transaction is open).
  • The pipeline keeps only the newest complete token of each input connector, so a step that is read late can be too high.

This PR and #8196 both add a field to ConnectorError. The one that merges second needs a small rebase.

Describe Manual Test Plan

Test Result
New suite case dropped_steps_identify_the_failed_request: a real pipeline, an output endpoint that reports a fatal error for its first write. Two requests with tokens Pass: the step of the first token is in dropped_steps and is the step of the error; the step of the second token is in no range
Unit test of the step ranges of batches: no transaction, transaction, new endpoint, snapshot, counts that go back, output buffer Pass
Unit test of the endpoint status: fatal, not fatal, encode error, error outside a batch Pass
Unit tests: merge of ranges and the limit of 100, multihost merge, status JSON without the new keys Pass
Revert check: the failed flag of a batch is not set The suite case and the status test fail
Python: dropped_steps and step parsed, old replies accepted Pass
openapi.json and the web console types regenerated One new type and two new properties
Clippy with warnings as errors, all targets, feldera-types, dbsp_connectors, static-connectors Pass

Checklist

  • Unit tests added/updated
  • Integration tests added/updated
  • Documentation updated
  • Changelog updated

Breaking Changes?

  • OpenAPI / REST HTTP API / feldera-types / manager
  • Python SDK

Describe Incompatible Changes

Additive only. New optional fields in /stats and in the connector status. Rust code that builds a ConnectorError or an ExternalOutputEndpointStatus with a struct literal must add the new field.


/// Returns the last step of the batch that is in the connector, and marks
/// the batch as failed if `failed`.
fn record_batch_error(&self, failed: bool) -> Option<Step> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug (medium): This charges any error to whichever batch is active, including errors raised on other threads. Kafka FT report_fatal (kafka_ft_fatal) and the non-FT delivery and producer callbacks run on librdkafka threads. If one of them fires while a later batch is in flight, that later batch goes into dropped_steps and its step is stamped on the error. The batch that really failed is not in the list. So the user gets a wrong answer (a false positive plus a false negative), not just a missing one. I confirmed this with a unit test in which a fatal transport_error from a spawned thread during batch_start(5..5) produced dropped_steps == [5..5], while the real failure in 2..4 was missing.

Possible fix: record the output thread's ThreadId in batch_start, and only attribute errors (both failed and step) raised on that thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, confirmed. Fixed in db0a637 as you propose: batch_start records the output thread, and only an error from that thread gets the step and can mark the batch. An error from another thread has step: None. Your test is in as worker_error_during_the_next_batch_has_no_step (fails without the check: Some(5)).

| Transactions | The output of a transaction leaves at its commit. If the connector drops that output, the range has all the steps of the transaction. |
| Output buffer | If the connector drops a flush of its output buffer, the range has all the steps since the previous flush. |
| Initial snapshot | If the connector drops its initial snapshot, the range starts at step 0, because a snapshot has the output of all earlier input. |
| The connector reports the failure after the batch ended | The steps are not in the list. The Kafka output connectors can report a delivery failure in this way. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug (medium, docs): This row is not accurate today. A late Kafka failure is not simply left out. If another batch is in flight when the failure arrives, its steps are put in the list instead, and the error gets that batch's step (see the comment on record_batch_error). Either fix the code or say here that the range and the step can belong to an unrelated batch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in db0a637 with the code change: the row now says that a failure reported later or from a thread of the connector is not in the list and has no step.

@mythical-fred-oss

Copy link
Copy Markdown
Contributor

What I ran

Check Result
cargo test -p feldera-types adapter_stats 13/13 pass
cargo test -p dbsp_connectors --lib (pending_steps, dropped_steps_merge, output_errors_track) pass
static-connectors suite dropped_steps_identify_the_failed_request pass, 20/20 runs (no flakiness seen)
pytest tests/unit/test_stats.py 6/6 pass
rustfmt and ruff on the changed files clean

I also checked the step numbering. The token step (total_initiated_steps), BatchQueueEntry.step and total_processed_steps all use the same counter, so settle(N) → first_step = N+1 is not off by one.

Gates: tests, docs, changelog and the additive API change are all fine. No unsafe and no new dependencies.

bug (medium): errors raised on other threads (Kafka) are charged to the batch in flight. See the inline comments. This is the QA test I used, which passes and so confirms the wrong attribution:

+    #[test]
+    fn async_error_is_charged_to_the_batch_in_flight() {
+        // ... endpoint = Arc::new(OutputEndpointStatus::new(...))
+        endpoint.batch_start(range(2, 4));
+        endpoint.batch_end();
+        endpoint.batch_start(range(5, 5));
+        let e = endpoint.clone();
+        std::thread::spawn(move || {
+            e.transport_error(true, Some("kafka_ft_fatal"), &anyhow!("delivery failed"))
+        }).join().unwrap();
+        endpoint.batch_end();
+        let status = endpoint.to_api_type(true);
+        assert_eq!(status.dropped_steps, [range(5, 5)]);           // wrong batch
+        assert_eq!(status.transport_errors.unwrap()[0].step, Some(5));
+    }

missing (medium), test cases the PR does not cover:

  • The output-buffer flush path (enable_output_buffer) with a failing flush: the range should span all steps since the last flush.
  • A dropped initial snapshot through the controller: the range should start at 0. Only the unit test on PendingSteps covers this today.
  • An error raised on a non-output thread, as in the test above.

@bestouff
bestouff marked this pull request as draft December 3, 2026 14:07
@bestouff

bestouff commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. In db0a637: the thread fix (see the inline replies), and the three cases you listed:

Case Test
Error from a non-output thread worker_error_during_the_next_batch_has_no_step
Failed flush of the output buffer dropped_buffer_flush_covers_both_requests: the range covers the steps of both requests in the flush
Dropped initial snapshot through the controller dropped_initial_snapshot_covers_an_earlier_request: the range starts at 0

The two controller cases fail when the range of a batch is its last step only. 5 of 5 runs pass.

@blp blp added the connectors Issues related to the adapters/connectors crate label Dec 3, 2026
When an output connector drops output, a user could not find which
input that output came from. A completion token is complete also when
a connector dropped the output of its input, which is intended. The
status of the connector had the error text and the counters, and
nothing that links a dropped batch to a token.

The output thread knows the steps of each batch that it gives to a
connector. Record them:

- The status of an output endpoint has a new list, dropped_steps: the
  ranges of steps whose output the connector did not write completely.
  A batch counts as dropped when the endpoint reports an encode error
  or a fatal transport error between its batch_start and the return of
  its batch_end. The list merges ranges that touch, keeps 100 ranges,
  and covers the current run: a token is not valid after a restart.
- Each error that an output endpoint reports during a batch has the
  last step of that batch.

The steps use the numbers of the step of a completion token. The range
of a batch starts after the last step that the endpoint reported as
processed, so it has the steps of a transaction when the batch is its
commit, and the steps since the last flush for an output buffer. The
range of a snapshot starts at step 0, because a snapshot has the
output of all earlier input.

A connector that reports a delivery failure after batch_end returned,
as the Kafka connectors can, is not covered.

The docs of completion tokens tell how to compare the step of a token
with the ranges, and give the limits. The Python SDK, the OpenAPI
schema and the web console types have the new fields. The status
merge of a multihost pipeline takes the union of the ranges.

Fixes: #8097
Signed-off-by: Xavier Bestel <xavier.bestel@feldera.com>
The status of an output endpoint charged each error to the batch that
was in the connector. A connector that reports a failure from a thread
of its own (the Kafka delivery and producer callbacks) while a later
batch is in the connector put that later batch in dropped_steps and
gave the error its step, and the batch that failed was not there.

Record the thread that gives the batch to the connector. Only an error
from that thread gets the step of the batch and can mark it as
dropped. An error from another thread has no step.

The Postgres output connector reports some errors from its worker
threads, and reports a dropped batch as pg_batch_end from batch_end,
on the output thread, so its dropped batches stay in the list.

Add tests: an error from another thread during a later batch, a
dropped flush of the output buffer, and a dropped initial snapshot.

Signed-off-by: Xavier Bestel <xavier.bestel@feldera.com>
…ost order

- A connector that returns an error from a write (push_buffer, push_key
  or batch_end), as Redis does when it loses the updates of a batch,
  reports it with fatal=false. Such a batch now goes into
  dropped_steps too. The rule for errors from connector callbacks does
  not change.
- The empty-buffer path of the output thread settled the range on the
  counts of the buffer also for an entry with no counts. For a new
  buffered sink these are 0, so its next failed flush got a range from
  step 1. Settle only on an entry with counts.
- The multihost merge applied the limit of 100 ranges at each merge of
  two hosts, so the result depended on the order of the hosts. Each host
  keeps its limit, and the merge now takes the full union.
- Docs: how to choose the lower bound for overlapping requests on one
  input connector, and two more limits (rows that a connector skips,
  the deferred commit of distributed Delta Lake).

Signed-off-by: Xavier Bestel <xavier.bestel@feldera.com>
@bestouff
bestouff marked this pull request as ready for review December 4, 2026 16:50
@bestouff bestouff assigned swanandx and unassigned swanandx Dec 4, 2026
@bestouff
bestouff requested a review from swanandx December 4, 2026 16:55
/// Increment error counter. If this is the first fatal error,
/// save it in `self.fatal_error`.
fn transport_error(&self, fatal: bool, tag: Option<&str>, error: &AnyError) {
let step = self.record_batch_error(fatal);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug (high): fatal is used as a stand-in for "this batch was lost", but the integrated sinks report a batch they gave up as non-fatal, from batch_end on the output thread. Examples:

  • Delta Lake batch_end → give_up + output_transport_error(.., false, .., "delta_batch_end") (integrated/delta_table/output.rs:1567)
  • Iceberg give_up → "iceberg_commit", false (integrated/iceberg.rs:~390)
  • DynamoDB: a chunk that ran out of retries, false (integrated/dynamodb/output.rs:~885)

These are not OutputProbes, so the write_failed path does not cover them. Their dropped batches get a step on the error but never appear in dropped_steps, which is the gap that #8097 asks to close. The docs table only lists the distributed Delta Lake deferred commit and Kafka.

Suggestion: give connectors an explicit way to say "this batch was dropped", e.g. a batch_dropped(endpoint_id) on the controller, or a drops_batch flag next to fatal. Call it from each give_up path, and add a suite case with an Encoder-as-consumer sink that gives up in batch_end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 02cc982. New ControllerInner::output_batch_dropped(endpoint_id) marks the batch in the connector as one that lost output, on the output thread only. Delta Lake (give_up), Iceberg (give_up) and DynamoDB (a chunk that ran out of retries) call it. A write that returns an error uses the same call. Tests: dropped_step_on_explicit_report (a sink that is its own consumer and gives up in batch_end, with and without the call), dropped_step_on_delta_commit_error, dropped_step_on_iceberg_commit_error, and the two DynamoDB cases for a permanent failure. Each fails when the call does nothing.

@mythical-fred-oss

Copy link
Copy Markdown
Contributor

What I ran

Check Result
cargo test -p dbsp_connectors --lib (dropped_steps_*, output_errors_track_the_active_batch, worker_error_*, pending_steps_*) pass
cargo test -p static-connectors --test connector_suites -- controller::test::dropped_ (5 new suite cases), 15 runs 15/15 pass, about 0.16 s each, no flakes
uv run pytest tests/unit/test_stats.py 6 pass

bug (high): see the inline comment. The Delta Lake, Iceberg and DynamoDB sinks report a batch they gave up as a non-fatal callback error from batch_end, so those dropped batches never reach dropped_steps. Until this is fixed, or listed in the docs table, the feature misses the main sinks.

missing (medium): test cases the PR does not cover

  • An Encoder that is its own consumer (the shape of Postgres, Delta, Iceberg and DynamoDB) and gives up a batch in batch_end. This would have caught the bug above.
  • The encoder.encode() → encode_error path in a real pipeline. Only the status unit test covers it.
  • The push_key error path (outprobe_push_key).
  • Restart from a checkpoint. ConnectorError is stored in the checkpoint, so restored errors keep their step while dropped_steps starts empty. The docs say the list is "current run only", so either clear step when restoring or document it.

The feldera-pr-checks gates pass: tests, docs and changelog are present, the change is additive with serde(default), there are no new dependencies and no unsafe.

…ve up

The integrated sinks that are their own consumer report a batch that
they gave up as a transport error that is not fatal, from batch_end on
the output thread. So a batch that Delta Lake, Iceberg or DynamoDB
dropped had its step on the error and was not in dropped_steps.

Add ControllerInner::output_batch_dropped, which marks the batch in the
connector as one that lost output. It follows the thread rule of the
other reports: only a call on the output thread counts. Delta Lake,
Iceberg and DynamoDB call it where they give up on a batch or on a part
of it. A write that returns an error uses the same call. Postgres
reports a dropped batch as fatal, so it needs no change.

An error that a checkpoint restored kept its step, while dropped_steps
starts empty after a restart. Clear the step when the error lists are
restored.

Tests: a sink in the shape of an integrated connector that gives up in
batch_end, with and without the report; an encode error and a key
write error in a pipeline; a commit that fails in Delta Lake (local
table) and in Iceberg (mock catalog); the two DynamoDB cases for a
permanent failure; the restore of an error. Each one fails when the
report does nothing.

Signed-off-by: Xavier Bestel <xavier.bestel@feldera.com>
@bestouff

bestouff commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Status of the review points, as of 02cc982:

Point Status
Delta Lake, Iceberg and DynamoDB batches that were given up are not in dropped_steps Fixed, see the inline reply
Test: an Encoder that is its own consumer and gives up in batch_end Added: dropped_step_on_explicit_report
Test: the encoder.encode() error path in a pipeline Added: dropped_step_on_encode_error
Test: the push_key error path Added: dropped_step_on_key_write_error (Debezium format)
Restored errors keep their step after a restart Changed: the restore of the error lists clears step. Test: restored_error_clears_step. In the field docs and the docs table
Docs table The row on the kind of error names the explicit report and the sinks that use it

Not covered, as before and in the docs: the deferred commit of distributed Delta Lake, and delivery failures that the Kafka sinks report from their own threads.

@swanandx swanandx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A batch counts as dropped only when its error is fatal (record_batch_error(fatal) in transport_error). Some connectors give up on a batch with an error that is not fatal. For example, after its last retry the Iceberg output calls output_transport_error with fatal = false for iceberg_commit. That drop is not in dropped_steps, but its error gets a step. Please count any error that the output thread reports during a batch.

Also, the limit of 100 ranges removes the oldest ranges with no marker. An old token then looks safe. If you merge the two oldest ranges, the list stays correct.

Before more work on this, I think we need agreement that this API is useful, because #8018 was closed for that reason.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connectors Issues related to the adapters/connectors crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[connectors] A user cannot find which input an output connector dropped

3 participants