Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Update not replicated to secondary

Hi,

We have configured a MongoDB primary (4.0.6) and MongoDB secondary (4.0.12) [without voting-static primary].

It looks like the replication is running without errors.

The problem is: when I make data updates (on primary) the updates do not replicate to the secondary.

Please help me to fix the problem and load delta changes to secondary.

The replication status shows:

{
    "set" : "rs0",
    "date" : ISODate("2020-05-27T22:27:30.923Z"),
    "myState" : 1,
    "term" : NumberLong(1),
    "syncingTo" : "",
    "syncSourceHost" : "",
    "syncSourceId" : -1,
    "heartbeatIntervalMillis" : NumberLong(2000),
    "optimes" : {
        "lastCommittedOpTime" : {
            "ts" : Timestamp(1590618446, 1),
            "t" : NumberLong(1)
        },
        "readConcernMajorityOpTime" : {
            "ts" : Timestamp(1590618446, 1),
            "t" : NumberLong(1)
        },
        "appliedOpTime" : {
            "ts" : Timestamp(1590618446, 1),
            "t" : NumberLong(1)
        },
        "durableOpTime" : {
            "ts" : Timestamp(1590618446, 1),
            "t" : NumberLong(1)
        }
    },
    "lastStableCheckpointTimestamp" : Timestamp(1590618426, 1),
    "members" : [ 
        {
            "_id" : 0,
            "name" : "mongomaster:27017",
            "health" : 1.0,
            "state" : 1,
            "stateStr" : "PRIMARY",
            "uptime" : 2171988,
            "optime" : {
                "ts" : Timestamp(1590618446, 1),
                "t" : NumberLong(1)
            },
            "optimeDate" : ISODate("2020-05-27T22:27:26.000Z"),
            "syncingTo" : "",
            "syncSourceHost" : "",
            "syncSourceId" : -1,
            "infoMessage" : "",
            "electionTime" : Timestamp(1588464660, 2),
            "electionDate" : ISODate("2020-05-03T00:11:00.000Z"),
            "configVersion" : 5,
            "self" : true,
            "lastHeartbeatMessage" : ""
        }, 
        {
            "_id" : 1,
            "name" : "mongoslave:27018",
            "health" : 1.0,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 501546,
            "optime" : {
                "ts" : Timestamp(1590116889, 1),
                "t" : NumberLong(1)
            },
            "optimeDurable" : {
                "ts" : Timestamp(1590116889, 1),
                "t" : NumberLong(1)
            },
            "optimeDate" : ISODate("2020-05-22T03:08:09.000Z"),
            "optimeDurableDate" : ISODate("2020-05-22T03:08:09.000Z"),
            "lastHeartbeat" : ISODate("2020-05-27T22:27:29.378Z"),
            "lastHeartbeatRecv" : ISODate("2020-05-22T03:08:11.889Z"),
            "pingMs" : NumberLong(2),
            "lastHeartbeatMessage" : "",
            "syncingTo" : "",
            "syncSourceHost" : "",
            "syncSourceId" : -1,
            "infoMessage" : "",
            "configVersion" : 5
        }
    ],
    "ok" : 1.0,
    "operationTime" : Timestamp(1590618446, 1),
    "$clusterTime" : {
        "clusterTime" : Timestamp(1590618446, 1),
        "signature" : {
            "hash" : { "$binary" : "P7jNLR6UPsFLFA3EHFCpl23MJDM=", "$type" : "00" },
            "keyId" : NumberLong(6822403774141693953)
        }
    }
}

:wave:

Hi @Anton_Turbin and welcome to the MongoDB community forums.

Have you looked at the mongo log files to see if you can see what’s going on? Your secondary does not appear to be getting the most recent operations as the optimeDate is almost 6 days behind your master. I would check the log files for both servers to see if you have any errors in them.

What is the result of running rs.printReplicationInfo() on both machines?

I did notice that this replica set only has two members and that is not a recommended setup, unless you’re doing some testing I would add a third member to the replica set.

As for syncing the data, if the secondary is not able to catch up you would have to resync that member.

1 Like

yes for now I testing only with 2 servers. They are configured via replica set Primary-(rw) and Secondary-(r - only).
The result “rs.printReplicationInfo()” from servers
Primary:
configured oplog size: 1622.255859375MB
log length start to end: 1139912secs (316.64hrs)
oplog first event time: Thu May 14 2020 22:00:34 GMT+0300 (Jerusalem Standard Time)
oplog last event time: Thu May 28 2020 02:39:06 GMT+0300 (Jerusalem Standard Time)
now: Thu May 28 2020 02:39:09 GMT+0300 (Jerusalem Standard Time)

Secondary:
configured oplog size: 11401.712695121765MB
log length start to end: 1438197secs (399.5hrs)
oplog first event time: Tue May 05 2020 14:38:12 GMT+0300 (Jerusalem Standard Time)
oplog last event time: Fri May 22 2020 06:08:09 GMT+0300 (Jerusalem Standard Time)
now: Thu May 28 2020 02:39:25 GMT+0300 (Jerusalem Standard Time)

Another question about resync, how I can resync without stopping the server (can I configure resynchronisation on fly?)

How I can prevent the crushes at the future and configure auto reload changes from Primary server if synchronization error happens

Yes I see error on slave " HostUnreachable: Error connecting to mongomaster:27017"
I really cannot connect from Secondary to Primary
mongo “mongodb://:@mongomaster:27017/users?authSource=admin”
tested the port and no problems with the port (the port is open and I can connect from other vm)

OK Thanks!!!
After checking the logs I did many tests to find problem,the problem in connection from Secondary to Master -> the crash happened by docker + iptables (the docker bridge very problematic or I cant find stable release of docker :slight_smile: )
now all automatically was synchronized and I VERY HAPPY THANKS AGAIN!!!

1 Like

@Anton_Turbin very glad to hear you got things figured out and running again. Just remember that the logs are your first line of troubleshooting generally. They might not always tell the whole story but they will point you in the right direction.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.