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(r2dbc): Leak of in-flight offsets #1300

Merged
merged 2 commits into from
Jan 18, 2025
Merged

Conversation

patriknw
Copy link
Member

  • concurrency issue in R2dbcOffsetStore when saving offsets in case of concurrent modifications
  • map vs flatMap
  • DynamoDB was correct
  • added some more logging

* concurrency issue in R2dbcOffsetStore when saving offsets in case of concurrent modifications
* map vs flatMap
* DynamoDB was correct
* added some more logging
@patriknw patriknw requested a review from pvlugter January 17, 2025 10:56
@@ -630,15 +652,19 @@ private[projection] class R2dbcOffsetStore(

val offsetInserts = dao.insertTimestampOffsetInTx(conn, filteredRecords)

offsetInserts.map { _ =>
offsetInserts.flatMap { _ =>
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the bug. I think it was introduced in a recent version when the lazy loading of offsets was added.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼 Not noticed in #1255

@@ -656,8 +682,9 @@ private[projection] class R2dbcOffsetStore(
}
if (newInflight.size >= 10000) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I have also tested this in a real service where I logged the inFlight size and could see that it was increasing over time. After the fix it is 0 after each save offsets, as expected.

Copy link
Contributor

@pvlugter pvlugter left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -630,15 +652,19 @@ private[projection] class R2dbcOffsetStore(

val offsetInserts = dao.insertTimestampOffsetInTx(conn, filteredRecords)

offsetInserts.map { _ =>
offsetInserts.flatMap { _ =>
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼 Not noticed in #1255

@pvlugter pvlugter merged commit 75a3ab9 into main Jan 18, 2025
22 checks passed
@pvlugter pvlugter deleted the wip-clear-inflight-patriknw branch January 18, 2025 03:08
@pvlugter pvlugter added this to the 1.6.7 milestone Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants