Skip to content

feat(mito): Add WriteCache struct and write SSTs to write cache#2999

Merged
killme2008 merged 32 commits into
GreptimeTeam:mainfrom
evenyag:feat/write-cache
Jan 4, 2024
Merged

feat(mito): Add WriteCache struct and write SSTs to write cache#2999
killme2008 merged 32 commits into
GreptimeTeam:mainfrom
evenyag:feat/write-cache

Conversation

@evenyag
Copy link
Copy Markdown
Contributor

@evenyag evenyag commented Dec 25, 2023

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

This PR implements a skeleton for the WriteCache that serves as a write-through cache for object stores.

WriteCache

The WriteCache has a local store to cache files.

pub struct WriteCache {
    /// Local file cache.
    file_cache: FileCacheRef,
    /// Object store manager.
    object_store_manager: ObjectStoreManagerRef,
}

The WriteCache has a write_and_upload_sst() method to write files to the cache (a local store) and upload them to object stores.

pub(crate) async fn write_and_upload_sst(
    &self,
    request: SstUploadRequest,
    write_opts: &WriteOptions,
) -> Result<Option<SstInfo>>

Upload can be sync or async. We will implement the sync version first.

The recover() method will recover the underlying file cache.

pub async fn recover(&self) -> Result<()>;

The AccessLayer hides the details of writing SSTs to the write cache.

impl AccessLayer {
    pub(crate) async fn write_sst(
        &self,
        request: SstWriteRequest,
        write_opts: &WriteOptions,
    ) -> Result<Option<SstInfo>> {
        // ...
    }
}

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

Refer to a related PR or issue link (optional)

@evenyag evenyag added the docs-not-required This change does not impact docs. label Dec 25, 2023
@evenyag evenyag requested review from QuenKar and waynexia December 26, 2023 07:47
@evenyag evenyag removed the docs-not-required This change does not impact docs. label Dec 27, 2023
@github-actions github-actions Bot added the docs-not-required This change does not impact docs. label Dec 27, 2023
@evenyag evenyag marked this pull request as ready for review December 27, 2023 06:30
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 27, 2023

Codecov Report

Attention: 38 lines in your changes are missing coverage. Please review.

Comparison is base (f1a4750) 85.68% compared to head (962a9d1) 85.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2999      +/-   ##
==========================================
- Coverage   85.68%   85.13%   -0.56%     
==========================================
  Files         806      806              
  Lines      131511   131563      +52     
==========================================
- Hits       112689   112003     -686     
- Misses      18822    19560     +738     

Copy link
Copy Markdown
Member

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread src/mito2/src/test_util/scheduler_util.rs
Comment thread src/mito2/src/cache/write_cache.rs Outdated
Comment thread src/mito2/src/cache/write_cache.rs Outdated
@evenyag evenyag marked this pull request as draft January 3, 2024 05:24
@evenyag
Copy link
Copy Markdown
Contributor Author

evenyag commented Jan 3, 2024

After some experiments, I plan to simplify the implementation of the write-through cache and upload files to object stores synchronously. Then we can remove UploadPart related components. I'll get back soon.

@evenyag evenyag changed the title feat(mito): upload part writer for write cache feat(mito): Add WriteCache struct and write SSTs to write cache Jan 3, 2024
@evenyag
Copy link
Copy Markdown
Contributor Author

evenyag commented Jan 3, 2024

I refactored the AccessLayer and WriteCache:

  • 0278513 refactors the AccessLayer to hide the details of writing SST files.
  • 9f03e67 writes the SST to the write cache, though it doesn't go through the local file cache.

@evenyag evenyag marked this pull request as ready for review January 3, 2024 14:56
Comment thread src/mito2/src/cache/write_cache.rs Outdated
@evenyag evenyag added this pull request to the merge queue Jan 4, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 4, 2024
@killme2008 killme2008 added this pull request to the merge queue Jan 4, 2024
Merged via the queue into GreptimeTeam:main with commit 96b6235 Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required This change does not impact docs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants