Skip to content

Commit c20e84a

Browse files
committed
MB-34995: [DM] Keys should be marked for log redaction
Add log redaction tags for the keys when used in exceptions or logs in the durability manager. Change-Id: I05c96243d426e8573a6a73148492c0ea04ac08f3 Reviewed-on: http://review.couchbase.org/112019 Tested-by: Trond Norbye <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent a9f305b commit c20e84a

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

engines/ep/src/durability/active_durability_monitor.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <folly/concurrency/UnboundedQueue.h>
2929

3030
#include <gsl.h>
31+
#include <utilities/logtags.h>
3132

3233
/*
3334
* This class embeds the state of an ADM. It has been designed for being
@@ -950,8 +951,8 @@ void ActiveDurabilityMonitor::commit(const SyncWrite& sw) {
950951

951952
if (globalBucketLogger->should_log(spdlog::level::debug)) {
952953
std::stringstream ss;
953-
ss << "SyncWrite commit \"" << key << "\": ack'ed by {"
954-
<< boost::join(sw.getAckedNodes(), ", ") << "}";
954+
ss << "SyncWrite commit \"" << cb::tagUserData(key.to_string())
955+
<< "\": ack'ed by {" << boost::join(sw.getAckedNodes(), ", ") << "}";
955956

956957
EP_LOG_DEBUG(ss.str());
957958
}

engines/ep/src/durability/durability_monitor_impl.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "durability_monitor_impl.h"
1919
#include <folly/lang/Assume.h>
2020
#include <gsl.h>
21+
#include <utilities/logtags.h>
2122

2223
/// Helper function to determine the expiry time for a SyncWrite from the
2324
/// durability requirements.
@@ -233,7 +234,8 @@ std::unordered_set<std::string> DurabilityMonitor::SyncWrite::getAckedNodes()
233234
std::ostream& operator<<(std::ostream& os,
234235
const DurabilityMonitor::SyncWrite& sw) {
235236
os << "SW @" << &sw << " "
236-
<< "cookie:" << sw.cookie << " qi:[key:'" << sw.item->getKey()
237+
<< "cookie:" << sw.cookie << " qi:[key:'"
238+
<< cb::tagUserData(sw.item->getKey().to_string())
237239
<< "' seqno:" << sw.item->getBySeqno()
238240
<< " reqs:" << to_string(sw.item->getDurabilityReqs()) << "] maj:"
239241
<< std::to_string(sw.firstChain ? sw.firstChain.chainPtr->majority : 0)

engines/ep/src/durability/passive_durability_monitor.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <boost/range/adaptor/reversed.hpp>
2929
#include <gsl.h>
30+
#include <utilities/logtags.h>
3031
#include <unordered_map>
3132

3233
PassiveDurabilityMonitor::PassiveDurabilityMonitor(VBucket& vb)
@@ -190,10 +191,10 @@ void PassiveDurabilityMonitor::completeSyncWrite(const StoredDocKey& key,
190191
auto s = state.wlock();
191192

192193
if (s->trackedWrites.empty()) {
193-
throwException<std::logic_error>(__func__,
194-
"No tracked, but received " +
195-
to_string(res) + " for key " +
196-
key.to_string());
194+
throwException<std::logic_error>(
195+
__func__,
196+
"No tracked, but received " + to_string(res) + " for key " +
197+
cb::tagUserData(key.to_string()));
197198
}
198199

199200
const auto next = s->getIteratorNext(s->highCompletedSeqno.it);
@@ -202,15 +203,16 @@ void PassiveDurabilityMonitor::completeSyncWrite(const StoredDocKey& key,
202203
throwException<std::logic_error>(
203204
__func__,
204205
"No Prepare waiting for completion, but received " +
205-
to_string(res) + " for key " + key.to_string());
206+
to_string(res) + " for key " +
207+
cb::tagUserData(key.to_string()));
206208
}
207209

208210
// Sanity check for In-Order Commit
209211
if (next->getKey() != key) {
210212
std::stringstream ss;
211213
ss << "Pending resolution for '" << *next
212214
<< "', but received unexpected " + to_string(res) + " for key "
213-
<< key;
215+
<< cb::tagUserData(key.to_string());
214216
throwException<std::logic_error>(__func__, "" + ss.str());
215217
}
216218

0 commit comments

Comments
 (0)