|
Surely this can be checked in a purely programmatic fashion? This level of manual interpretation seems pretty error-prone...
There is also a subtle point which is that the moveChunk.to can actually enter the changelog after the moveChunk.commit and moveChunk.from (eg. if the to-side mongod is under heavy load, and gets delayed while sending the moveChunk.to entry). This doesn't change the overall goal of "find the last moveChunk.start, and check that it has a corresponding moveChunk.from and/or moveChunk.commit", but it does mean that a little extra care might be needed.
I think something like this would work:
var laststart = db.changelog.find({what:"moveChunk.start"}).sort({time:-1}).next()
|
db.changelog.find({what:/^moveChunk\.(from|commit)/, time: { $gte: laststart.time }, ns: laststart.ns, server: laststart.server, "details.min": laststart.details.min, "details.max": laststart.details.max, "details.from": laststart.details.from , "details.to": laststart.details.to}).sort({time:-1}).limit(1).pretty()
|
If there is any output, then the most recent chunk migration has completed. If there is no output, then the most recently started migration may still be in progress (but might not, eg. if the from mongod aborted mid-way through the migration).
|