You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/10/17 09:48:48 UTC

[GitHub] [couchdb] ceremcem opened a new issue, #4227: CouchDB should provide advice on safe use with BTRFS storage

ceremcem opened a new issue, #4227:
URL: https://github.com/apache/couchdb/issues/4227

   ## Summary
   
   BTRFS filesystem does not play well 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 for "data" folder on a BTRFS filesystem would be a wise move. 
   
   ## Possible Solution
   
   Following script fixes the issue: 
   
   ```bash
   #!/bin/bash
   set -eu
   
   curr="/var/lib/couchdb"
   new="$curr.new"
   
   if lsattr $curr -a | grep /\.$ | grep -- "-C-" > /dev/null; then
       echo "CoW is already disabled for $curr. Doing nothing."
       exit 0
   fi
   systemctl stop couchdb
   mkdir $new
   chown couchdb:couchdb $new
   chattr +C $new
   rsync -avxHAX --info=progress2 $curr/ $new/
   mv $curr $curr.bak
   mv $new $curr
   systemctl start couchdb
   
   echo "---------------------------------------------"
   echo "Changes made successfully."
   echo "You can delete $curr.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.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org