diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2017-06-28 16:07:27 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2017-07-05 15:27:24 -0400 |
commit | 9d803b41497eb54864361a3877097d8e1dd55dc2 (patch) | |
tree | 5190f31e6057fa391ac2b3de861159d6d70081b1 /src/mongo | |
parent | 3c9d91f8e408339ba2ecfdf1c34cb93b4ed6a926 (diff) | |
download | mongo-9d803b41497eb54864361a3877097d8e1dd55dc2.tar.gz |
SERVER-29817 Always intialize bytesWritten to 0 for chunks.
Previously, it was initialized to a pseudorandom value that was less than
some fraction of the maximum chunk size. This introduced a depencency between
the chunk constuctor and the balancer, and provided no particular value.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/s/chunk.cpp | 26 | ||||
-rw-r--r-- | src/mongo/s/chunk.h | 1 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_write.cpp | 2 |
3 files changed, 3 insertions, 26 deletions
diff --git a/src/mongo/s/chunk.cpp b/src/mongo/s/chunk.cpp index 72651dec9f6..3c183a15885 100644 --- a/src/mongo/s/chunk.cpp +++ b/src/mongo/s/chunk.cpp @@ -32,34 +32,16 @@ #include "mongo/s/chunk.h" -#include "mongo/platform/random.h" -#include "mongo/s/balancer_configuration.h" -#include "mongo/s/grid.h" -#include "mongo/util/log.h" +#include "mongo/util/mongoutils/str.h" namespace mongo { -namespace { - -// Test whether we should split once data * splitTestFactor > chunkSize (approximately) -const int splitTestFactor = 5; - -/** - * Generates a random value for _dataWritten so that a mongos restart wouldn't cause delay in - * splitting. - */ -int64_t mkDataWritten() { - PseudoRandom r(static_cast<int64_t>(time(0))); - return r.nextInt32(grid.getBalancerConfiguration()->getMaxChunkSizeBytes() / splitTestFactor); -} - -} // namespace Chunk::Chunk(const ChunkType& from) : _range(from.getMin(), from.getMax()), _shardId(from.getShard()), _lastmod(from.getVersion()), _jumbo(from.getJumbo()), - _dataWritten(mkDataWritten()) { + _dataWritten(0) { invariantOK(from.validate()); } @@ -80,10 +62,6 @@ void Chunk::clearBytesWritten() { _dataWritten = 0; } -void Chunk::randomizeBytesWritten() { - _dataWritten = mkDataWritten(); -} - std::string Chunk::toString() const { return str::stream() << ChunkType::shard() << ": " << _shardId << ", " << ChunkType::lastmod() << ": " << _lastmod.toString() << ", " << _range.toString(); diff --git a/src/mongo/s/chunk.h b/src/mongo/s/chunk.h index 484a1d9597c..af89044f41c 100644 --- a/src/mongo/s/chunk.h +++ b/src/mongo/s/chunk.h @@ -80,7 +80,6 @@ public: uint64_t getBytesWritten() const; uint64_t addBytesWritten(uint64_t bytesWrittenIncrement); void clearBytesWritten(); - void randomizeBytesWritten(); /** * Marks this chunk as jumbo. Only moves from false to true once and is used by the balancer. diff --git a/src/mongo/s/commands/cluster_write.cpp b/src/mongo/s/commands/cluster_write.cpp index 0bc72d6fd7c..ecc68ae8b0c 100644 --- a/src/mongo/s/commands/cluster_write.cpp +++ b/src/mongo/s/commands/cluster_write.cpp @@ -452,7 +452,7 @@ void updateChunkWriteStatsAndSplitIfNeeded(OperationContext* opCtx, // Ensure the collection gets reloaded because of the move Grid::get(opCtx)->catalogCache()->invalidateShardedCollection(nss); } catch (const DBException& ex) { - chunk->randomizeBytesWritten(); + chunk->clearBytesWritten(); if (ErrorCodes::isStaleShardingError(ErrorCodes::Error(ex.getCode()))) { log() << "Unable to auto-split chunk " << redact(chunkRange.toString()) << causedBy(ex) |