Skip to content

Commit

Permalink
fix: A large number of delete ranges exist when building an sst, resu…
Browse files Browse the repository at this point in the history
…lting in a large amount of memory consumption (baidu#225)

* fix: A large number of delete ranges exist when building an sst, resulting in a large amount of memory consumption

* 修正变量名

---------

Co-authored-by: 苏健 <[email protected]>
  • Loading branch information
slsjnp and 苏健 authored Aug 15, 2023
1 parent 5bfc1ba commit b0f8f1a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/raft/my_raft_log_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ int MyRaftLogStorage::truncate_prefix(const int64_t first_index_kept) {
DB_WARNING("Truncating region_id: %ld to first index kept:%ld from first log index:%ld",
_region_id, first_index_kept, _first_log_index.load());

int64_t start_index = _first_log_index.load();
if (start_index < 0){
return 0;
}
_first_log_index.store(first_index_kept);
if (first_index_kept > _last_log_index.load()) {
_last_log_index.store(first_index_kept - 1);
Expand Down Expand Up @@ -485,7 +489,7 @@ int MyRaftLogStorage::truncate_prefix(const int64_t first_index_kept) {

//替换为remove_range
char start_key[LOG_DATA_KEY_SIZE];
_encode_log_data_key(start_key, LOG_DATA_KEY_SIZE, 0);
_encode_log_data_key(start_key, LOG_DATA_KEY_SIZE, start_index);
char end_key[LOG_DATA_KEY_SIZE];
_encode_log_data_key(end_key, LOG_DATA_KEY_SIZE, first_index_kept);

Expand Down

0 comments on commit b0f8f1a

Please sign in to comment.