Mongodb replicaset cluster maximum logicalTime => 2038 year max

I have noticed a mongodb bug. If I set my system time to 2070 and I set the mongodb cluster replicaSet configuration, mongod crash:

python3 -c "
> import pymongo
> client = pymongo.MongoClient('mongodb://')
> config = {'_id': 'rs0', 'members': [{'_id': 0, 'host': ''}]}
> client.admin.command('replSetInitiate', config)
> "
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "/usr/lib/python3/dist-packages/pymongo/", line 740, in command
    codec_options, session=session, **kwargs)
  File "/usr/lib/python3/dist-packages/pymongo/", line 637, in _command
  File "/usr/lib/python3/dist-packages/pymongo/", line 694, in command
  File "/usr/lib/python3/dist-packages/pymongo/", line 162, in command
  File "/usr/lib/python3/dist-packages/pymongo/", line 168, in _check_command_response
pymongo.errors.OperationFailure: cluster time cannot be advanced beyond its maximum value, full error: {'operationTime': Timestamp(0, 0), 'ok': 0.0, 'errmsg': 'cluster time cannot be advanced beyond its maximum value', 'code': 40482, 'codeName': 'Location40482', '$clusterTime': {'clusterTime': Timestamp(0, 0), 'signature': {'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'keyId': 0}}}

From mongo source it seems the max clock value is defined as below

static const uint32_t kMaxSignedInt = ((1U << 31) - 1);
bool lessThanOrEqualToMaxPossibleTime(LogicalTime time, uint64_t nTicks) {
   return time.asTimestamp().getSecs() <= LogicalClock::kMaxSignedInt &&
        time.asTimestamp().getInc() <= (LogicalClock::kMaxSignedInt - nTicks);

Which means: 2 ** 31 / (3600 * 24 * 365) == 68 years from 1970 / 1970 + 68 == 2038

  • if I set the year as 2042 → restart → crash
  • if I set the year as 2035 → restart the configuration → it’s correctly working

It seems linked to this bug, which was raised in 2018. Do you know if there has been any update on this topic ?

Yours sincerely,


Hi @Alexis_Doussot,

Welcome to the MongoDB Community Forums… :clap:

This is a known problem for all systems using 32-bit integers for measuring time and as you can see in the JIRA, we’re aware of the issue and the ticket has been assigned to a team’s queue. You can also keep track of further comments right there on the ticket.