Skip to content

Commit f18b981

Browse files
Sriram Ganesandaverigby
authored andcommitted
MB-29501: Validate cookie before doing a TRACE_BEGIN/TRACE_END
The tracing macros TRACE_BEGIN/TRACE_END require that a valid cookie is passed in to these macros. So, ensure that the cookie is valid and then call TRACE_BEGIN in the VBucketBGFetchItem constructor Change-Id: I7b1f60082dc4586354933c4bc24fe6e8ade17178 Reviewed-on: http://review.couchbase.org/93719 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 2a69644 commit f18b981

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

engines/ep/src/ep_vb.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,12 @@ ENGINE_ERROR_CODE EPVBucket::completeBGFetchForSingleItem(
187187
updateBGStats(fetched_item.initTime, startTime, fetchEnd);
188188

189189
// Close the BG_WAIT span; and add a BG_LOAD span
190-
TRACE_END(fetched_item.cookie, cb::tracing::TraceCode::BG_WAIT, startTime);
191-
TRACE_BEGIN(
192-
fetched_item.cookie, cb::tracing::TraceCode::BG_LOAD, startTime);
193-
TRACE_END(fetched_item.cookie, cb::tracing::TraceCode::BG_LOAD, fetchEnd);
190+
if (fetched_item.cookie) {
191+
TRACE_END(fetched_item.cookie, cb::tracing::TraceCode::BG_WAIT, startTime);
192+
TRACE_BEGIN(
193+
fetched_item.cookie, cb::tracing::TraceCode::BG_LOAD, startTime);
194+
TRACE_END(fetched_item.cookie, cb::tracing::TraceCode::BG_LOAD, fetchEnd);
195+
}
194196

195197
return status;
196198
}

engines/ep/src/vbucket_bgfetch_item.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class VBucketBGFetchItem {
3636
cookie(c),
3737
initTime(init_time),
3838
metaDataOnly(meta_only) {
39-
TRACE_BEGIN(cookie, cb::tracing::TraceCode::BG_WAIT, init_time);
39+
if (cookie) {
40+
TRACE_BEGIN(cookie, cb::tracing::TraceCode::BG_WAIT, init_time);
41+
}
4042
}
4143

4244
GetValue* value;

0 commit comments

Comments
 (0)