Skip to content

Commit e613ef5

Browse files
daverigbyowend74
authored andcommitted
MB-33918: Add log messages for Cursor Dropping triggering
Change-Id: I6fa2a6591fc2bf58e0cf67bbe7d920148a228fdd Reviewed-on: http://review.couchbase.org/108280 Well-Formed: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent bfb2058 commit e613ef5

File tree

1 file changed

+46
-16
lines changed

1 file changed

+46
-16
lines changed

engines/ep/src/checkpoint_remover.cc

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,37 +103,67 @@ void ClosedUnrefCheckpointRemoverTask::cursorDroppingIfNeeded(void) {
103103
* cursor_dropping_lower_mark or cursor_dropping_checkpoint_mem_lower_mark
104104
* based on the trigger condition.
105105
*/
106-
const auto bucketQuota = engine->getConfiguration().getMaxSize();
106+
const auto& config = engine->getConfiguration();
107+
const auto bucketQuota = config.getMaxSize();
107108

108-
const bool aboveLowWatermark =
109-
stats.getEstimatedTotalMemoryUsed() >= stats.mem_low_wat.load();
110-
const bool hitCheckpointMemoryThreshold =
109+
const auto activeVBChkptMemSize =
111110
engine->getKVBucket()
112111
->getVBuckets()
113-
.getActiveVBucketsTotalCheckpointMemoryUsage() >=
114-
bucketQuota * (engine->getConfiguration()
115-
.getCursorDroppingCheckpointMemUpperMark() /
116-
100);
117-
118-
if (stats.getEstimatedTotalMemoryUsed() >
119-
stats.cursorDroppingUThreshold.load() ||
120-
(aboveLowWatermark && hitCheckpointMemoryThreshold)) {
112+
.getActiveVBucketsTotalCheckpointMemoryUsage();
113+
114+
const auto chkptMemLimit =
115+
bucketQuota *
116+
(config.getCursorDroppingCheckpointMemUpperMark() / 100);
117+
118+
const bool hitCheckpointMemoryThreshold =
119+
activeVBChkptMemSize >= chkptMemLimit;
120+
121+
const bool aboveLowWatermark =
122+
stats.getEstimatedTotalMemoryUsed() >= stats.mem_low_wat.load();
123+
124+
const bool ckptMemExceedsCheckpointMemoryThreshold =
125+
aboveLowWatermark && hitCheckpointMemoryThreshold;
126+
127+
const bool memUsedExceedsCursorDroppingUpperMark =
128+
stats.getEstimatedTotalMemoryUsed() >
129+
stats.cursorDroppingUThreshold.load();
130+
131+
auto toMB = [](size_t bytes) { return bytes / (1024 * 1024); };
132+
if (memUsedExceedsCursorDroppingUpperMark ||
133+
ckptMemExceedsCheckpointMemoryThreshold) {
121134
size_t amountOfMemoryToClear;
122-
if (aboveLowWatermark && hitCheckpointMemoryThreshold) {
135+
136+
if (ckptMemExceedsCheckpointMemoryThreshold) {
123137
// If we were triggered by the fact we hit the low watermark and we
124138
// are over the threshold of allowed checkpoint memory usage, then
125139
// try to clear memory down to the lower limit of the allowable
126140
// memory usage threshold.
127141
amountOfMemoryToClear =
128142
stats.getEstimatedTotalMemoryUsed() -
129143
(bucketQuota *
130-
(engine->getConfiguration()
131-
.getCursorDroppingCheckpointMemLowerMark() /
132-
100));
144+
(config.getCursorDroppingCheckpointMemLowerMark() / 100));
145+
LOG(EXTENSION_LOG_INFO,
146+
"Triggering cursor dropping as checkpoint_memory (%lu MB) "
147+
"exceeds cursor_dropping_checkpoint_mem_upper_mark (%lu%%, "
148+
"%lu MB). Attempting to free %lu MB of memory.",
149+
toMB(activeVBChkptMemSize),
150+
config.getCursorDroppingCheckpointMemUpperMark(),
151+
toMB(chkptMemLimit),
152+
toMB(amountOfMemoryToClear));
153+
133154
} else {
134155
amountOfMemoryToClear = stats.getEstimatedTotalMemoryUsed() -
135156
stats.cursorDroppingLThreshold.load();
157+
LOG(EXTENSION_LOG_INFO,
158+
"Triggering cursor dropping as mem_used (%lu MB) "
159+
"exceeds cursor_dropping_upper_mark (%lu%%, %lu MB). "
160+
"Attempting to free %lu MB of memory.",
161+
toMB(stats.getEstimatedTotalMemoryUsed()),
162+
config.getCursorDroppingUpperMark(),
163+
toMB(stats.cursorDroppingUThreshold.load()),
164+
toMB(amountOfMemoryToClear));
136165
}
166+
137167
size_t memoryCleared = 0;
138168
KVBucketIface* kvBucket = engine->getKVBucket();
139169
// Get a list of active vbuckets sorted by memory usage

0 commit comments

Comments
 (0)