-
Notifications
You must be signed in to change notification settings - Fork 312
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
fix(manual_compact): fix replica lose manual compact finished status after replica migrate bug #1961
base: master
Are you sure you want to change the base?
fix(manual_compact): fix replica lose manual compact finished status after replica migrate bug #1961
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1758,14 +1758,22 @@ dsn::error_code pegasus_server_impl::start(int argc, char **argv) | |
dsn::ERR_LOCAL_APP_FAILURE, | ||
"open app failed, unsupported data version {}", | ||
_pegasus_data_version); | ||
// update last manual compact finish timestamp | ||
uint64_t last_manual_compact_used_time = 0; | ||
LOG_AND_RETURN_NOT_OK( | ||
ERROR_PREFIX, | ||
_meta_store->get_last_manual_compact_used_time(&last_manual_compact_used_time), | ||
"get_last_manual_compact_used_time failed"); | ||
|
||
// update last manual compact finish & used timestamp | ||
_manual_compact_svc.init_last_finish_time_ms(last_manual_compact_finish_time); | ||
_manual_compact_svc.init_last_used_time_ms(last_manual_compact_used_time); | ||
cleanup.cancel(); | ||
} else { | ||
// Write initial meta data to meta CF and flush when create new DB. | ||
_meta_store->set_data_version(PEGASUS_DATA_VERSION_MAX); | ||
_meta_store->set_last_flushed_decree(0); | ||
_meta_store->set_last_manual_compact_finish_time(0); | ||
_meta_store->set_last_manual_compact_used_time(0); | ||
flush_all_family_columns(true); | ||
} | ||
|
||
|
@@ -3334,7 +3342,8 @@ ::dsn::error_code pegasus_server_impl::check_column_families(const std::string & | |
return ::dsn::ERR_OK; | ||
} | ||
|
||
uint64_t pegasus_server_impl::do_manual_compact(const rocksdb::CompactRangeOptions &options) | ||
uint64_t pegasus_server_impl::do_manual_compact(const rocksdb::CompactRangeOptions &options, | ||
uint64_t start) | ||
{ | ||
// wait flush before compact to make all data compacted. | ||
uint64_t start_time = dsn_now_ms(); | ||
|
@@ -3355,6 +3364,11 @@ uint64_t pegasus_server_impl::do_manual_compact(const rocksdb::CompactRangeOptio | |
status.ToString(), | ||
end_time - start_time); | ||
_meta_store->set_last_manual_compact_finish_time(end_time); | ||
uint64_t last_manual_compact_finish_time = 0; | ||
CHECK_OK_PREFIX( | ||
_meta_store->get_last_manual_compact_finish_time(&last_manual_compact_finish_time)); | ||
after_manual_compact(start_time, last_manual_compact_finish_time); | ||
|
||
// generate new checkpoint and remove old checkpoints, in order to release storage asap | ||
if (!release_storage_after_manual_compact()) { | ||
// it is possible that the new checkpoint is not generated, if there was no data | ||
|
@@ -3375,12 +3389,17 @@ uint64_t pegasus_server_impl::do_manual_compact(const rocksdb::CompactRangeOptio | |
// update rocksdb statistics immediately | ||
update_replica_rocksdb_statistics(); | ||
|
||
uint64_t last_manual_compact_finish_time = 0; | ||
CHECK_OK_PREFIX( | ||
_meta_store->get_last_manual_compact_finish_time(&last_manual_compact_finish_time)); | ||
return last_manual_compact_finish_time; | ||
} | ||
|
||
void pegasus_server_impl::after_manual_compact(std::uint64_t starttime, uint64_t endtime) | ||
{ | ||
// store last manual compact used time to meta store for learn situation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the replica server shutdown before the replicas complete the manual compaction, can this patch resolve this issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this patch will still work. Cause if replica server shutdown before the replicas complete the manual compaction,the |
||
uint64_t used_time = endtime - starttime; | ||
_meta_store->set_last_manual_compact_used_time(used_time); | ||
flush_all_family_columns(true); | ||
} | ||
|
||
bool pegasus_server_impl::release_storage_after_manual_compact() | ||
{ | ||
int64_t old_last_durable = last_durable_decree(); | ||
|
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.
When upgrade from old versions, ERR_OBJECT_NOT_FOUND will be returned, right?