In the world of NoSQL

I recently ran out of disk space on the partition where my couchdb databases resided, the disk had been filled by a couchdb database that severly needed to be compacted (which in my case would reduce it from 270 GB to 40 GB).

The problem was that when couchdb compacts a database, it basically writes a whole new database (so I need 40 GB of free space to be able to perform the compaction).


By default a couchdb compaction is performed in three stages:

1. Start/resume compact to dbname.couch.compact

2. Remove dbname.couch

3. Rename(not move) dbname.couch.compact to dbname.couch


I couldn’t just create a symlink called dbname.couch.compact to an empty file on another partition, since couchdb removed the file due to invalid format.  It might have worked if I had started a compaction, killed couch, moved dbname.couch.compact to another partition, and then created the symlink, and resumed the compaction, but since that’s not how I did it I don’t know if it will work.


My solution was to:

1. Copy dbname.couch to the other partition

2. Stop couch

3. Symlink dbname.couch to dbname.couch on the other partition

4. Start couch and start the compaction.  It should complete the compaction and remove the symlink.


§6 · juli 4, 2011 · CouchDB · 1 comment · Tags: ,