-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Background database deletion #2857
Conversation
c9b945c
to
19bf682
Compare
43b0caa
to
2144b30
Compare
end, | ||
{ok, NewAcc} | ||
end, | ||
{ok, _Infos} = fabric2_db:list_deleted_dbs_info(Callback, [], []), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could technically run longer than 5 seconds so we should use the {restart_tx, true}
option here.
@jiangphcn look great, Peng Hui. Nice work! See a few minor updates and a simplification in regards to batching and it should be good to go. |
73bb7db
to
0e7b08c
Compare
ScheduleSec = schedule_sec(), | ||
Opts = #{max_sched_time => Now + min(ScheduleSec div 3, 15)}, | ||
case couch_jobs:accept(?JOB_TYPE, Opts) of | ||
% maybe handle timeout here, need to check the api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the comment since we don't need the timeout there
|
||
|
||
process_expirations(#{} = Job, #{} = Data) -> | ||
{ok, Infos} = fabric2_db:list_deleted_dbs_info([{restart_tx, true}]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could still use a callback here just so we don't have to load all the infos into memory.
It might be better to use the callback here and LastUpdateAt would be the accumulator value
case Since >= timestamp_to_sec(TimeStamp) of | ||
true -> | ||
couch_log:notice("Permanently deleting ~p database with" | ||
" timestamp ~p", [DbName, TimeStamp]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a 4 space indent here since it's a continuation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 nice work, Peng Hui
b6eb006
to
3d447c6
Compare
allow background job to delete soft-deleted database according to specified criteria to release space. Once database is hard-deleted, the data can't be fetched back. Co-authored-by: Nick Vatamaniuc<[email protected]>
3d447c6
to
91becc1
Compare
thanks @nickva so much for your kindly support and review! |
Overview
Allow to permanently delete those soft-deleted databases under background. In general, the soft-deleted database can be kept from several hours to several days. Later, they need to be deleted to reclaim disk space. So one criteria can be specified to decide how to select which soft-deleted databases to be deleted.
Testing recommendations
make check apps=fabric tests=crud_test_,scheduled_db_remove_error_test_
Related Issues or Pull Requests
Checklist
rel/overlay/etc/default.ini