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

refactor(remote_wal): entry id usage #2986

Merged
merged 7 commits into from
Dec 25, 2023
Merged

Conversation

niebayes
Copy link
Contributor

@niebayes niebayes commented Dec 23, 2023

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

  • Let the LogStore::append_batch method return a last_entry_id for each region. More specifically, it returns a HashMap<u64, EntryId> where the key is a region id while the value is the id of the entry, the last entry of the entries belong to the region, written into the log store.
  • For KafkaLogStore, the returned entry id for each region is the kafka offset of the last entry belong to the region that are written into the log store. During replay, the passed-in entry id is interpreted to a kafka offset and used to fetch log entries exactly starting from the offset.
  • For RaftEngineLogStore, the returned entry id for each region is identical with the passed-in entry id. For example, an entry with id x is appended to the log store. Then, the log store will return x for the region that the entry belong to.
  • After a region's entry is written into the log store, the last_entry_id returned from the log store will be used to update the next_entry_id of the associated RegionWriteCtx. More specifically, next_entry_id = last_entry_id + 1.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

@niebayes niebayes added the docs-not-required This change does not impact docs. label Dec 23, 2023
@niebayes niebayes enabled auto-merge December 23, 2023 16:29
@niebayes niebayes requested review from evenyag, v0y4g3r, WenyXu, killme2008, MichaelScofield and waynexia and removed request for evenyag, v0y4g3r and WenyXu December 23, 2023 16:29
@niebayes niebayes changed the title refactor: entry id usage refactor(: entry id usage Dec 23, 2023
@niebayes niebayes changed the title refactor(: entry id usage refactor(remote_wal): entry id usage Dec 23, 2023
@niebayes niebayes self-assigned this Dec 23, 2023
Copy link

codecov bot commented Dec 23, 2023

Codecov Report

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

Comparison is base (06fd7fd) 85.87% compared to head (55b9d61) 85.86%.
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2986      +/-   ##
===========================================
- Coverage    85.87%   85.86%   -0.01%     
===========================================
  Files          780      780              
  Lines       126184   126196      +12     
===========================================
+ Hits        108356   108360       +4     
- Misses       17828    17836       +8     

src/mito2/src/worker/handle_write.rs Outdated Show resolved Hide resolved
src/mito2/src/region_write_ctx.rs Outdated Show resolved Hide resolved
src/log-store/src/raft_engine/log_store.rs Show resolved Hide resolved
src/mito2/src/worker/handle_write.rs Outdated Show resolved Hide resolved
src/store-api/src/logstore.rs Outdated Show resolved Hide resolved
src/mito2/src/region_write_ctx.rs Outdated Show resolved Hide resolved
src/log-store/src/raft_engine/log_store.rs Outdated Show resolved Hide resolved
src/mito2/src/region_write_ctx.rs Outdated Show resolved Hide resolved
@niebayes niebayes requested a review from v0y4g3r December 25, 2023 06:56
@niebayes niebayes requested review from evenyag and WenyXu December 25, 2023 06:56
Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

LGTM

src/store-api/src/logstore/entry.rs Outdated Show resolved Hide resolved
@niebayes niebayes added this pull request to the merge queue Dec 25, 2023
Merged via the queue into develop with commit d4ac873 Dec 25, 2023
14 checks passed
@niebayes niebayes deleted the refactor/entry_id_usage branch December 25, 2023 07:45
niebayes added a commit that referenced this pull request Dec 25, 2023
* chore: update comments for log store stuff

* refactor: entry id usage

* tmp update

* Revert "tmp update"

This reverts commit fcfcda2.

* fix: resolve review conversations

* fix: resolve review conversations

* chore: remove entry offset
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