Details
-
Improvement
-
Resolution: Unresolved
-
Major
-
Cheshire-Cat
-
None
-
1
Description
As part of implementing support for operating on deleted documents for SubdocReplaceBodyWithXattr we face some challenges:
1) Deleted documents can't have value.
All subdoc operations preserves the state of the document which they started operating on; and complete their operation by doing a CAS replace. It means that SubdocReplaceBodyWithXattr can't really work on deleted documents as they're not allowed to have a value. The use case for SubdocReplaceBodyWithXattr is however as part of committing a transaction, so the result should be a live document so we've introduced a new flag for the command: ReviveDocument which would store the final result as a live document; and this is where we face challenge 2..
2) There is no way to do CAS replace on a deleted document to make it a live document.
One may do a CAS replace of one deleted document to another deleted document, and one may do a CAS replace from one live document to another live document. BUT if one tries to do a CAS replace from a deleted document to a live document it fails.
Given that the CAS value change when you delete a document (the deleted document have a different CAS value than the document had when it was alive) I think it should be safe to allow CAS replace to work in this case.
The "workaround" used right now is to use an "ADD" in the case where we want to transition from a deleted document to a live document (in the combination with revive being requested we error out if the document we fetched from the database isn't a deleted document). This is currently the same way which the clients is doing this (they do an ADD from the client side). Unfortunately we still got the problem that someone could have created and deleted the document between the document was fetched and the add back occurs and this race is what I want to get rid of with a CAS replace.
Attachments
Issue Links
- relates to
-
MB-41550 Support for a Sub-Document copy mutation spec
- Closed