diff options
author | Geert Bosch <geert@mongodb.com> | 2015-05-05 18:19:19 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2015-05-06 14:06:36 -0400 |
commit | bb112233c8b7717a8f83501fc8d992c07731f817 (patch) | |
tree | ec306f0f8f1757e0a329d49ada389970f506abc8 | |
parent | d2cb8db14acb5dd47a0479583f962740520c5723 (diff) | |
download | mongo-bb112233c8b7717a8f83501fc8d992c07731f817.tar.gz |
SERVER-17018: Only invalidate cursors pointing to the same index
-rw-r--r-- | src/mongo/db/index/btree_index_cursor.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/index/btree_index_cursor.h | 7 | ||||
-rw-r--r-- | src/mongo/db/structure/btree/btree.cpp | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/db/index/btree_index_cursor.cpp b/src/mongo/db/index/btree_index_cursor.cpp index be1472241f3..528a0a5ff4d 100644 --- a/src/mongo/db/index/btree_index_cursor.cpp +++ b/src/mongo/db/index/btree_index_cursor.cpp @@ -63,13 +63,14 @@ namespace mongo { bool BtreeIndexCursor::isEOF() const { return _bucket.isNull(); } - void BtreeIndexCursor::aboutToDeleteBucket(const DiskLoc& bucket) { + void BtreeIndexCursor::aboutToDeleteBucket(const IndexCatalogEntry* index, + const DiskLoc& bucket) { SimpleMutex::scoped_lock lock(_activeCursorsMutex); for (unordered_set<BtreeIndexCursor*>::iterator i = _activeCursors.begin(); i != _activeCursors.end(); ++i) { BtreeIndexCursor* ic = *i; - if (bucket == ic->_bucket) { + if (bucket == ic->_bucket && ic->_btreeState == index) { ic->_keyOffset = -1; } } diff --git a/src/mongo/db/index/btree_index_cursor.h b/src/mongo/db/index/btree_index_cursor.h index 73a7923095e..8562660738e 100644 --- a/src/mongo/db/index/btree_index_cursor.h +++ b/src/mongo/db/index/btree_index_cursor.h @@ -46,9 +46,12 @@ namespace mongo { bool isEOF() const; /** - * Called from btree.cpp when we're about to delete a Btree bucket. + * Called from btree.cpp when we're about to delete a Btree bucket. The index descriptor + * is needed as just the DiskLoc of the bucket is not unique across databases, which might + * result in incorrect invalidation of cursors in other unlocked databases. */ - static void aboutToDeleteBucket(const DiskLoc& bucket); + static void aboutToDeleteBucket(const IndexCatalogEntry* index, + const DiskLoc& bucket); virtual Status setOptions(const CursorOptions& options); diff --git a/src/mongo/db/structure/btree/btree.cpp b/src/mongo/db/structure/btree/btree.cpp index 2eef1bd55e4..3e2286fe418 100644 --- a/src/mongo/db/structure/btree/btree.cpp +++ b/src/mongo/db/structure/btree/btree.cpp @@ -859,7 +859,7 @@ namespace mongo { template< class V > void BtreeBucket<V>::delBucket(IndexCatalogEntry* btreeState, const DiskLoc thisLoc ) { - BtreeIndexCursor::aboutToDeleteBucket(thisLoc); + BtreeIndexCursor::aboutToDeleteBucket(btreeState, thisLoc); verify( !isHead() ); DiskLoc ll = this->parent; @@ -1000,7 +1000,7 @@ namespace mongo { ll.btree<V>()->childForPos( indexInParent( thisLoc ) ).writing() = this->nextChild; } BTREE(this->nextChild)->parent.writing() = this->parent; - BtreeIndexCursor::aboutToDeleteBucket(thisLoc); + BtreeIndexCursor::aboutToDeleteBucket(btreeState, thisLoc); deallocBucket( btreeState, thisLoc ); } |