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

feat(mito): Checks whether a region should flush periodically #3459

Merged
merged 8 commits into from
Mar 15, 2024

Conversation

evenyag
Copy link
Contributor

@evenyag evenyag commented Mar 7, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

This PR checks whether a region should flush periodically and flush it if its last flush time is earlier than auto_flush_interval. The previous implementation only triggers the check on flush, which implies the write buffer is full. It might cause the database to hold a large amount of data for a long time if users stop ingesting data.

This PR

  • adds a timeout to receive a channel so the worker can handle some tasks periodically
  • adds a TimeProvider to get the current timestamp and checks elapsed time, this also simplifies test implementation

Each worker will start with a random check delay between [0, MAX_INITIAL_CHECK_DELAY_SECS) to avoid them flush together.

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.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Mar 7, 2024
@evenyag evenyag force-pushed the feat/worker-auto-flush branch 2 times, most recently from e65fa6a to 4f77f89 Compare March 12, 2024 03:11
@evenyag evenyag force-pushed the feat/worker-auto-flush branch from 4f77f89 to 812855b Compare March 14, 2024 03:43
@evenyag evenyag marked this pull request as ready for review March 14, 2024 06:41
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 97.05882% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 85.00%. Comparing base (b85d7bb) to head (a4145ca).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3459      +/-   ##
==========================================
- Coverage   85.30%   85.00%   -0.31%     
==========================================
  Files         904      906       +2     
  Lines      150170   150925     +755     
==========================================
+ Hits       128106   128288     +182     
- Misses      22064    22637     +573     

src/mito2/src/worker.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

LGTM

@fengjiachun fengjiachun added this pull request to the merge queue Mar 15, 2024
Merged via the queue into GreptimeTeam:main with commit 74862f8 Mar 15, 2024
18 checks passed
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.

3 participants