When the logOp() function fails to write an oplog entry because of restrictions in the current replication state, the error message looks like this:
logOp() but can't accept write to collection mydb.mycoll
It would be helpful, especially when debugging features that write multiple oplog entries at various points in the same component, to add some information on the oplog entries that logOp() failed to write to the local.oplog.rs collection. A proposed extension to the error message could look like the following:
logOp() but can't accept write to collection mydb.mycoll: [ (record id 1, redacted BSONObj doc 1),(record id 2, redacted BSONObj doc 2), ... ]
When the logOp() exception is logged as part of a longer error message, a sample message could like this:
Fatal assertion 51101 NotMaster: Index build: 7a6dae45-6bcf-474d-9868-27c6d0ca67a4; Database: unittests :: caused by :: logOp() but can't accept write to collection unittests.$cmd: entries: 1: [(RecordId(0), { op: "c", ns: "unittests.$cmd", ui: UUID("743fcd54-9c06-4fd2-9ab9-48c7b284ccd1"), o: { createIndexes: "InitialSyncSetIndexMultikeyOnInsert", v: 2, key: { b: 1 }, name: "b_1" }, ts: Timestamp(1, 93), t: 1, wall: new Date(1001), v: 2 })] at src/mongo/db/index_builds_coordinator.cpp 1159