Skip to content

[bug](txn) fix concurrent txns's status data race - #17893

Merged
morningman merged 4 commits into
apache:masterfrom
ByteYue:fix_concurrent_txns_data_race
Mar 20, 2023
Merged

morningman merged 4 commits into
apache:masterfrom
ByteYue:fix_concurrent_txns_data_race

Conversation

@ByteYue

@ByteYue ByteYue commented Mar 17, 2023 •

Copy link
Copy Markdown
Contributor

Proposed changes

Issue Number: close #xxx

Problem summary

Recently, we found that in a high-concurrency import scenario, one version was consistently missing across all three replicas of a certain tablet. However, when we ran grep ${tablet_id} | grep publish | grep missed_version on the backend, we could not find the corresponding logs. After checking the transaction numbers of the missed_version-1 and missed_version+1, we finally identified the transaction number of the missing version. We then used this transaction ID to search for logs in the frontend, and found the following:
image

The same transaction timed out while attempting to acquire a write lock and was aborted, but it was later successfully committed. However, the abort transaction was also cleared on the backend by "clear transaction" rpc. As a result, the publish task corresponding to this transaction can never succeed.

After reviewing the code related to transactions, it appears that there are many places where access to the transactionState is not thread-safe. Additionally, even the unprotectedCommitTransaction2PC method can successfully commit a transaction without satisfying the required status limitations.

The transaction code does not fully consider duplicate concurrent RPCs, and the current code is tightly coupled and difficult to modify. This pull request can only attempt to handle the issue with unprotectedCommitTransaction2PC on a case-by-case basis, while also adding a read lock to ensure thread-safe access to transactionState (although this may not be sufficient).

Describe your changes.

Checklist(Required)

  • Does it affect the original behavior
  • Has unit tests been added
  • Has document been added or modified
  • Does it need to update dependencies
  • Is this PR support rollback (If NO, please explain WHY)

Further comments

If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@ByteYue
ByteYue force-pushed the fix_concurrent_txns_data_race branch from 357fd2c to c00c314 Compare March 17, 2023 13:25
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@ByteYue

ByteYue commented Mar 17, 2023

Copy link
Copy Markdown
Contributor Author

run buildall

Comment thread be/src/agent/task_worker_pool.cpp Resolved
@morningman morningman self-assigned this Mar 18, 2023
@ByteYue

ByteYue commented Mar 18, 2023

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@ByteYue
ByteYue force-pushed the fix_concurrent_txns_data_race branch from 787438b to 4c321b6 Compare March 18, 2023 09:52
@ByteYue

ByteYue commented Mar 18, 2023

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@ByteYue

ByteYue commented Mar 19, 2023

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@hello-stephen

hello-stephen commented Mar 19, 2023 •

Copy link
Copy Markdown
Contributor

TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 34.27 seconds
stream load tsv: 476 seconds loaded 74807831229 Bytes, about 149 MB/s
stream load json: 25 seconds loaded 2358488459 Bytes, about 89 MB/s
stream load orc: 76 seconds loaded 1101869774 Bytes, about 13 MB/s
stream load parquet: 32 seconds loaded 861443392 Bytes, about 25 MB/s
https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20230320081726_clickbench_pr_117223.html

@morningman morningman added usercase Important user case type label dev/1.2.3 labels Mar 20, 2023
@ByteYue

ByteYue commented Mar 20, 2023

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@ByteYue

ByteYue commented Mar 20, 2023

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman morningman left a comment

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.

LGTM

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Mar 20, 2023
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@dataroaring dataroaring left a comment

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.

LGTM

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

Labels

approved Indicates a PR has been approved by one committer. dev/1.2.4-merged kind/test reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants