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: implement Background service for databend #11751

Merged
merged 43 commits into from
Jun 16, 2023
Merged

Conversation

ZhiHanZ
Copy link
Collaborator

@ZhiHanZ ZhiHanZ commented Jun 14, 2023

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Databend Internal Storage FuseTable is similar to Apache Iceberg, which is a Log Structured Table and need to compact/recluster/vacuum table regularly to merge small data chunks, sort them by the cluster key or vacuum unneeded branches.

Previously, those implementation rely on different drivers which add some complexity for infrastructure as we need to deploy and maintain additional service to trigger driver events.
Thus we need to introduce the Background Service, which allow to run databend as a background one-shot job or as a background daemon to run cron jobs,
jobs may trigger table maintainence tasks, for example, automatic compaction/vacuum/recluster by cron based/ critiria based without additional maintainence needed

This implementation contain:

  1. complete metasrv schema definition and background_job and background_tasks
  2. apis to update and maintain background_job and background_task state on meta-service
  3. simplified job scheduler implementation which support one_shot, interval, cron job type.

Not contain:

  1. cron job graceful shutdown
  2. tests on background job state machine
  3. management apis or call procedures to view and create background jobs by user
  4. Cluster mode background service, as we need a leader election process to ensure a leader to initialize requests

Closes #issue

@ZhiHanZ ZhiHanZ requested a review from drmingdrmer as a code owner June 14, 2023 07:30
@vercel
Copy link

vercel bot commented Jun 14, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
databend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2023 9:23am

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Jun 14, 2023
@ZhiHanZ ZhiHanZ requested a review from drmingdrmer June 14, 2023 16:01
src/meta/api/src/background_api_impl.rs Outdated Show resolved Hide resolved
src/meta/api/src/background_api_impl.rs Outdated Show resolved Hide resolved
src/meta/api/src/background_api_impl.rs Outdated Show resolved Hide resolved
@ZhiHanZ ZhiHanZ requested a review from drmingdrmer June 15, 2023 09:39
src/meta/api/src/background_api_impl.rs Outdated Show resolved Hide resolved
src/meta/api/src/background_api_impl.rs Outdated Show resolved Hide resolved
src/meta/api/src/background_api_impl.rs Outdated Show resolved Hide resolved
@ZhiHanZ ZhiHanZ requested a review from drmingdrmer June 16, 2023 08:33
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

LGTM

PS display implementation can be simplified

src/meta/app/src/background/background_job.rs Outdated Show resolved Hide resolved
@BohuTANG BohuTANG merged commit 491e44a into main Jun 16, 2023
@BohuTANG BohuTANG deleted the background_service_zhihanz branch June 16, 2023 10:11
andylokandy pushed a commit to andylokandy/databend that referenced this pull request Nov 27, 2023
* feat: background service patch 1(schema definitions)

* feat: add kv api for background tasks

* feat: add background_task apis with unit-test

* feat: add background job schema

* save

* feat: add compaction background job

* save

* save

* save

* add task logics

* save

* save

* save

* save

* feat: refactor background apis

* feat: add apis

* save

* save

* lint

* license

* license

* license

* fix debug settings

* fix comment

* fix

* remove unneeded stats

* fix comment

* fix unit tests

* fix

* fix comment

* remove unneeded kv call

* fix

* f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants