Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukang-Lian committed Nov 28, 2024
1 parent a4d9aaa commit 47fc072
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cloud/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ CONF_mInt64(recycler_sleep_before_scheduling_seconds, "60");
// log a warning if a recycle task takes longer than this duration
CONF_mInt64(recycle_task_threshold_seconds, "10800"); // 3h

// force recycler to recycle all useless object.
// **just for TEST**
CONF_mInt64(recycle_retention_test_seconds, "-1"); // 3h

CONF_String(test_s3_ak, "");
CONF_String(test_s3_sk, "");
CONF_String(test_s3_endpoint, "");
Expand Down
18 changes: 13 additions & 5 deletions cloud/src/recycler/recycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,9 @@ int InstanceRecycler::recycle_indexes() {
retention_seconds =
std::min(config::dropped_index_retention_seconds, retention_seconds);
}
return expiration + retention_seconds;
return config::recycle_retention_test_seconds > 0
? ::time(nullptr) + config::recycle_retention_test_seconds
: expiration + retention_seconds;
};

// Elements in `index_keys` has the same lifetime as `it` in `scan_and_recycle`
Expand Down Expand Up @@ -946,7 +948,9 @@ int InstanceRecycler::recycle_partitions() {
retention_seconds =
std::min(config::dropped_partition_retention_seconds, retention_seconds);
}
return expiration + retention_seconds;
return config::recycle_retention_test_seconds > 0
? ::time(nullptr) + config::recycle_retention_test_seconds
: expiration + retention_seconds;
};

// Elements in `partition_keys` has the same lifetime as `it` in `scan_and_recycle`
Expand Down Expand Up @@ -1688,7 +1692,9 @@ int InstanceRecycler::recycle_rowsets() {
retention_seconds =
std::min(config::compacted_rowset_retention_seconds, retention_seconds);
}
return expiration + retention_seconds;
return config::recycle_retention_test_seconds > 0
? ::time(nullptr) + config::recycle_retention_test_seconds
: expiration + retention_seconds;
};

auto handle_rowset_kv = [&](std::string_view k, std::string_view v) -> int {
Expand Down Expand Up @@ -1917,8 +1923,10 @@ int InstanceRecycler::recycle_tmp_rowsets() {
// ATTN: `txn_expiration` should > 0, however we use `creation_time` + a large `retention_time` (> 1 day in production environment)
// when `txn_expiration` <= 0 in some unexpected situation (usually when there are bugs). This is usually safe, coz loading
// duration or timeout always < `retention_time` in practice.
int64_t expiration =
rowset.txn_expiration() > 0 ? rowset.txn_expiration() : rowset.creation_time();
int64_t expiration = config::recycle_retention_test_seconds >= 0
? ::time(nullptr) + config::recycle_retention_test_seconds
: rowset.txn_expiration() > 0 ? rowset.txn_expiration()
: rowset.creation_time();
VLOG_DEBUG << "recycle tmp rowset scan, key=" << hex(k) << " num_scanned=" << num_scanned
<< " num_expired=" << num_expired << " expiration=" << expiration
<< " txn_expiration=" << rowset.txn_expiration()
Expand Down

0 comments on commit 47fc072

Please sign in to comment.