Hi,

I'm experimenting with a CouchDB setup on a SMB mount point. I know this
is not supported, but I ran into a (maybe simple) problem I don't
understand. Maybe someone of you can give a hint easily (that would be
amazing).

Given the following patch (I need to close/reopen the file descriptors
after renaming) for the function
https://github.com/apache/couchdb/blob/1.6.x/src/couchdb/couch_db_updater.erl#L176

>   1 --- a/src/couchdb/couch_db_updater.erl
>   2 +++ b/src/couchdb/couch_db_updater.erl
>   3 @@ -202,8 +202,18 @@ handle_call({compact_done, CompactFilepath}, _From, 
> #db{filepath=Path}=Db) ->
>   4          RootDir = couch_config:get("couchdb", "database_dir", "."),
>   5          couch_file:delete(RootDir, Filepath),
>   6          ok = file:rename(CompactFilepath, Filepath),
>   7 +
>   8 +        ok = couch_file:close(NewDb#db.updater_fd),
>   9 +        ok = couch_file:close(NewDb#db.fd),
>  10 +        {ok, SwappedFd} = couch_file:open(Filepath),
>  11 +        SwappedReaderFd = open_reader_fd(Filepath, Db#db.options),
>  12 +        SwappedDb = NewDb2#db{
>  13 +            fd = SwappedReaderFd,
>  14 +            updater_fd = SwappedFd
>  15 +        },
>  16 +        unlink(SwappedFd),
>  17          close_db(Db),
>  18 -        NewDb3 = refresh_validate_doc_funs(NewDb2),
>  19 +        NewDb3 = refresh_validate_doc_funs(SwappedDb),
>  20          ok = gen_server:call(Db#db.main_pid, {db_updated, NewDb3}, 
> infinity),
>  21          couch_db_update_notifier:notify({compacted, NewDb3#db.name}),
>  22          ?LOG_INFO("Compaction for db \"~s\" completed.", [Db#db.name]),

then the gen_server:call() of line 20 never returns.

Is there a major issue with this approach or just a minor mistake in my
implementation?


Thank you for having a look,
Stefan

Reply via email to