Skip to content

Commit 23f7f18

Browse files
decrease pending gc task count when return (eBay#345)
1 parent b1a5fe1 commit 23f7f18

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class HomeObjectConan(ConanFile):
1212
name = "homeobject"
13-
version = "2.7.6"
13+
version = "2.7.7"
1414

1515
homepage = "https://github.com/eBay/HomeObject"
1616
description = "Blob Store built on HomeReplication"

src/lib/homestore_backend/gc_manager.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ std::shared_ptr< GCManager::pdev_gc_actor > GCManager::get_pdev_gc_actor(uint32_
163163

164164
bool GCManager::is_eligible_for_gc(chunk_id_t chunk_id) {
165165
auto chunk = m_chunk_selector->get_extend_vchunk(chunk_id);
166-
167166
const auto defrag_blk_num = chunk->get_defrag_nblks();
168-
169167
if (!defrag_blk_num) { return false; }
170168

171169
// 1 if the chunk state is inuse, it is occupied by a open shard, so it can not be selected and we don't need gc it.
@@ -176,9 +174,7 @@ bool GCManager::is_eligible_for_gc(chunk_id_t chunk_id) {
176174
}
177175

178176
const auto total_blk_num = chunk->get_total_blks();
179-
180177
const auto gc_garbage_rate_threshold = HS_BACKEND_DYNAMIC_CONFIG(gc_garbage_rate_threshold);
181-
182178
bool should_gc = 100 * defrag_blk_num >= total_blk_num * gc_garbage_rate_threshold;
183179

184180
LOGDEBUG("gc scan chunk_id={}, use_blks={}, available_blks={}, total_blks={}, defrag_blks={}, should_gc={}",
@@ -1007,7 +1003,8 @@ bool GCManager::pdev_gc_actor::purge_reserved_chunk(chunk_id_t chunk) {
10071003
void GCManager::pdev_gc_actor::handle_error_before_persisting_gc_metablk(chunk_id_t move_from_chunk,
10081004
chunk_id_t move_to_chunk,
10091005
folly::Promise< bool > task,
1010-
const uint64_t task_id, uint8_t priority) {
1006+
const uint64_t task_id, uint8_t priority,
1007+
const pg_id_t& pg_id) {
10111008
LOGERROR(
10121009
"gc task_id={}, move_from_chunk={} to move_to_chunk={} with priority={} failed before persisting gc metablk",
10131010
task_id, move_from_chunk, move_to_chunk, priority);
@@ -1023,6 +1020,7 @@ void GCManager::pdev_gc_actor::handle_error_before_persisting_gc_metablk(chunk_i
10231020
priority == static_cast< uint8_t >(task_priority::normal) ? de.failed_gc_task_count.fetch_add(1)
10241021
: de.failed_egc_task_count.fetch_add(1);
10251022
});
1023+
m_hs_home_object->gc_manager()->decr_pg_pending_gc_task(pg_id);
10261024
}
10271025

10281026
void GCManager::pdev_gc_actor::process_gc_task(chunk_id_t move_from_chunk, uint8_t priority,
@@ -1031,16 +1029,16 @@ void GCManager::pdev_gc_actor::process_gc_task(chunk_id_t move_from_chunk, uint8
10311029
priority);
10321030
auto start_time = std::chrono::steady_clock::now();
10331031
auto vchunk = m_chunk_selector->get_extend_vchunk(move_from_chunk);
1032+
RELEASE_ASSERT(vchunk->m_pg_id.has_value(), "chunk_id={} is expected to belong to a pg, but not!", move_from_chunk);
1033+
const auto pg_id = vchunk->m_pg_id.value();
10341034

10351035
if (vchunk->m_state != ChunkState::GC) {
10361036
LOGWARN("gc task_id={}, move_from_chunk={} is expected to in GC state, but not!", task_id, move_from_chunk);
10371037
task.setValue(false);
1038+
m_hs_home_object->gc_manager()->decr_pg_pending_gc_task(pg_id);
10381039
return;
10391040
}
10401041

1041-
RELEASE_ASSERT(vchunk->m_pg_id.has_value(), "chunk_id={} is expected to belong to a pg, but not!", move_from_chunk);
1042-
const auto pg_id = vchunk->m_pg_id.value();
1043-
10441042
RELEASE_ASSERT(vchunk->m_v_chunk_id.has_value(), "pg={}, chunk_id={} is expected to have a vchunk id, but not!",
10451043
pg_id, move_from_chunk);
10461044
const auto vchunk_id = vchunk->m_v_chunk_id.value();
@@ -1056,22 +1054,25 @@ void GCManager::pdev_gc_actor::process_gc_task(chunk_id_t move_from_chunk, uint8
10561054

10571055
if (!purge_reserved_chunk(move_to_chunk)) {
10581056
LOGWARN("gc task_id={}, can not purge move_to_chunk={}", task_id, move_to_chunk);
1059-
handle_error_before_persisting_gc_metablk(move_from_chunk, move_to_chunk, std::move(task), task_id, priority);
1057+
handle_error_before_persisting_gc_metablk(move_from_chunk, move_to_chunk, std::move(task), task_id, priority,
1058+
pg_id);
10601059
return;
10611060
}
10621061

10631062
if (!copy_valid_data(move_from_chunk, move_to_chunk, task_id)) {
10641063
LOGWARN("gc task_id={}, failed to copy data from move_from_chunk={} to move_to_chunk={} with priority={}",
10651064
task_id, move_from_chunk, move_to_chunk, priority);
1066-
handle_error_before_persisting_gc_metablk(move_from_chunk, move_to_chunk, std::move(task), task_id, priority);
1065+
handle_error_before_persisting_gc_metablk(move_from_chunk, move_to_chunk, std::move(task), task_id, priority,
1066+
pg_id);
10671067
return;
10681068
}
10691069

10701070
std::vector< std::pair< BlobRouteByChunkKey, BlobRouteValue > > valid_blob_indexes;
10711071
if (!get_blobs_to_replace(move_to_chunk, valid_blob_indexes)) {
10721072
LOGWARN("gc task_id={}, failed to get valid blob indexes from gc index table for move_to_chunk={}", task_id,
10731073
move_to_chunk);
1074-
handle_error_before_persisting_gc_metablk(move_from_chunk, move_to_chunk, std::move(task), task_id, priority);
1074+
handle_error_before_persisting_gc_metablk(move_from_chunk, move_to_chunk, std::move(task), task_id, priority,
1075+
pg_id);
10751076
return;
10761077
}
10771078

src/lib/homestore_backend/gc_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class GCManager {
233233

234234
void handle_error_before_persisting_gc_metablk(chunk_id_t move_from_chunk, chunk_id_t move_to_chunk,
235235
folly::Promise< bool > task, const uint64_t task_id,
236-
uint8_t priority);
236+
uint8_t priority, const pg_id_t& pg_id);
237237

238238
pdev_gc_metrics& metrics() { return metrics_; }
239239

0 commit comments

Comments
 (0)