[SERVER-68458] Incorrect maxDocID calculation in _getLastDocID() for sharded_backup_restore.js Created: 01/Aug/22  Updated: 29/Oct/23  Resolved: 15/Aug/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Gregory Wlodarek Assignee: Gregory Wlodarek
Resolution: Fixed Votes: 0
Labels: test-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2022-08-22
Participants:
Linked BF Score: 14

 Description   

The _getLastDocID() function checks the last oplog entry of each shard to figure out the maxDocID. It's not guaranteed that the last oplog entry will be an insert of a document containing the docId field:

[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] ----
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] Last docID: 167, lastEntries: [
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	{
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"op" : "u",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ns" : "config.cache.databases",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ui" : UUID("b3fb3e73-cc56-43fa-bbce-62362eaef69e"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"$v" : 2,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"diff" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 				"u" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 					"version" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 						"uuid" : UUID("bf948bf4-90c6-46b3-9074-4b63668704ee"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 						"timestamp" : Timestamp(0, 0),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 						"lastMod" : 0
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 					}
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 				}
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			}
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o2" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"_id" : "config"
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ts" : Timestamp(1654660031, 7),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"t" : NumberLong(1),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"v" : NumberLong(2),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"wall" : ISODate("2022-06-08T03:47:11.858Z")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	{
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"op" : "i",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ns" : "test.continuous_writes_unrestored",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ui" : UUID("ca3f3e6f-d4ab-40ec-9d2d-b8ef968d94be"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"_id" : ObjectId("62a01bbe4418e4e1315b8741"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"shardId" : 1,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"numForPartition" : -50,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"docId" : 165
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o2" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"numForPartition" : -50,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"_id" : ObjectId("62a01bbe4418e4e1315b8741")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ts" : Timestamp(1654660030, 16),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"t" : NumberLong(1),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"v" : NumberLong(2),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"wall" : ISODate("2022-06-08T03:47:11.012Z")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	{
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"op" : "i",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ns" : "test.continuous_writes_unrestored",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ui" : UUID("ca3f3e6f-d4ab-40ec-9d2d-b8ef968d94be"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"_id" : ObjectId("62a01bbf4418e4e1315b8745"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"shardId" : 2,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"numForPartition" : 50,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"docId" : 166
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o2" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"numForPartition" : 50,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"_id" : ObjectId("62a01bbf4418e4e1315b8745")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ts" : Timestamp(1654660031, 2),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"t" : NumberLong(1),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"v" : NumberLong(2),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"wall" : ISODate("2022-06-08T03:47:11.343Z")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	{
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"op" : "i",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ns" : "test.continuous_writes_unrestored",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ui" : UUID("ca3f3e6f-d4ab-40ec-9d2d-b8ef968d94be"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"_id" : ObjectId("62a01bbf4418e4e1315b8749"),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"shardId" : 3,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"numForPartition" : 150,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"docId" : 167
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o2" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"numForPartition" : 150,
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"_id" : ObjectId("62a01bbf4418e4e1315b8749")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ts" : Timestamp(1654660031, 4),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"t" : NumberLong(1),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"v" : NumberLong(2),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"wall" : ISODate("2022-06-08T03:47:11.567Z")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	{
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"op" : "n",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ns" : "",
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"o" : {
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 			"msg" : "periodic noop"
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		},
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"ts" : Timestamp(1654660031, 1),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"t" : NumberLong(1),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"v" : NumberLong(2),
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 		"wall" : ISODate("2022-06-08T03:47:11.270Z")
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] 	}
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] ]
[js_test:sharded_pit_selective_backup_restore_simple] [jsTest] ----

As seen in the code snippet above, the first element of lastEntries is not an insert of a document with the docId field. We should filter for oplog entries containing docId and look at the last one then to properly compute the maxDocID.



 Comments   
Comment by Githook User [ 15/Aug/22 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-68458 Fix maxDocID calculation in _getLastDocID() for sharded_backup_restore.js
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/9f73cac527ae02cb0177a8d81981713f98c60d84

Generated at Thu Feb 08 06:10:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.