[ 
https://issues.apache.org/jira/browse/COUCHDB-1592?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13939638#comment-13939638
 ] 

Nils Breunese commented on COUCHDB-1592:
----------------------------------------

Thanks for the quick patch, Robert!

I haven't had a change to try it out (I'll have to dig in to how to build 
CouchDB first), but looking at the patch it seems {{abs_path}} will resolve 
only one level of symlink. It might be a good idea to keep following symlinks 
until a regular file is found. I actually know that one of our hosters likes to 
use more than one 'layer' of symlinks ({{link1}} points to {{link2}}, which in 
turn points to {{real_location}}), so the proposed patch would probably not 
work in that case.

Again, I don't really know Erlang myself, but I found that ec_file in Erlware 
Commons provides a real_dir_path function, but it's apparently based on a 'cwd 
hack' (https://twitter.com/ericbmerritt/status/306097346196946945) and 
temporarily changes the current working directory: 
https://github.com/erlware/erlware_commons/blob/master/src/ec_file.erl That 
doesn't sound like the cleanest solution.

If Erlang lacks a proper equivalent of realpath(3), then I guess just 
recursively calling {{abs_path}} until no symlink is found would be best?

It's just a one character change to your patch, but does something like this 
make sense?

{code}
 abs_path(Path0) ->
+    {ok, Info} = file:read_file_info(Path0),
+    case Info#file_info.type of
+        symlink ->
+            {ok, Path} = file:read_link(Path0),
+            abs_path(Path);
+        _ ->
+            abs_path2(Path0)
+    end.
+
+abs_path2(Path0) ->
     Path = filename:absname(Path0),
     case lists:last(Path) of
     $/ ->
{code}

> Free space check for automatic compaction doesn't follow symlinks
> -----------------------------------------------------------------
>
>                 Key: COUCHDB-1592
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1592
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Database Core
>    Affects Versions: 1.2
>            Reporter: Nils Breunese
>
> We've got a problem with automatic compaction not running due to low 
> diskspace according to CouchDB. According to our system administrators there 
> is more than enough space (more than twice the currently used space), but the 
> data directory is a symlink to the real data storage. It seems CouchDB is 
> checking the diskspace on the filesystem on which the symlink resides instead 
> of the diskspace on the linked filesystem.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to