0

is there anything obvious I'm doing wrong with this code?

$result = $this->_grid->remove(
    $someQueryWithOneResult, array('safe' => true, 'justOne' => true)
);
if ($result['n'] === 0) {
    throw new FileNotFoundException("no file with xuuid '" . $xuuid . "'", 404);
} else if ($result['n'] === 1) {
    return true;
}

Sometimes the exception is thrown (meaning the result was 0). I'm quite sure the file exists and it is deleted afterwards. I run this in a batch job against a mongoDb cluster with 2 shards and 2 replicasets.

I suspect a bug inside mongoDb either PHP driver (maybe 'safe' => true doens't work), or maybe some problem with the shard.

Any ideas? Google couldn't really help :-(

Regards

Marko

Marko
  • 514
  • 1
  • 4
  • 16

1 Answers1

1

You are likely running into either https://jira.mongodb.org/browse/SERVER-4532 or a variant of it https://jira.mongodb.org/browse/SERVER-7958.

These are fixed in current development version 2.3 (which will become 2.4 production release) and the fixes have been back-ported to 2.2 and will be in 2.2.3 release later this winter.

Asya Kamsky
  • 41,784
  • 5
  • 109
  • 133