How are documents deleted by sync gateway?


#1

I am trying to debug an issue with my app trying to retrieve deleted documents. I want to know what the original doc it was trying to retrieve was, but all I can find is the current version which just has sync gateway metadata. On our dev server when I delete a doc I am still able to retrieve previous versions by using the admin url. E.g if I delete doc with id=xxx and it has rev 1-a and rev 1-b, where 1-b is just the metadata with the _deleted flag, I can retrieve 1-a by using:
localhost:4985//xxx?rev=1-a

When I try this on our production server with the actual docs I get:
{“error”:“not found”,“reason”:“deleted”}

Does sync gateway clean up old docs and remove them if they were deleted? Is there any way I can retrieve the document data of deleted documents, or was it removed from couchbase forever?


#2

It sounds like there might be a difference in your dev and production configs. You can set the revs_limit in the database config. Do they appear to be different?

To answer the question above, once a compaction happens, the documents are deleted forever (other than doing some forensic work on the filesystem, perhaps).


#3

Thanks for letting me know. Makes sense that they would be removed during compaction.