diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2020-09-25 09:33:56 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-25 14:38:47 +0000 |
commit | b5378e3b57fec7cca6ded55f4af07119c532edc9 (patch) | |
tree | 38d461dfd4fbd2a7cc3c157281c1974adcde7b18 /src/mongo/db | |
parent | 754dc47c7905877f73a6526e449549a3baba10ed (diff) | |
download | mongo-b5378e3b57fec7cca6ded55f4af07119c532edc9.tar.gz |
SERVER-51107 Suffix index build external sort files with a random number generated at startup
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 5ae6e0be6d3..dd9c8b22863 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -847,7 +847,8 @@ std::shared_ptr<Ident> AbstractIndexAccessMethod::getSharedIdent() const { /** * Generates a new file name on each call using a static, atomic and monotonically increasing - * number. + * number. Each name is suffixed with a random number generated at startup, to prevent name + * collisions when the index build external sort files are preserved across restarts. * * Each user of the Sorter must implement this function to ensure that all temporary files that the * Sorter instances produce are uniquely identified using a unique file name extension with separate @@ -856,7 +857,9 @@ std::shared_ptr<Ident> AbstractIndexAccessMethod::getSharedIdent() const { */ std::string nextFileName() { static AtomicWord<unsigned> indexAccessMethodFileCounter; - return "extsort-index." + std::to_string(indexAccessMethodFileCounter.fetchAndAdd(1)); + static const int64_t randomSuffix = SecureRandom().nextInt64(); + return str::stream() << "extsort-index." << indexAccessMethodFileCounter.fetchAndAdd(1) << '-' + << randomSuffix; } Status AbstractIndexAccessMethod::_handleDuplicateKey(OperationContext* opCtx, |