title: Is moving documents between collections a good way to represent state changes in MongoDB?
body: <p>I have two collections, one (<strong>A</strong>) containing items to be processed (relatively small) and one (<strong>B</strong>) with those already processed (fairly large, with extra result fields).</p>
  
  <p>Items are read from <strong>A</strong>, get processed and save()'d to <strong>B</strong>, then remove()'d from <strong>A</strong>.</p>
  
  <p>The rationale is that indices can be different across these, and that the "incoming" collection can be kept very small and fast this way.</p>
  
  <p>I've run into two issues with this:</p>
  
  <ul>
  <li>if either remove() or save() time out or otherwise fail under load, I lose the item completely, or process it twice</li>
  <li>if both fail, the side effects happen but there is no record of that</li>
  </ul>
  
  <p>I can sidestep the double-failure case with findAndModify locks (not needed otherwise, we have a process-level lock) but then we have stale lock issues and partial failures can still happen. There's no way to atomically remove+save to different collections, as far as I can tell (maybe by design?)</p>
  
  <p>Is there a Best Practice for this situation? </p>