summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-12-02 10:39:42 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-12-02 14:42:08 -0500
commit4923623142d9a014fc8ee3d6f72f4f974e20e728 (patch)
treebe3fe8752dcb63f3590a4e629d55ea4f49626b66
parent5c33c7c5b538bc01094127ba6e9c6531a79886d1 (diff)
downloadmongo-4923623142d9a014fc8ee3d6f72f4f974e20e728.tar.gz
SERVER-16354 Delete the recovery unit in IndexCatalogEntry::setMultikey
-rw-r--r--src/mongo/db/catalog/index_catalog_entry.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/index_catalog_entry.cpp b/src/mongo/db/catalog/index_catalog_entry.cpp
index 31a0aaba355..cc4e04e21f1 100644
--- a/src/mongo/db/catalog/index_catalog_entry.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry.cpp
@@ -141,13 +141,19 @@ namespace mongo {
}
+ /**
+ * RAII class, which associates a new RecoveryUnit with an OperationContext for the purposes
+ * of simulating a sub-transaction. Takes ownership of the new recovery unit and frees it at
+ * destruction time.
+ */
class RecoveryUnitSwap {
public:
RecoveryUnitSwap(OperationContext* txn, RecoveryUnit* newRecoveryUnit)
: _txn(txn),
- _oldRecoveryUnit(_txn->releaseRecoveryUnit()) {
+ _oldRecoveryUnit(_txn->releaseRecoveryUnit()),
+ _newRecoveryUnit(newRecoveryUnit) {
- _txn->setRecoveryUnit(newRecoveryUnit);
+ _txn->setRecoveryUnit(_newRecoveryUnit.get());
}
~RecoveryUnitSwap() {
@@ -156,9 +162,14 @@ namespace mongo {
}
private:
- // Neither of these are owned
+ // Not owned
OperationContext* const _txn;
+
+ // Owned, but life-time is not controlled
RecoveryUnit* const _oldRecoveryUnit;
+
+ // Owned and life-time is controlled
+ const boost::scoped_ptr<RecoveryUnit> _newRecoveryUnit;
};
void IndexCatalogEntry::setMultikey(OperationContext* txn) {