You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mike Leddy <mi...@loop.com.br> on 2011/09/05 19:46:14 UTC

Encountered all_dbs_active with compaction daemon on trunk

Hi,

I decided to test out the latest trunk on one of my nodes with some
2,500 databases. On activating the compaction daemon it became apparent
that some databases were being opened but not closed. 

Looking at the debug logs it became clear that when a database did not
need to be compacted it was remaining open (confirmed with lsof).

I made a small one line patch which seems to have resolved the problem:

--- a/src/couchdb/couch_compaction_daemon.erl
+++ b/src/couchdb/couch_compaction_daemon.erl
@@ -185,6 +185,7 @@ maybe_compact_db(DbName, Config) ->
                 end
             end;
         false ->
+            couch_db:close(Db),
             maybe_compact_views(DbName, DDocNames, Config)
         end;
     _ ->

This makes sure that when can_db_compact returns false that
couch_db:close is called. [I have to admit it seems strange 
to me to call couch_db:close in four different places to clean
up the the one couch_db:open_int but my erlang coding skills
are weak.]

Regards,

Mike



Re: Encountered all_dbs_active with compaction daemon on trunk

Posted by Filipe David Manana <fd...@apache.org>.
Hi Mike,

Good finding and thanks for the report and patch.
Applied to trunk:

http://svn.apache.org/viewvc?revision=1165433&view=revision


On Mon, Sep 5, 2011 at 10:46 AM, Mike Leddy <mi...@loop.com.br> wrote:
> Hi,
>
> I decided to test out the latest trunk on one of my nodes with some
> 2,500 databases. On activating the compaction daemon it became apparent
> that some databases were being opened but not closed.
>
> Looking at the debug logs it became clear that when a database did not
> need to be compacted it was remaining open (confirmed with lsof).
>
> I made a small one line patch which seems to have resolved the problem:
>
> --- a/src/couchdb/couch_compaction_daemon.erl
> +++ b/src/couchdb/couch_compaction_daemon.erl
> @@ -185,6 +185,7 @@ maybe_compact_db(DbName, Config) ->
>                 end
>             end;
>         false ->
> +            couch_db:close(Db),
>             maybe_compact_views(DbName, DDocNames, Config)
>         end;
>     _ ->
>
> This makes sure that when can_db_compact returns false that
> couch_db:close is called. [I have to admit it seems strange
> to me to call couch_db:close in four different places to clean
> up the the one couch_db:open_int but my erlang coding skills
> are weak.]
>
> Regards,
>
> Mike
>
>
>



-- 
Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."