[SERVER-1670] validate() helper in the mongo shell needs work Created: 24/Aug/10  Updated: 16/Aug/18  Resolved: 16/Aug/18

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

Type: Bug Priority: Trivial - P5
Reporter: Dwight Merriman Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Done Votes: 0
Labels: neweng, platforms-re-triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

see str.match() lines below - bad with certain collection names

> db.foo.validate
 function () {
 var res = this._db.runCommand(
 
{validate:this.getName()}
 
);
 res.valid = false;
 var raw = res.result || res.raw;
 if (raw) {
 var str = "-" + tojson(raw);
 res.valid = !(str.match(/exception/) || str.match(/corrupt/));
 var p = /lastExtentSize:(\d+)/;
 var r = p.exec(str);
 if (r)
 
{ res.lastExtentSize = Number(r[1]); }
 
}
 return res;
 }>
 



 Comments   
Comment by Matt Lord (Inactive) [ 16/Aug/18 ]

I'm closing this for now as I'm unaware of any repeatable test case using MongoDB 4.0. 

The function has been improved in subsequent years: 

test@mongolord> version()
4.0.1
test@mongolord> db.foo.validate
function (full) {
    var cmd = {validate: this.getName()};
 
    if (typeof(full) == 'object')  // support arbitrary options here
        Object.extend(cmd, full);
    else
        cmd.full = full;
 
    var res = this._db.runCommand(cmd);
 
    if (typeof(res.valid) == 'undefined') {
        // old-style format just put everything in a string. Now using proper fields
 
        res.valid = false;
 
        var raw = res.result || res.raw;
 
        if (raw) {
            var str = "-" + tojson(raw);
            res.valid = !(str.match(/exception/) || str.match(/corrupt/));
 
            var p = /lastExtentSize:(\d+)/;
            var r = p.exec(str);
            if (r) {
                res.lastExtentSize = Number(r[1]);
            }
        }
    }
 
    return res;
}

 
If anyone is able to provide a test case that still fails then I'm happy to re-open it. 

Thank you!

Comment by Asya Kamsky [ 16/Aug/18 ]

Every server that did not return the field "valid" in result has been EOL for at least several years.

Recommend we close this as gone away matt.lord

 

Generated at Thu Feb 08 02:57:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.