Skip to content

[hotifx-to-7.5] raftstore: support rocksdb writes during ingestion #18096#18520

Merged
overvenus merged 3 commits intotikv:add-index-ingest-allow-writefrom
LykxSassinator:cp_pr3_to_hotfix
Jun 7, 2025
Merged

[hotifx-to-7.5] raftstore: support rocksdb writes during ingestion #18096#18520
overvenus merged 3 commits intotikv:add-index-ingest-allow-writefrom
LykxSassinator:cp_pr3_to_hotfix

Conversation

@LykxSassinator
Copy link
Contributor

This is a manual CP of #18096

This PR implements the proposal described in issue #18081. With this change, the P99 apply wait duration is significantly reduced.

image

New metrics RocksDB-kv->Ingest SST allow_write:
image

Summary

Enabled RocksDB’s allow_write option to reduce the latency impact of SST file ingestion on foreground operations, while introducing a range latch mechanism to ensure correctness.

Key Changes

The specific changes include:

  1. Enabled allow_write: The IngestExternalFileOptions.allow_write option was enabled by apply-snapshot ingest SST.
  2. Introduced RangeLatch: Added RocksEngine.ingest_latch to dynamically acquire range locks during SST ingestion, preventing concurrent writes by Compaction Filter GC.

The reason for introducing a range latch is that in TiKV, operations such as applying snapshots during region creation, handling foreground writes in normal operation, and destroying peers are all executed sequentially. However, the Compaction Filter GC operates as a dedicated background thread, making it the only component that might run concurrently and write default CF with SST ingestion. To handle this potential concurrency, the RangeLatch ensures there are no overlapping ranges between these two concurrent operations, maintaining correctness.

What is changed and how it works?

Issue Number: Close #18081

What's Changed:

This PR implements the proposal described in [issue #18081](https://github.com/tikv/tikv/issues/18081). With this change, the P99 apply wait duration is significantly reduced.

Related changes

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

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

Release note

none

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 6, 2025
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 6, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: overvenus, v01dstar

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

The pull request process is described here

Details Needs approval from an approver in each of these files:

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 added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 6, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 6, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-06-06 11:33:57.174205603 +0000 UTC m=+9215.402520866: ☑️ agreed by overvenus.
  • 2025-06-06 23:50:01.845900536 +0000 UTC m=+53380.074215799: ☑️ agreed by v01dstar.

Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus merged commit 7d3f332 into tikv:add-index-ingest-allow-write Jun 7, 2025
2 of 3 checks passed
ti-chi-bot bot pushed a commit that referenced this pull request Jun 10, 2025
 

Rollup of following sst ingestion optimizations

* raftstore: directly write kvs rather than ingestion when merging small regions. (#17408) (#18518)
* raftstore: remove stale ranges by DeleteByKeys rather than ingesting. (#18040) (#18519)
* raftstore: support rocksdb writes during ingestion #18096 (#18520)
* storage: support online config for flow-control module (#17396). (#18523)
* sst_importer: allow write during ingesting sst (#18514) (#18522)

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>

Co-authored-by: lucasliang <nkcs_lykx@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants