diff options
author | Randolph Tan <randolph@10gen.com> | 2019-03-25 16:44:32 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2019-04-03 16:08:25 -0400 |
commit | 47153dbf7aebeba9a5b9086a82709adfa6fd7226 (patch) | |
tree | 79fbadde42332add71593f572be0ea9cf4ec000a /src/mongo/db/s/migration_chunk_cloner_source_legacy.h | |
parent | dd589aa07a0155cdeaa70f0403466aabcfaa5186 (diff) | |
download | mongo-47153dbf7aebeba9a5b9086a82709adfa6fd7226.tar.gz |
SERVER-40301 Don't hold mutex while doing queries in nextCloneBatch and nextModsBatch
Diffstat (limited to 'src/mongo/db/s/migration_chunk_cloner_source_legacy.h')
-rw-r--r-- | src/mongo/db/s/migration_chunk_cloner_source_legacy.h | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.h b/src/mongo/db/s/migration_chunk_cloner_source_legacy.h index 3874f03e76a..1fd34944a8b 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.h +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.h @@ -120,7 +120,8 @@ public: /** * Called by the recipient shard. Populates the passed BSONArrayBuilder with a set of documents, - * which are part of the initial clone sequence. + * which are part of the initial clone sequence. Assumes that there is only one active caller + * to this method at a time (otherwise, it can cause corruption/crash). * * Returns OK status on success. If there were documents returned in the result argument, this * method should be called more times until the result is empty. If it returns failure, it is @@ -201,22 +202,6 @@ private: */ Status _storeCurrentLocs(OperationContext* opCtx); - /** - * Insert items from docIdList to a new array with the given fieldName in the given builder. If - * explode is true, the inserted object will be the full version of the document. Note that - * whenever an item from the docList is inserted to the array, it will also be removed from - * docList. - * - * Should be holding the collection lock for ns if explode is true. - */ - void _xfer(OperationContext* opCtx, - Database* db, - std::list<BSONObj>* docIdList, - BSONObjBuilder* builder, - const char* fieldName, - long long* sizeAccumulator, - bool explode); - /* * Consumes the operation track request and appends the relevant document changes to * the appropriate internal data structures (known colloquially as the 'transfer mods queue'). @@ -266,6 +251,26 @@ private: */ void _drainAllOutstandingOperationTrackRequests(stdx::unique_lock<stdx::mutex>& lk); + /** + * Appends to the builder the list of _id of documents that were deleted during migration. + * Entries appended to the builder are removed from the list. + * Returns the total size of the documents that were appended + initialSize. + */ + long long _xferDeletes(BSONObjBuilder* builder, + std::list<BSONObj>* removeList, + long long initialSize); + + /** + * Appends to the builder the list of full documents that were modified/inserted during the + * migration. Entries appended to the builder are removed from the list. + * Returns the total size of the documents that were appended + initialSize. + */ + long long _xferUpdates(OperationContext* opCtx, + Database* db, + BSONObjBuilder* builder, + std::list<BSONObj>* updateList, + long long initialSize); + // The original move chunk request const MoveChunkRequest _args; |