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

Storage: Refactor DMContext to avoid being misused #8318

Merged
merged 8 commits into from
Nov 6, 2023

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Nov 6, 2023

What problem does this PR solve?

Issue Number: close #8312

Problem Summary:

What is changed and how it works?

  • Rename DMContext::db_context to DMContext::global_context
  • Always save global_context as member in DMContext
  • Remove a lock in DeltaMergeStore::newDMContext that does not have concurrent issue in the latest code

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 6, 2023
@JaySon-Huang JaySon-Huang changed the title Refactor DMContext to avoid being misused Storage: Refactor DMContext to avoid being misused Nov 6, 2023
Comment on lines -452 to -453
std::shared_lock lock(read_write_mutex);

Copy link
Contributor Author

@JaySon-Huang JaySon-Huang Nov 6, 2023

Choose a reason for hiding this comment

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

The lock was added to protect the "schema" in very old versions(https://github.com/pingcap/tiflash/pull/507/files#diff-22b900e9e8020dc835612316f3bf151cae28b621bfac64d6a22b377d062f4b7eR165-R190). But now the members used in this function do not have concurrent issues. So this lock can be removed.

const String & tracing_id_ = "")
: db_context(db_context_)
: global_context(session_context_.getGlobalContext()) // always save the global context
Copy link
Contributor Author

Choose a reason for hiding this comment

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

always save the global context no matter what the pass-in session_context is a session only context or global context, and rename it to be global_context

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 6, 2023
@ti-chi-bot ti-chi-bot bot added the lgtm label Nov 6, 2023
Copy link
Contributor

ti-chi-bot bot commented Nov 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JinheLin, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JinheLin,Lloyd-Pottiger]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 6, 2023
Copy link
Contributor

ti-chi-bot bot commented Nov 6, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-06 08:43:29.629790716 +0000 UTC m=+3461007.216900863: ☑️ agreed by JinheLin.
  • 2023-11-06 09:03:06.277928516 +0000 UTC m=+3462183.865038647: ☑️ agreed by Lloyd-Pottiger.

@JaySon-Huang
Copy link
Contributor Author

/run-integration-test

1 similar comment
@Lloyd-Pottiger
Copy link
Contributor

/run-integration-test

@ti-chi-bot ti-chi-bot bot merged commit ecb1eea into pingcap:master Nov 6, 2023
6 checks passed
@JaySon-Huang JaySon-Huang deleted the fix_dm_context_member branch November 6, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TiFlash crash in DM::SegmentReadTask::doFetchPages
3 participants