Skip to content

Commit

Permalink
Add accept_log_when_hash_matched
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Oct 22, 2024
1 parent 1c02c91 commit bab746b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/distributed_system/wal_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ class LIBATFRAME_UTILS_API_HEAD_ONLY wal_client {
}

object_type::default_configure(*ret);
ret->accept_log_when_hash_matched = true;

ret->subscriber_heartbeat_interval = std::chrono::duration_cast<duration>(std::chrono::minutes{3});
ret->subscriber_heartbeat_retry_interval = std::chrono::duration_cast<duration>(std::chrono::minutes{1});

return ret;
}

Expand Down
8 changes: 6 additions & 2 deletions include/distributed_system/wal_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class LIBATFRAME_UTILS_API_HEAD_ONLY wal_object {
duration gc_expire_duration;
size_t max_log_size;
size_t gc_log_size;
bool accept_log_when_hash_matched;
};
using configure_pointer = typename wal_mt_mode_data_trait<configure_type, log_operator_type::mt_mode>::strong_ptr;

Expand Down Expand Up @@ -190,6 +191,7 @@ class LIBATFRAME_UTILS_API_HEAD_ONLY wal_object {
out.gc_expire_duration = std::chrono::duration_cast<duration>(std::chrono::hours(7 * 24));
out.max_log_size = 512;
out.gc_log_size = 128;
out.accept_log_when_hash_matched = false;
}

wal_result_code load(const storage_type& storage, callback_param_type param) {
Expand Down Expand Up @@ -724,7 +726,8 @@ class LIBATFRAME_UTILS_API_HEAD_ONLY wal_object {
}

wal_result_code ret = redo_log(log, param);
if (wal_result_code::kOk != ret) {
if (wal_result_code::kOk != ret && !(get_configure().accept_log_when_hash_matched && vtable_->set_hash_code &&
vtable_->get_hash_code && vtable_->calculate_hash_code)) {
return ret;
}

Expand Down Expand Up @@ -808,7 +811,8 @@ class LIBATFRAME_UTILS_API_HEAD_ONLY wal_object {
}

wal_result_code ret = redo_log(log, param);
if (wal_result_code::kOk != ret) {
if (wal_result_code::kOk != ret && !(get_configure().accept_log_when_hash_matched && vtable_->set_hash_code &&
vtable_->get_hash_code && vtable_->calculate_hash_code)) {
return ret;
}

Expand Down

0 comments on commit bab746b

Please sign in to comment.