|
In FCV 4.4, each node is responsible for deleting the excess documents in capped collections. This implies that capped deletes may not be synchronized between nodes at times. When upgraded to FCV 5.0, the primary will generate delete oplog entries for capped collections. However, if the secondary was behind in deleting excess documents while in FCV 4.4, the primary would have no way of knowing and it would delete the first document it sees in its capped collection. This would leave the capped collection in an inconsistent state across the nodes, until the secondary steps up and starts deleting documents it never had a chance to. The capped collection would be consistent across the replica set nodes once every secondary stepped up, for replica sets where this is possible.
Below is an example of this with a capped collection capacity of 4 documents:
| Node 1 |
Node 2 |
| Starts with docs 2-5 |
Starts with docs 1-5 |
| isPrimary |
... |
| Insert 6 |
... |
| Delete 2 |
... |
| ... |
Insert 6 |
| ... |
Delete 2 |
| ... |
Left with 1 + 3-6 |
| Stepdown |
... |
| ... |
New primary |
| ... |
Insert 7 |
| ... |
Delete 1 + 3 (had an excess of one document always) |
| Insert 7 |
... |
| Delete 1 (no-op) |
... |
| Delete 3 |
... |
|