summaryrefslogtreecommitdiff
path: root/src/mongo/db/sessions_collection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/sessions_collection.cpp')
-rw-r--r--src/mongo/db/sessions_collection.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/mongo/db/sessions_collection.cpp b/src/mongo/db/sessions_collection.cpp
index a5595f21dbf..6deccfe9ff3 100644
--- a/src/mongo/db/sessions_collection.cpp
+++ b/src/mongo/db/sessions_collection.cpp
@@ -42,26 +42,13 @@
#include "mongo/db/logical_session_id_helpers.h"
#include "mongo/db/ops/write_ops.h"
#include "mongo/db/repl/read_concern_args.h"
+#include "mongo/db/sessions_server_parameters_gen.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/util/duration.h"
namespace mongo {
namespace {
-// This batch size is chosen to ensure that we don't form requests larger than the 16mb limit.
-// Especially for refreshes, the updates we send include the full user name (user@db), and user
-// names can be quite large (we enforce a max 10k limit for usernames used with sessions).
-//
-// At 1000 elements, a 16mb payload gives us a budget of 16000 bytes per user, which we should
-// comfortably be able to stay under, even with 10k user names.
-constexpr size_t kMaxBatchSize = 1000;
-
-// Used to refresh or remove items from the session collection with write
-// concern majority
-const WriteConcernOptions kMajorityWriteConcern{WriteConcernOptions::kMajority,
- WriteConcernOptions::SyncMode::UNSET,
- WriteConcernOptions::kWriteConcernTimeoutSystem};
-
-
BSONObj lsidQuery(const LogicalSessionId& lsid) {
return BSON(LogicalSessionRecord::kIdFieldName << lsid.toBSON());
}
@@ -104,7 +91,7 @@ void runBulkGeneric(TFactory makeT, AddLineFn addLine, SendFn sendBatch, const C
for (const auto& item : items) {
addLine(*thing, item);
- if (++i >= kMaxBatchSize) {
+ if (++i >= std::size_t(mongo::gSessionMaxBatchSize.load())) {
sendLocalBatch();
setupBatch();
@@ -192,7 +179,14 @@ SessionsCollection::FindBatchFn SessionsCollection::makeFindFnForCommand(const N
void SessionsCollection::_doRefresh(const NamespaceString& ns,
const std::vector<LogicalSessionRecord>& sessions,
SendBatchFn send) {
- auto init = [ns](BSONObjBuilder* batch) {
+ // Used to refresh items from the session collection with write
+ // concern majority
+ const WriteConcernOptions kMajorityWriteConcern{
+ WriteConcernOptions::kMajority,
+ WriteConcernOptions::SyncMode::UNSET,
+ Milliseconds(mongo::gSessionWriteConcernTimeoutSystemMillis.load())};
+
+ auto init = [ns, kMajorityWriteConcern](BSONObjBuilder* batch) {
batch->append("update", ns.coll());
batch->append("ordered", false);
batch->append(WriteConcernOptions::kWriteConcernField, kMajorityWriteConcern.toBSON());
@@ -202,14 +196,20 @@ void SessionsCollection::_doRefresh(const NamespaceString& ns,
entries->append(
BSON("q" << lsidQuery(record) << "u" << updateQuery(record) << "upsert" << true));
};
-
runBulkCmd("updates", init, add, send, sessions);
}
void SessionsCollection::_doRemove(const NamespaceString& ns,
const std::vector<LogicalSessionId>& sessions,
SendBatchFn send) {
- auto init = [ns](BSONObjBuilder* batch) {
+ // Used to remove items from the session collection with write
+ // concern majority
+ const WriteConcernOptions kMajorityWriteConcern{
+ WriteConcernOptions::kMajority,
+ WriteConcernOptions::SyncMode::UNSET,
+ Milliseconds(mongo::gSessionWriteConcernTimeoutSystemMillis.load())};
+
+ auto init = [ns, kMajorityWriteConcern](BSONObjBuilder* batch) {
batch->append("delete", ns.coll());
batch->append("ordered", false);
batch->append(WriteConcernOptions::kWriteConcernField, kMajorityWriteConcern.toBSON());