I need to run compaction on a production CouchDB instance, that may not have had compaction run on it before.

If compaction puts too much additional load on the CouchDB instance, is it possible to safely kill the compaction process? If so, how?


During compaction, a new .couch file is written. So what you would do, when you interrupt compaction is making the file useless. The only way to stop compaction (iirc) is to stop CouchDB. Not a good idea.

Generally, compaction is a background process. The database reads are not affected by it - also for heavy read! If you have heavy write processes, compaction may never end because writing and updating a doc is faster than compaction.

You could consider scheduling compaction to a time slot, where you know that the database is not on 100% capacity. You do that in local.ini like this:

; configuration for automatic compaction.
; see: http://docs.couchdb.org/en/latest/config/compaction.html
_default = [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "02:00"}, {to, "05:00"}]

This means, run automatic compaction only during 2 and 5 in the night and only, when the fragmentation of the database is greater than or equals 70% and the view fragmentation is greater than or equals 60%

Further info can be found here: http://docs.couchdb.org/en/latest/maintenance/compaction.html

If you have questions you are very welcome to join the dev@couchdb.apache.org mailinglist or join IRC at #couchdb-dev or #couchdb at irc.freenode.net

  • you can stop compaction...
  • there is a .compact file created

  • you can remove it, then run $ lsof | grep -i deleted | grep beam

  • from there on, grab the couchdb PID and the FD(file descriptor) ie. 20u and zero out the file in :


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.