avoid ghost writes using findAndReplace() for PUT and POST requests

Description

A PUT or POST request first deletes an exiting document and then recreates it with findAndModify() with upsert option. This leads to ghost deletes and one delete db operation overhead.

findAndModify() was preferred over findAndReplace() to allow update operators and dot notation.

However:

  • allowing the update operators (with the exception of $currentDate) is useless, since the write operation is applied when the existing document has been already deleted;

  • the dot notation can be supported by RESTHeart unflattering the request body

  • the $currentDate operator can be suppoerted by RESTHeart replacing it with a BsonDateTime() object

Given that, we can use findAndReplace() command and avoid ghost deletes.

Environment

None

Status

Assignee

Andrea Di Cesare

Reporter

Andrea Di Cesare

Labels

None

Fix versions

Priority

Critical
Configure