summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2016-09-19 10:00:14 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2016-09-19 10:51:36 -0400
commit69c7bd7247639e143d21db25460d33667224a8b1 (patch)
tree35c1b03b821841dcaa88cbed5b4996ae943c9f76
parent689940149701364a6beaee7e2d95effb84bcfb31 (diff)
downloadmongo-69c7bd7247639e143d21db25460d33667224a8b1.tar.gz
SERVER-26160 Store std::string in ReplSetDistLockManager instead of StringData
-rw-r--r--src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp13
-rw-r--r--src/mongo/s/catalog/replset/replset_dist_lock_manager.h4
2 files changed, 8 insertions, 9 deletions
diff --git a/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp b/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp
index 27b80627647..5f1fc1eddeb 100644
--- a/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp
+++ b/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp
@@ -142,7 +142,7 @@ void ReplSetDistLockManager::doTask() {
}
elapsedSincelastPing.reset();
- std::deque<std::pair<DistLockHandle, boost::optional<StringData>>> toUnlockBatch;
+ std::deque<std::pair<DistLockHandle, boost::optional<std::string>>> toUnlockBatch;
{
stdx::unique_lock<stdx::mutex> lk(_mutex);
toUnlockBatch.swap(_unlockList);
@@ -154,9 +154,8 @@ void ReplSetDistLockManager::doTask() {
"status unlock not initialized!");
if (toUnlock.second) {
// A non-empty _id (name) field was provided, unlock by ts (sessionId) and _id.
- unlockStatus =
- _catalog->unlock(txn.get(), toUnlock.first, toUnlock.second.get());
- nameMessage = " and " + LocksType::name() + ": " + toUnlock.second->toString();
+ unlockStatus = _catalog->unlock(txn.get(), toUnlock.first, *toUnlock.second);
+ nameMessage = " and " + LocksType::name() + ": " + *toUnlock.second;
} else {
unlockStatus = _catalog->unlock(txn.get(), toUnlock.first);
}
@@ -347,7 +346,7 @@ StatusWith<DistLockHandle> ReplSetDistLockManager::lockWithSessionID(OperationCo
if (status != ErrorCodes::LockStateChangeFailed) {
// An error occurred but the write might have actually been applied on the
// other side. Schedule an unlock to clean it up just in case.
- queueUnlock(lockSessionID, name);
+ queueUnlock(lockSessionID, name.toString());
return status;
}
@@ -464,7 +463,7 @@ void ReplSetDistLockManager::unlock(OperationContext* txn,
auto unlockStatus = _catalog->unlock(txn, lockSessionID, name);
if (!unlockStatus.isOK()) {
- queueUnlock(lockSessionID, name);
+ queueUnlock(lockSessionID, name.toString());
} else {
LOG(0) << "distributed lock with " << LocksType::lockID() << ": '" << lockSessionID
<< "' and " << LocksType::name() << ": '" << name.toString() << "' unlocked.";
@@ -485,7 +484,7 @@ Status ReplSetDistLockManager::checkStatus(OperationContext* txn,
}
void ReplSetDistLockManager::queueUnlock(const DistLockHandle& lockSessionID,
- const boost::optional<StringData>& name) {
+ const boost::optional<std::string>& name) {
stdx::unique_lock<stdx::mutex> lk(_mutex);
_unlockList.push_back(std::make_pair(lockSessionID, name));
}
diff --git a/src/mongo/s/catalog/replset/replset_dist_lock_manager.h b/src/mongo/s/catalog/replset/replset_dist_lock_manager.h
index 4731cd0bf3a..a05221de08b 100644
--- a/src/mongo/s/catalog/replset/replset_dist_lock_manager.h
+++ b/src/mongo/s/catalog/replset/replset_dist_lock_manager.h
@@ -93,7 +93,7 @@ private:
/**
* Queue a lock to be unlocked asynchronously with retry until it doesn't error.
*/
- void queueUnlock(const DistLockHandle& lockSessionID, const boost::optional<StringData>& name);
+ void queueUnlock(const DistLockHandle& lockSessionID, const boost::optional<std::string>& name);
/**
* Periodically pings and checks if there are locks queued that needs unlocking.
@@ -139,7 +139,7 @@ private:
// 2. Attempting to grab or overtake a lock resulted in an error where we are uncertain
// whether the modification was actually applied or not, and call unlock to make
// sure that it was cleaned up.
- std::deque<std::pair<DistLockHandle, boost::optional<StringData>>> _unlockList; // (M)
+ std::deque<std::pair<DistLockHandle, boost::optional<std::string>>> _unlockList; // (M)
bool _isShutDown = false; // (M)
stdx::condition_variable _shutDownCV; // (M)