Search code examples
mongodbdatereplicasetmongodb-oplog

MongoDb Primary Oplog one hour behing realtime


Since in my country the time was changeg to one hour "ahead". My replica set is doing something I can't understand. This is a 4.2 version and P-S-S replica set.

The Primary oplog is registering actions with the wrong time, it would register 8:00 for an action done at 9:00.

The OS time is properly set ande when I checked the time in mongo shell i got the following:

set1:PRIMARY> Date()
Mon Nov 08 2021 09:29:57 GMT+0100 (CET)
set1:PRIMARY> ISODate()
ISODate("2021-11-08T08:30:11.674Z")

Where is Mongo taking the ISODate value? Is it possible to change it?


Solution

  • Your database is always using UTC timestamps, because UTC don't follow light saving time, a.k.a. summertime.

    That will prevent problems when world around changes from wintertime to summertime, and back (in different dates, in different countries).