Document resurrected directly in the bucket (i.e. not via SG) don't preserve revision metadata, due to known server limitations (it's prohibitively expensive to query for tombstones for each insert).
This scenario is currently be treated as a conflict by Inter-Sync Gateway replication, in two scenarios:
- Documents resurrected on the active peer are rejected by the remote, and don't get replicated. (There's nothing to be pulled, so there's no trigger for conflict resolution)
- Documents resurrected on the passive peer incorrectly trigger conflict resolution when pulled, and the default 'delete wins' policy results in the document being re-tombstoned after replication.
A possible solution for this is to allow disconnected branches to be written (and not be flagged as a conflict) when there are no other active leaves on the rev tree. The 'disconnected branch' requirement is necessary to ensure actual conflicts between a delete and an update are properly flagged as conflicts.
Tests should be included both for the document resurrect case, but also the conflict case (if not already present) to ensure this enhancement doesn't break other delete-related functionality.