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

[Enhancement] Introduce TxnStateCache for merge commit sync mode #55001

Merged
merged 13 commits into from
Jan 16, 2025

Conversation

banmoy
Copy link
Contributor

@banmoy banmoy commented Jan 13, 2025

Why I'm doing:

This is the first PR of merge commit sync mode optimization #54995. Introduce TxnStateCache on BE side. You can see #54995 for details

What I'm doing:

Fixes #issue

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 January 13, 2025 06:32
@wanpengfei-git wanpengfei-git requested a review from a team January 13, 2025 06:33
@mergify mergify bot assigned banmoy Jan 13, 2025
@@ -360,7 +377,7 @@ class DynamicCache {
return ret;
}

mutable std::mutex _lock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use bthread::Mutex?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because the cache may be accessed in the brpc request

@banmoy banmoy force-pushed the txn_state_cache branch 4 times, most recently from 3a9b0ee to d761fda Compare January 15, 2025 01:32
trueeyu
trueeyu previously approved these changes Jan 15, 2025
be/src/runtime/batch_write/txn_state_cache.h Outdated Show resolved Hide resolved
be/src/runtime/batch_write/txn_state_cache.h Show resolved Hide resolved
return Status::ServiceUnavailable("Transaction state cache is stopped");
}
TxnStateDynamicCacheEntry* entry = create_if_not_exist ? cache->get_or_create(txn_id, 1) : cache->get(txn_id);
if (create_if_not_exist) {
Copy link
Contributor

Choose a reason for hiding this comment

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

going to set the txn id every time even the entry already exists because of create_if_not_exist = true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. DynamicCache does not support to accept parameters for constructor when creating an entry, so use this way as a workaround

be/src/runtime/batch_write/txn_state_cache.h Show resolved Hide resolved
be/src/runtime/batch_write/txn_state_cache.h Show resolved Hide resolved
be/src/runtime/batch_write/txn_state_cache.h Outdated Show resolved Hide resolved
be/src/common/config.h Show resolved Hide resolved
be/src/runtime/batch_write/batch_write_mgr.cpp Outdated Show resolved Hide resolved
be/src/runtime/batch_write/txn_state_cache.cpp Outdated Show resolved Hide resolved
@banmoy banmoy force-pushed the txn_state_cache branch 2 times, most recently from 0e8b88f to 55a3ea1 Compare January 15, 2025 10:48
gengjun-git pushed a commit that referenced this pull request Jan 15, 2025
…55001 (#55071)

This is the second PR of merge commit sync mode optimization #54995. Introduce TxnStateDispatcher on FE side. You can see #54995 for details

Signed-off-by: PengFei Li <[email protected]>
banmoy added a commit to banmoy/starrocks that referenced this pull request Jan 15, 2025
…tarRocks#55001 (StarRocks#55071)

This is the second PR of merge commit sync mode optimization StarRocks#54995. Introduce TxnStateDispatcher on FE side. You can see StarRocks#54995 for details

Signed-off-by: PengFei Li <[email protected]>
banmoy added 13 commits January 16, 2025 13:28
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: PengFei Li <[email protected]>
Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

pass : 403 / 455 (88.57%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/runtime/batch_write/batch_write_mgr.h 0 1 00.00% [53]
🔵 be/src/service/internal_service.cpp 0 5 00.00% [1282, 1283, 1286, 1290, 1291]
🔵 be/src/http/action/update_config_action.cpp 1 6 16.67% [333, 334, 335, 336, 338]
🔵 be/src/runtime/batch_write/isomorphic_batch_write.cpp 26 33 78.79% [404, 426, 427, 439, 440, 441, 453]
🔵 be/src/util/dynamic_cache.h 24 28 85.71% [306, 321, 342, 344]
🔵 be/src/runtime/batch_write/txn_state_cache.h 19 22 86.36% [130, 131, 132]
🔵 be/src/runtime/batch_write/batch_write_mgr.cpp 26 29 89.66% [269, 270, 271]
🔵 be/src/runtime/batch_write/txn_state_cache.cpp 305 329 92.71% [36, 114, 122, 140, 172, 173, 217, 221, 268, 269, 270, 282, 283, 301, 302, 304, 316, 317, 335, 398, 467, 468, 469, 470]
🔵 be/src/runtime/exec_env.cpp 2 2 100.00% []

@wyb wyb enabled auto-merge (squash) January 16, 2025 09:26
@wyb wyb merged commit 5d145b0 into StarRocks:main Jan 16, 2025
50 checks passed
banmoy added a commit to banmoy/starrocks that referenced this pull request Jan 16, 2025
banmoy added a commit to banmoy/starrocks that referenced this pull request Jan 16, 2025
wyb pushed a commit that referenced this pull request Jan 16, 2025
wyb pushed a commit that referenced this pull request Jan 16, 2025
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.

5 participants