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

[BugFix] Fix transaction stream load lock leak #53564

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

banmoy
Copy link
Contributor

@banmoy banmoy commented Dec 4, 2024

Why I'm doing:

In transaction stream load, a normal load request needs to go through the on_header, on_chunk_data, and handle processes of the TransactionStreamLoadAction. To prevent concurrent load requests, a lock will be acquired in on_header, and released in handle. But for an abnormal load request, handle may be not called, and the lock will not be released. For example, the client crashes before transmitting all of data, only on_header and on_chunk_data are called, and handle will not be called. This can lead to resources not being cleaned up after the load timeout because the cleanup needs acquire the lock (see TransactionMgr::_clean_stream_context).

What I'm doing:

Move the lock release to TransactionStreamLoadAction::free_handler_ctx which will be always called regardless of whether an exception occurs or not.

Fixes #53155

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@banmoy banmoy requested review from a team as code owners December 4, 2024 16:36
@mergify mergify bot assigned banmoy Dec 4, 2024
Signed-off-by: PengFei Li <[email protected]>
@banmoy banmoy force-pushed the txn_stream_load_lock branch from 96cae2e to 1493631 Compare December 4, 2024 16:51
@github-actions github-actions bot added 3.1 and removed 3.1 labels Dec 4, 2024
}

void TransactionStreamLoadAction::free_handler_ctx(void* param) {
StreamLoadContext* ctx = (StreamLoadContext*)param;
Copy link
Contributor

Choose a reason for hiding this comment

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

static_cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


void TransactionStreamLoadAction::free_handler_ctx(void* param) {
StreamLoadContext* ctx = (StreamLoadContext*)param;
if (ctx == nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

shall check nullptr against param before convert to StreamLoadContext?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

static_cast can be applied to nullptr so it's safe to check after the cast

Signed-off-by: PengFei Li <[email protected]>
Copy link

github-actions bot commented Dec 5, 2024

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

github-actions bot commented Dec 5, 2024

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

github-actions bot commented Dec 5, 2024

[BE Incremental Coverage Report]

pass : 16 / 19 (84.21%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/http/action/transaction_stream_load.cpp 16 19 84.21% [149, 180, 580]

@wyb wyb merged commit 82fffc3 into StarRocks:main Dec 5, 2024
57 checks passed
Copy link

github-actions bot commented Dec 5, 2024

@Mergifyio backport branch-3.4

@github-actions github-actions bot removed the 3.4 label Dec 5, 2024
Copy link

github-actions bot commented Dec 5, 2024

@Mergifyio backport branch-3.3

@github-actions github-actions bot removed the 3.3 label Dec 5, 2024
Copy link

github-actions bot commented Dec 5, 2024

@Mergifyio backport branch-3.2

Copy link
Contributor

mergify bot commented Dec 5, 2024

backport branch-3.4

✅ Backports have been created

Copy link

github-actions bot commented Dec 5, 2024

@Mergifyio backport branch-3.1

Copy link
Contributor

mergify bot commented Dec 5, 2024

backport branch-3.3

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Signed-off-by: PengFei Li <[email protected]>
(cherry picked from commit 82fffc3)
mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Signed-off-by: PengFei Li <[email protected]>
(cherry picked from commit 82fffc3)

# Conflicts:
#	be/test/http/transaction_stream_load_test.cpp
mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Signed-off-by: PengFei Li <[email protected]>
(cherry picked from commit 82fffc3)

# Conflicts:
#	be/test/http/transaction_stream_load_test.cpp
@jaogoy
Copy link
Contributor

jaogoy commented Dec 5, 2024

ignore backport check: 3.1.16

banmoy added a commit to banmoy/starrocks that referenced this pull request Dec 5, 2024
banmoy added a commit to banmoy/starrocks that referenced this pull request Dec 5, 2024
banmoy added a commit to banmoy/starrocks that referenced this pull request Dec 5, 2024
banmoy added a commit to banmoy/starrocks that referenced this pull request Dec 5, 2024
wanpengfei-git pushed a commit that referenced this pull request Dec 6, 2024
wanpengfei-git pushed a commit that referenced this pull request Dec 6, 2024
wyb pushed a commit that referenced this pull request Dec 6, 2024
wyb pushed a commit that referenced this pull request Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] CN nodes can not release query_pool Fragment memory
4 participants