You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Wout Mertens <wo...@gmail.com> on 2009/03/24 23:26:55 UTC

server crash when compacting empty database

Hi,

try this on latest trunk (and several before that I think):

1. Create an empty database
2. Compact it

Result => lots of ugly backtraces from couchdb.

Is this a bug or a misfeature? Should I file a bug, if so, what info  
should I give?

Cheers,

Wout.

Re: server crash when compacting empty database

Posted by Wout Mertens <wm...@cisco.com>.
Confirmed.

However, here's a related one: net-couchdb's compacting test makes  
CouchDB crash as well.

I don't have time right now to make a minimal test case, but this is  
the code:
========================
# insert a few documents and delete one
my $bacon   = $couch->insert( { b => 'bacon' } );

# test the asynchronous API
{
     $bacon->delete;
     my $starting_size = $couch->disk_size;
     $couch->compact({ async => 1 });
     sleep 1 while $couch->is_compacting;
     my $ending_size = 1||$couch->disk_size;
     cmp_ok( $starting_size, '>', $ending_size, 'async: size  
reduction' );
}
========================

So what happens is:
1. create new db
2. insert document
3. delete document
4. compact, asynchronously
5. keep asking for status
6. Couch crashes when the compact is done and on the next status request


Is this a 0.9.0 blocker?

Wout.

On Mar 25, 2009, at 12:58 AM, Jan Lehnardt wrote:

>
> On 25 Mar 2009, at 00:08, Jan Lehnardt wrote:
>
>> Hi Wout,
>>
>> good find! I'd say it is an API misuse at this point, but of course,
>> CouchDB should handle this more gracefully.
>>
>> The patch below fixes the problem fairly high up in the db_updater
>> module. The actual fix might has to go into the start_copy_compact/1
>> function, but I'd rather leave this for Damien.
>>
>> Also, this is not a blocker for 0.9 :)
>>
>> Wout, if this is still open tomorrow, can you file a bug?
>
> fixed as of r 758093
>
> Cheers
> Jan
> --
>
>>
>> Cheers
>> Jan
>> --
>>
>> Index: /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl
>> ===================================================================
>> --- /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl	 
>> (revision 757850)
>> +++ /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl	 
>> (working copy)
>> @@ -139,6 +139,9 @@
>>    {reply, {ok, Db2#db.update_seq, IdRevsPurged}, Db2}.
>>
>>
>> +handle_cast(start_compact, #db{update_seq=Seq}=Db) when Seq =:= 0 ->
>> +    % do not attemt to compact empty dbs
>> +    {noreply, Db};
>> handle_cast(start_compact, Db) ->
>>    case Db#db.compactor_pid of
>>    nil ->
>>
>>
>> On 24 Mar 2009, at 23:26, Wout Mertens wrote:
>>
>>> Hi,
>>>
>>> try this on latest trunk (and several before that I think):
>>>
>>> 1. Create an empty database
>>> 2. Compact it
>>>
>>> Result => lots of ugly backtraces from couchdb.
>>>
>>> Is this a bug or a misfeature? Should I file a bug, if so, what  
>>> info should I give?
>>>
>>> Cheers,
>>>
>>> Wout.
>>>
>>
>>
>


Re: server crash when compacting empty database

Posted by Jan Lehnardt <ja...@apache.org>.
On 25 Mar 2009, at 00:08, Jan Lehnardt wrote:

> Hi Wout,
>
> good find! I'd say it is an API misuse at this point, but of course,
> CouchDB should handle this more gracefully.
>
> The patch below fixes the problem fairly high up in the db_updater
> module. The actual fix might has to go into the start_copy_compact/1
> function, but I'd rather leave this for Damien.
>
> Also, this is not a blocker for 0.9 :)
>
> Wout, if this is still open tomorrow, can you file a bug?

fixed as of r 758093

Cheers
Jan
--

>
> Cheers
> Jan
> --
>
> Index: /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl
> ===================================================================
> --- /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl	 
> (revision 757850)
> +++ /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl	 
> (working copy)
> @@ -139,6 +139,9 @@
>     {reply, {ok, Db2#db.update_seq, IdRevsPurged}, Db2}.
>
>
> +handle_cast(start_compact, #db{update_seq=Seq}=Db) when Seq =:= 0 ->
> +    % do not attemt to compact empty dbs
> +    {noreply, Db};
> handle_cast(start_compact, Db) ->
>     case Db#db.compactor_pid of
>     nil ->
>
>
> On 24 Mar 2009, at 23:26, Wout Mertens wrote:
>
>> Hi,
>>
>> try this on latest trunk (and several before that I think):
>>
>> 1. Create an empty database
>> 2. Compact it
>>
>> Result => lots of ugly backtraces from couchdb.
>>
>> Is this a bug or a misfeature? Should I file a bug, if so, what  
>> info should I give?
>>
>> Cheers,
>>
>> Wout.
>>
>
>


Re: server crash when compacting empty database

Posted by Jan Lehnardt <ja...@apache.org>.
Hi Wout,

good find! I'd say it is an API misuse at this point, but of course,
CouchDB should handle this more gracefully.

The patch below fixes the problem fairly high up in the db_updater
module. The actual fix might has to go into the start_copy_compact/1
function, but I'd rather leave this for Damien.

Also, this is not a blocker for 0.9 :)

Wout, if this is still open tomorrow, can you file a bug?

Cheers
Jan
--

Index: /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl
===================================================================
--- /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl	 
(revision 757850)
+++ /Users/jan/Work/couchdb/trunk/src/couchdb/couch_db_updater.erl	 
(working copy)
@@ -139,6 +139,9 @@
      {reply, {ok, Db2#db.update_seq, IdRevsPurged}, Db2}.


+handle_cast(start_compact, #db{update_seq=Seq}=Db) when Seq =:= 0 ->
+    % do not attemt to compact empty dbs
+    {noreply, Db};
  handle_cast(start_compact, Db) ->
      case Db#db.compactor_pid of
      nil ->


On 24 Mar 2009, at 23:26, Wout Mertens wrote:

> Hi,
>
> try this on latest trunk (and several before that I think):
>
> 1. Create an empty database
> 2. Compact it
>
> Result => lots of ugly backtraces from couchdb.
>
> Is this a bug or a misfeature? Should I file a bug, if so, what info  
> should I give?
>
> Cheers,
>
> Wout.
>