[SERVER-64945] scan_checked_replset.js attempts to incorrectly scan on truncated collection name Created: 25/Mar/22  Updated: 25/Apr/22  Resolved: 25/Apr/22

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

Type: Bug Priority: Major - P3
Reporter: Edwin Zhou Assignee: Eric Sedor
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-65403 Update dbCheck-related scripts Closed
Related
Operating System: ALL
Participants:

 Description   

Currently, scan_checked_replset.js parses namespaces from documents by splitting the namespace on a period ".".

let [dbName, collName] = doc.namespace.split('.', 2);

This is problematic for collections that contain periods in the collection name, e.g:

admin.system.users
config.system.sessions

This leads to the script attempting to scan on partial namespaces:

{
	"msg" : "Scanning range",
	"range" : {
		"_id" : {
			"db" : "admin",
			"collection" : "system",
			"minKey" : { "$minKey" : 1 },
			"maxKey" : { "$maxKey" : 1 }
		}
	}
}
{
	"msg" : "Scanning range",
	"range" : {
		"_id" : {
			"db" : "config",
			"collection" : "system",
			"minKey" : { "$minKey" : 1 },
			"maxKey" : { "$maxKey" : 1 }
		}
	}
}

We can fix this by ensuring that the full collection name is not split against by slicing on the first occurrence of a "."

let i = doc.namespace.indexOf(".")
let [dbName, collName] = [doc.namespace.slice(0,i), doc.namespace.slice(i+1)];


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