summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Heppenstall <jamie.heppenstall@mongodb.com>2019-07-29 16:30:59 -0400
committerJamie Heppenstall <jamie.heppenstall@mongodb.com>2019-07-31 15:54:46 -0400
commitfcc8b201da71e5a2fda1ba2d540a85c612dae619 (patch)
treeeb094f7a9dbd974acd9e36fcb95c7e6b0b4a3af1
parent3e2d338ebfbb17f26a1ab7dcbb447fbac29e549b (diff)
downloadmongo-fcc8b201da71e5a2fda1ba2d540a85c612dae619.tar.gz
SERVER-42397 Log refineCollectionShardKey in the audit log
-rw-r--r--src/mongo/db/audit.cpp4
-rw-r--r--src/mongo/db/audit.h5
-rw-r--r--src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp5
3 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/audit.cpp b/src/mongo/db/audit.cpp
index 81bb38b720d..e304d566339 100644
--- a/src/mongo/db/audit.cpp
+++ b/src/mongo/db/audit.cpp
@@ -172,4 +172,8 @@ void mongo::audit::logShardCollection(Client* client,
const BSONObj& keyPattern,
bool unique) {}
+void mongo::audit::logRefineCollectionShardKey(Client* client,
+ StringData ns,
+ const BSONObj& keyPattern) {}
+
#endif
diff --git a/src/mongo/db/audit.h b/src/mongo/db/audit.h
index d73a9101367..048d5d882d3 100644
--- a/src/mongo/db/audit.h
+++ b/src/mongo/db/audit.h
@@ -315,5 +315,10 @@ void logRemoveShard(Client* client, StringData shardname);
*/
void logShardCollection(Client* client, StringData ns, const BSONObj& keyPattern, bool unique);
+/**
+ * Logs the result of a refineCollectionShardKey event.
+ */
+void logRefineCollectionShardKey(Client* client, StringData ns, const BSONObj& keyPattern);
+
} // namespace audit
} // namespace mongo
diff --git a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp
index ff1334ef1ed..acddb4be4e8 100644
--- a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp
+++ b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp
@@ -31,6 +31,7 @@
#include "mongo/platform/basic.h"
+#include "mongo/db/audit.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/commands.h"
#include "mongo/db/repl/repl_client_info.h"
@@ -141,6 +142,10 @@ public:
collType.getUnique(),
false); // createIndexIfPossible
+ LOG(0) << "CMD: refineCollectionShardKey: " << request().toBSON({});
+
+ audit::logRefineCollectionShardKey(opCtx->getClient(), nss.ns(), proposedKey);
+
ShardingCatalogManager::get(opCtx)->refineCollectionShardKey(
opCtx, nss, newShardKeyPattern);
}