On Sun, Jun 27, 2010 at 9:10 AM, Mark Hammond <[email protected]> wrote:
> On 27/06/2010 12:01 PM, Damien Katz wrote:
>>
>> Mark, looks like it's the file:sync calls. Can you try this patch?
>>
>> Index: src/couchdb/couch_file.erl
>> ===================================================================
>> --- src/couchdb/couch_file.erl (revision 957790)
>> +++ src/couchdb/couch_file.erl (working copy)
>> @@ -148,7 +148,7 @@
>> %%----------------------------------------------------------------------
>>
>> sync(Filepath) when is_list(Filepath) ->
>> - {ok, Fd} = file:open(Filepath, [read, raw]),
>> + {ok, Fd} = file:open(Filepath, [write, raw]),
>> try file:sync(Fd) after file:close(Fd) end;
>> sync(Fd) ->
>> gen_server:call(Fd, sync, infinity).
>
> I made that patch and it looked good for a while. The 'all_docs' test
> passes, but the 'basics' test fails with the traceback at
> http://pastebin.com/6ZZU8B6q. As you will see at the end, couch itself
> stopped, so no other requests could be made.
>
> Attempting to restart couch then failed with a similar traceback at it comes
> up - http://pastebin.com/4A1QEDq3. My reading of it is that the DB is
> somehow corrupted (it can't find a valid header). If I stop couch, delete
> all .couch files from the file-system and restart, it starts up fine again
> and re-attempting the 'basics' test does exactly the same thing again.
>
> Note that all the above was after re-enabling the auth database, but I don't
> think the problem is related to that specifically.
>
> Mark
>
Opening in append mode in sync/1 helps for 'basics' test. But there is
still something wrong. The server hangs in different tests when trying
to 'Run All'.
diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl
index 8c82272..6671bcc 100644
--- a/src/couchdb/couch_file.erl
+++ b/src/couchdb/couch_file.erl
@@ -148,7 +148,7 @@ truncate(Fd, Pos) ->
%%----------------------------------------------------------------------
sync(Filepath) when is_list(Filepath) ->
- {ok, Fd} = file:open(Filepath, [read, raw]),
+ {ok, Fd} = file:open(Filepath, [append, raw]),
try file:sync(Fd) after file:close(Fd) end;
sync(Fd) ->
gen_server:call(Fd, sync, infinity).
-juhani