Skip to content
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

fix(sink): handle Kinesis PutRecords partial success and throttle #17983

Merged
merged 5 commits into from
Aug 13, 2024

Conversation

wenym1
Copy link
Contributor

@wenym1 wenym1 commented Aug 9, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

Changes on the doc of kinesis sink:

In kinesis sink, we use PutRecords to send multiple records in a batch to achieve higher throughput. Due to the limitation of kinesis, records might be out of order when using such API. Nevertheless, in the current kinesis sink implementation, we ensure at-least-once delivery semantic, and eventual consistency.

@github-actions github-actions bot added the type/fix Bug fix label Aug 9, 2024
@graphite-app graphite-app bot requested a review from a team August 9, 2024 05:23
Copy link
Contributor

@tabVersion tabVersion left a comment

Choose a reason for hiding this comment

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

basically LGTM, match the desc on the manual

Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

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

Thanks for the fix

src/connector/src/sink/kinesis.rs Outdated Show resolved Hide resolved
src/connector/src/sink/kinesis.rs Outdated Show resolved Hide resolved
Comment on lines +281 to +282
// PutRecords doesn’t guarantee the ordering of records. If you need to read records in the same
// order they are written to the stream, use PutRecord instead of PutRecords, and write to the same shard.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we acknowledge this limitation in doc as there is currently no user option to opt for ordering rather than batching?

}
if total_payload_size + *size < MAX_TOTAL_RECORD_PAYLOAD_SIZE {
total_payload_size += *size;
records.push(record.clone());
Copy link
Contributor

Choose a reason for hiding this comment

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

The need of clone here feels like a API design flaw in the AWS auto-generated SDK. I don't think we can do anything but just point it out.

Impact:
Every single message written out is cloned at least once.

Root cause:
AWS SDK takes the ownership away but does not give it back for failure retry.

Comment on lines 344 to 350
#[expect(rw::format_error)]
return Err(SinkError::Kinesis(anyhow!(
"failed to send records. sent {} out of {}, last err: {:?}",
start_idx,
total_count,
e.as_report()
)));
Copy link
Contributor

Choose a reason for hiding this comment

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

When wrapping an error and returning to caller (rather than handling/consuming the error as warn! below), use context:

return Err(
  SinkError::Kinesis(
    anyhow!(e).context(format!("failed to send records. sent {start_idx} out of {total_count}, last err:"))
  )
);

@wenym1 wenym1 added the user-facing-changes Contains changes that are visible to users label Aug 13, 2024
@wenym1 wenym1 added this pull request to the merge queue Aug 13, 2024
Merged via the queue into main with commit cd9c31e Aug 13, 2024
30 of 31 checks passed
@wenym1 wenym1 deleted the yiming/fix-kinesis-sink-put-records-partial branch August 13, 2024 07:16
@xiangjinwu xiangjinwu added the need-cherry-pick-release-1.10 Open a cherry-pick PR to branch release-1.10 after the current PR is merged label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-cherry-pick-release-1.10 Open a cherry-pick PR to branch release-1.10 after the current PR is merged type/fix Bug fix user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants