Github user eiri commented on the pull request:
https://github.com/apache/couchdb-couch/pull/141#issuecomment-194026861
@iilyak Ok, here we go. I've got a bit carried away trying to make
`delete_file` to distinguish delete from compaction from context, but at the
end it got too convoluted, so I threw it away and went with just adding a new
delete option 'compaction'. This is how it works now when 'rename_on_delete'
enabled:
1. On database delete db file got renamed the same way as it was before -
with _.YMD.HMS.deleted_ suffix and kept in a shard directory.
1. The deleted database's ddocs directories got renamed with the same
suffix and stay in according shards dirs. The view files inside not renamed. PR
for this : apache/couchdb-couch-index#15
1. On database compaction pre-compacted db file got renamed to
`$shard:$dbname:YMD.HMS.$uuid.couch` and moved into `.delete` directory, but
not deleted. This is partly done to avoid mixes up on db restoration, so old
compactions will not be confused with honest deleted file.
1. Compaction's meta file treated the same and moved into `.delete` as
well, except its extension kept _.meta_
1. On views compaction view files got renamed to
`$shard:$ddoc_dir:$filename.YMD.HMS.$uuid.view` and moved into `.delete`
directory of views root.
1. As confusing as it is, there are two separate approaches to views
cleanups. One is in fabric, but not marshalled through rexi. It's just plain
brutally unlinks all tombstoned view files on local to it node. As far as I
understand it's a desperate measure to disk cleanup. I left it as it is.
1. Another one in `couch_mrview_cleanup.erl`. It seems it intended to be
used with API end-point `/db/_view_cleanup`, but I'm not sure if it's actually
on clustered interface. Anyway, I left it to act as delete, not compaction, so
it'll be renaming tombstoned view files right in place, in shards dirs, the
same way as database files renamed on delete.
I tried to keep commits in logical order, I know you prefer to review them
that way. The thing got a bit larger than your original PR, so let me know what
do you think.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---