Skip to content

PageStorage skip non continuous sequence safely#2435

Merged
ti-srebot merged 9 commits intopingcap:masterfrom
JaySon-Huang:safe_skip_non_continuous_sequence
Jul 28, 2021
Merged

PageStorage skip non continuous sequence safely#2435
ti-srebot merged 9 commits intopingcap:masterfrom
JaySon-Huang:safe_skip_non_continuous_sequence

Conversation

@JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Jul 19, 2021

What problem does this PR solve?

Issue Number: close #2317, related to #2312, #2356

Problem Summary:
After #2312 and #2356, we introduce "Formal" PageFiles into LegacyCompactor::collectPageFilesToCompact.
So we may read files that are writing by other threads during LegacyCompactor::collectPageFilesToCompact. We need further protection on those writable files while applying GC, or we may scan some data in the middle of writing.

What is changed and how it works?

  • Save the meta offset of writable files after restore and write
  • Save the last persisted sequence of writable files after write
  • Set the last persisted sequence of writable of the overall persisted sequence after restore
  • When reading meta from those writable files, only read to the meta offset or to the min persisted sequence at maximum
  • Add some failpoint to generate non-continuous sequences

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch:

Check List

Tests

  • Manual test (add detailed scripts or steps below)
    • Enable random_slow_page_storage_write and random_exception_after_page_storage_sequence_acquired to generate non-continuous sequence
    • Wait until the meta get compacted by LegacyCompactor
    • Restart TiFlash to check whether we can read / write

Side effects

Release note

  • No release note

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang JaySon-Huang changed the title Skip non continuous sequence safely PageStorage skip non continuous sequence safely Jul 19, 2021
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
@JaySon-Huang JaySon-Huang force-pushed the safe_skip_non_continuous_sequence branch from 9047f83 to 707fac6 Compare July 23, 2021 11:36
@JaySon-Huang JaySon-Huang added the type/bugfix This PR fixes a bug. label Jul 26, 2021
@JaySon-Huang JaySon-Huang requested a review from flowbehappy July 26, 2021 02:59
Copy link
Contributor

@flowbehappy flowbehappy left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 27, 2021
@flowbehappy
Copy link
Contributor

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 28, 2021
@ti-srebot
Copy link
Collaborator

Your auto merge job has been accepted, waiting for:

  • 2509
  • 2504

@ti-srebot
Copy link
Collaborator

/run-all-tests

@JaySon-Huang JaySon-Huang removed the status/can-merge Indicates a PR has been approved by a committer. label Jul 28, 2021
@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 28, 2021
@ti-srebot
Copy link
Collaborator

/run-all-tests

@ti-srebot ti-srebot merged commit 3fe3768 into pingcap:master Jul 28, 2021
@JaySon-Huang JaySon-Huang deleted the safe_skip_non_continuous_sequence branch July 28, 2021 11:55
@flowbehappy flowbehappy added this to the v5.1.2 milestone Aug 4, 2021
JaySon-Huang added a commit to JaySon-Huang/tiflash that referenced this pull request Aug 4, 2021
JaySon-Huang added a commit to JaySon-Huang/tiflash that referenced this pull request Aug 4, 2021
flowbehappy pushed a commit that referenced this pull request Aug 4, 2021
* Ignore sequence hole among PageFile meta (#2312)

* Fix bug for GC may skip unexpected WriteBatches (#2356)

* Add length check while running PageStorage GC (#2394)

* PageStorage skip non continuous sequence safely (#2435)

* Fix PageStorage GC with high valid rate PageFile (#2436)

* More debug info for DeltaTree (query_id, snapshot lifetime) (#2431)

* Fix deadlock on `removeExpiredSnapshots` (#2461)

* Add grafana panels for write throughput per instance (#2524)
JaySon-Huang pushed a commit that referenced this pull request Aug 5, 2021
* Ignore sequence hole among PageFile meta (#2312)
* Fix bug for GC may skip unexpected WriteBatches (#2356)
* Add length check while running PageStorage GC (#2394)
* PageStorage skip non continuous sequence safely (#2435)
* Fix PageStorage GC with high valid rate PageFile (#2436)

Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
@JaySon-Huang JaySon-Huang removed this from the v5.1.2 milestone Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PageStorage can not GC legacy files due to non-continuous sequence number

3 participants