mongoid/moped — pull request #256 by jonhyman (2014-02-11 13:49:16+00:00)
Title: Retries when there is an auth failure on insert.

We've been seeing something really weird in our staging database. We have a line of that that is like

```ruby
m = Model.new(...)
success = m.save()
if success
do_work()
end
```

with safe writes turned on. We see in the Moped logs that the INSERT is happening and Mongoid thinks that everything happened successfully. However, we did some packet sniffing on the machine and saw this:

> IPX:15077 <<-- IPY:54709 129 bytes id:a1886 661638 - 105
reply n:1 cursorId: 0
{ err: "not authorized for insert on staging.collection_name", code: 16540, n: 0, ok: 1.0 }

It seems like the INSERT is silently failing - it is extremely hard to reproduce, perhaps we can reproduce it once an hour (we reproduced it a dozen times yesterday). I think this might help.

Please let me know your thoughts.