pingcap / tiflash

The analytical engine for TiDB and TiDB Cloud. Try free: https://tidbcloud.com/free-trial
https://docs.pingcap.com/tidb/stable/tiflash-overview
Apache License 2.0
937 stars 409 forks source link

KVStore: Refine parallel prehandle snapshot (part-1) #9192

Closed JaySon-Huang closed 2 weeks ago

JaySon-Huang commented 2 weeks ago

What problem does this PR solve?

Issue Number: ref https://github.com/pingcap/tiflash/issues/8081

Problem Summary:

I'd like to introduce a new layer SnapshotSSTReader and move getApproxBytes/findSplitKeys into that layer. This could make the logic in parallel prehandle snapshots more clear.

This PR is a preceding PR that refactors the code to simplify the following logical change.

New SnapshotSSTReader interface in later PR:

struct SnapshotSSTReader
{
    SnapshotSSTReader(
        const SSTViewVec & snaps,
        const TiFlashRaftProxyHelper * proxy_helper,
        RegionID region_id,
        UInt64 snapshot_index,
        const ImutRegionRangePtr & region_range,
        std::optional<SSTScanSoftLimit> && soft_limit,
        const String & log_prefix);

    // Currently it only takes effect if using tablet sst reader which is usually a raftstore v2 case.
    // Otherwise will return zero.
    size_t getApproxBytes() const;
    std::vector<std::string> findSplitKeys(size_t splits_count) const;

    using SSTReaderPtr = std::unique_ptr<SSTReader>;
    SSTReaderPtr write_cf_reader;
    SSTReaderPtr default_cf_reader;
    SSTReaderPtr lock_cf_reader;
};

What is changed and how it works?

Check List

Tests

Side effects

Documentation

Release note

None
ti-chi-bot[bot] commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, 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](https://github.com/pingcap/tiflash/blob/master/OWNERS)~~ [CalvinNeo,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[bot] commented 2 weeks ago

[LGTM Timeline notifier]

Timeline: