diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-10-06 15:12:40 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-10-11 00:52:09 -0400 |
commit | 45d35fe3fcefefe1282b8e0dfc8cd76cb247951d (patch) | |
tree | 6643f175807ae1c20902885846d29e888127f9a6 /src/mongo/db/sessions_collection.cpp | |
parent | 8b3694d704d4c472adba87e8fb0827372324c215 (diff) | |
download | mongo-45d35fe3fcefefe1282b8e0dfc8cd76cb247951d.tar.gz |
SERVER-31184 Make servers automatically set up config.system.sessions
Diffstat (limited to 'src/mongo/db/sessions_collection.cpp')
-rw-r--r-- | src/mongo/db/sessions_collection.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/sessions_collection.cpp b/src/mongo/db/sessions_collection.cpp index 69e420f40b8..ec0d2f43a8b 100644 --- a/src/mongo/db/sessions_collection.cpp +++ b/src/mongo/db/sessions_collection.cpp @@ -35,6 +35,7 @@ #include "mongo/bson/bsonobjbuilder.h" #include "mongo/client/dbclientinterface.h" +#include "mongo/db/create_indexes_gen.h" #include "mongo/db/logical_session_id.h" #include "mongo/db/ops/write_ops.h" #include "mongo/db/refresh_sessions_gen.h" @@ -204,6 +205,7 @@ Status SessionsCollection::doRefresh(const NamespaceString& ns, auto init = [ns](BSONObjBuilder* batch) { batch->append("update", ns.coll()); batch->append("ordered", false); + batch->append("allowImplicitCollectionCreation", false); }; auto add = [](BSONArrayBuilder* entries, const LogicalSessionRecord& record) { @@ -309,4 +311,19 @@ StatusWith<LogicalSessionIdSet> SessionsCollection::doFetch(const NamespaceStrin return removed; } +BSONObj SessionsCollection::generateCreateIndexesCmd() { + NewIndexSpec index; + index.setKey(BSON("lastUse" << 1)); + index.setName("lsidTTLIndex"); + index.setExpireAfterSeconds(localLogicalSessionTimeoutMinutes * 60); + + std::vector<NewIndexSpec> indexes; + indexes.push_back(std::move(index)); + + CreateIndexesCmd createIndexes; + createIndexes.setCreateIndexes(kSessionsCollection.toString()); + createIndexes.setIndexes(std::move(indexes)); + + return createIndexes.toBSON(); +} } // namespace mongo |