summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2013-05-01 09:25:03 -0400
committerDan Pasette <dan@10gen.com>2013-05-13 01:30:42 -0400
commit4dc1cd907aa84733c3d5f68eb8c4a52beef229a3 (patch)
tree96007629fe0db65aa350307a3581b3d2aee6bec9
parentbd9e9d04bc0f0d35b19e97421bb7f28fc349443a (diff)
downloadmongo-4dc1cd907aa84733c3d5f68eb8c4a52beef229a3.tar.gz
SERVER-9333 correct reference counting of GhostSlave members
The _ghostCache contains shared pointers to GhostSlave members. When we clear this cache, we decrement all the reference counts to these objects. Because we were not keeping a shared_ptr to a GhostSlave object in percolate(), but instead were using a bare pointer, this caused the bare pointer to be deleted out from under us when we cleared the cache. This in turn caused the internal objects like the OplogReader to be deleted, which caused segfaults in percolate() when we attempted to advance the oplogreader cursor.
-rw-r--r--src/mongo/db/repl/rs_sync.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/mongo/db/repl/rs_sync.cpp b/src/mongo/db/repl/rs_sync.cpp
index 548b646c342..4970650d7e8 100644
--- a/src/mongo/db/repl/rs_sync.cpp
+++ b/src/mongo/db/repl/rs_sync.cpp
@@ -832,7 +832,7 @@ namespace replset {
void GhostSync::percolate(const BSONObj& id, const OpTime& last) {
const OID rid = id["_id"].OID();
- GhostSlave* slave;
+ shared_ptr<GhostSlave> slave;
{
rwlock lk( _lock , false );
@@ -842,13 +842,12 @@ namespace replset {
return;
}
- slave = i->second.get();
+ slave = i->second;
if (!slave->init) {
OCCASIONALLY log() << "couldn't percolate slave " << rid << " not init" << rsLog;
return;
}
}
-
verify(slave->slave);
const Member *target = replset::BackgroundSync::get()->getSyncTarget();