Skip to content

Commit 5857503

Browse files
committed
Merge branch 'tui1350'
ensure that Record GC threshold is non-decreasing
2 parents 9c0282b + e310a48 commit 5857503

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/concurrency_control/epoch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ static inline void compute_and_set_cc_safe_ss_epoch() {
145145
}
146146
}
147147

148+
// ASSERTION
149+
if (auto old = get_cc_safe_ss_epoch(); result_epoch < old) {
150+
LOG_FIRST_N(ERROR, 100) << log_location_prefix << "programming error."
151+
<< " cc_safe_ss_epoch back from " << old << " to " << result_epoch;
152+
}
153+
148154
// set cc safe ss epoch
149155
set_cc_safe_ss_epoch(result_epoch);
150156
}

src/concurrency_control/garbage.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,23 @@ void work_manager() {
108108
LOG_FIRST_N(ERROR, 1) << log_location_prefix
109109
<< log_location_prefix << "epoch error";
110110
}
111-
set_min_begin_epoch(min_begin_epoch);
112111
} else {
113112
/**
114113
* above loop didn't find living tx. at least, befor_loop epoch is
115114
* minimum begin epoch.
116115
*/
117-
set_min_begin_epoch(before_loop);
116+
min_begin_epoch = before_loop;
117+
}
118+
// NB. The calculation method used in the code above has a potential concurrency flaws,
119+
// as it can miss recently begun transactions,
120+
// which can result in a smaller value than the previously calculated value of min_begin_epoch.
121+
// But even if the calculated value of min_begin_epoch is small,
122+
// OCC reads/writes the latest version, and never reads/writes that version.
123+
// Therefore, instead of correcting the calculation method, simply discards the smaller value.
124+
if (auto old = get_min_begin_epoch(); min_begin_epoch > old) {
125+
set_min_begin_epoch(min_begin_epoch);
126+
} else if (min_begin_epoch < old) {
127+
VLOG(log_debug) << log_location_prefix << "min_begin_epoch back from " << old << " to " << min_begin_epoch << " (ignored)";
118128
}
119129
// computing about ltx
120130
if (valid_epoch != 0) {

0 commit comments

Comments
 (0)