ceremcem opened a new issue #611: URL: https://github.com/apache/couchdb-documentation/issues/611
## Summary BTRFS filesystem does not play with database files due to its Copy-on-Write feature. This kind of files should be created inside a folder whose CoW feature is turned off. See https://btrfs.wiki.kernel.org/index.php/Gotchas#Fragmentation > Files with a lot of random writes can become heavily fragmented (10000+ extents) causing thrashing on HDDs and excessive multi-second spikes of CPU load on systems with an SSD or large amount a RAM. On servers and workstations this affects databases and virtual machine images. Disabling CoW on a BTRFS filesystem would be a wise move. ## Possible Solution [Following script](https://gist.github.com/ceremcem/4abd9864b5c040069aca19753204dc66) fixes the issue: ```bash #!/bin/bash set -eu old="/var/lib/couchdb" new="$old.new" if lsattr $old -a | grep /\.$ | grep -- "-C-" > /dev/null; then echo "CoW is already disabled for $old. Doing nothing." exit 0 fi systemctl stop couchdb mkdir $new chattr +C $new cp -avr $old/* $new/ mv $old $old.bak mv $new $old systemctl start couchdb echo "---------------------------------------------" echo "Changes made successfully." echo "You can delete $old.bak if everything works correctly." echo "---------------------------------------------" ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
