[jira] [Updated] (COUCHDB-1445) CouchDB deletes .view files if it can't open them, even if the error is emfile.

2012-03-19 Thread Randall Leeds (Updated) (JIRA)

 [ 
https://issues.apache.org/jira/browse/COUCHDB-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Randall Leeds updated COUCHDB-1445:
---

 Priority: Blocker  (was: Major)
Affects Version/s: 1.3
   1.1.1
Fix Version/s: 1.3

Fixed on 1.1.x and 1.2.x. Blocking master for 1.3.

To https://git-wip-us.apache.org/repos/asf/couchdb.git
   29eac04..94e72e7  1.2.x - 1.2.x
   785d32f..24a61fd  1.1.x - 1.1.x

 CouchDB deletes .view files if it can't open them, even if the error is 
 emfile.
 -

 Key: COUCHDB-1445
 URL: https://issues.apache.org/jira/browse/COUCHDB-1445
 Project: CouchDB
  Issue Type: Bug
  Components: JavaScript View Server
Affects Versions: 1.1.1, 1.2, 1.3
Reporter: Jan Lehnardt
Assignee: Randall Leeds
Priority: Blocker
 Fix For: 1.2, 1.3, 1.1.2


 Via Stefan Kögl on dev@:
 Another thing I noticed during my tests of CouchDB 1.2.x. I redirected
 live traffic to the instance and after a rather short time, requests
 were failing with the following information in the logs:
 [Sun, 18 Mar 2012 16:39:24 GMT] [error] [0.27554.2]
 {error_report,0.31.0,
{0.27554.2,std_error,
 [{application,mochiweb},
  Accept failed error,
  {error,emfile}]}}
 [Sun, 18 Mar 2012 16:39:24 GMT] [error] [0.27554.2]
 {error_report,0.31.0,
  {0.27554.2,crash_report,
   [[{initial_call,
 {mochiweb_acceptor,init,
 ['Argument__1','Argument__2',
  'Argument__3']}},
 {pid,0.27554.2},
 {registered_name,[]},
 {error_info,
 {exit,
 {error,accept_failed},
 [{mochiweb_acceptor,init,3},
  {proc_lib,init_p_do_apply,3}]}},
 {ancestors,
 [couch_httpd,couch_secondary_services,
  couch_server_sup,0.32.0]},
 {messages,[]},
 {links,[0.129.0]},
 {dictionary,[]},
 {trap_exit,false},
 {status,running},
 {heap_size,233},
 {stack_size,24},
 {reductions,244}],
[]]}}
 I think emfile means that CouchDB (or mochiweb?) couldn't open any
 more files / connections. I've set the (hard and soft) nofile limit for
 user couchdb to 4096, but didn't raise the ERL_MAX_PORTS accordingly.
 Anyway, as soon as the error occured, CouchDB started writing most of my
 view files from scratch, rendering the instance unusable.
 I'd expect CouchDB to fail more gracefully when the maximum number of
 open files is reached. Is this a bug or expected behaviour?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




Re: {error,emfile} on CouchDB 1.2.x

2012-03-19 Thread Jan Lehnardt

On Mar 19, 2012, at 09:31 , Randall Leeds wrote:

 Fixed on 1.2.x and 1.1.x. Need to sleep and take a look at how I want to
 handle it on master.
 Thanks again for picking up on this one, Stefan. It's been in there since
 forever and I'd definitely seen the symptom without knowing the cause.

Thanks Randall and Paul for nailing this one over night :)

I ran it through make distcheck and the browser test suite and got all A's.

Back to Noah.

Cheers
Jan
-- 



Re: 1.2.0 status update

2012-03-19 Thread Jan Lehnardt
tl;dr: 1.2.0 is finally ready to roll.


Just to close this loop:

COUCHDB-1426 is closed and committed.

Shortly after, COUCHDB-1445 got reported and solved (woop).

Thanks everybody for pushing hard on these last few steps!

Cheers
Jan
-- 



On Mar 16, 2012, at 05:31 , Randall Leeds wrote:

 On Mar 15, 2012 8:30 PM, Jason Smith j...@iriscouch.com wrote:
 
 On Thu, Mar 15, 2012 at 10:59 PM, Robert Newson robert.new...@gmail.com
 wrote:
 Noah = awesome. Kicking arse and takin' names.
 
 Completely agree.
 
 Also, your first sentence is a valid Erlang statement. If that's not
 evidence that God is on our side, I don't know what is.
 
 --
 Iris Couch
 
 I just LOL'd. I'm parsing out. I'll be in a standards meeting in eight
 hours, but should be available, with reasonable latency, to test 1426
 throughout.



Re: {error,emfile} on CouchDB 1.2.x

2012-03-19 Thread Dave Cottlehuber
On 19 March 2012 10:28, Jan Lehnardt j...@apache.org wrote:

 On Mar 19, 2012, at 09:31 , Randall Leeds wrote:

 Fixed on 1.2.x and 1.1.x. Need to sleep and take a look at how I want to
 handle it on master.
 Thanks again for picking up on this one, Stefan. It's been in there since
 forever and I'd definitely seen the symptom without knowing the cause.

 Thanks Randall and Paul for nailing this one over night :)

 I ran it through make distcheck and the browser test suite and got all A's.

 Back to Noah.

 Cheers
 Jan
 --



Ditto, LGTME. Roll this puppy!


Re: {error,emfile} on CouchDB 1.2.x

2012-03-19 Thread Stefan Kögl
On Mon, Mar 19, 2012 at 9:31 AM, Randall Leeds randall.le...@gmail.com wrote:
 Fixed on 1.2.x and 1.1.x. Need to sleep and take a look at how I want to
 handle it on master.
 Thanks again for picking up on this one, Stefan. It's been in there since
 forever and I'd definitely seen the symptom without knowing the cause.

Thanks for taking care of this so quickly -- looking forward to a
great release :)


-- Stefan


[jira] [Commented] (COUCHDB-1443) Duplicate documents on concurrent insert

2012-03-19 Thread Bob Dionne (Commented) (JIRA)

[ 
https://issues.apache.org/jira/browse/COUCHDB-1443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13232549#comment-13232549
 ] 

Bob Dionne commented on COUCHDB-1443:
-

I'm not able to reproduce this on the MBA, though I couldn't get up to 15000 
connections. The fact that you se 412s when you use PUTs would point to the 
client, unless there's a mochiweb problem.

 Duplicate documents on concurrent insert
 

 Key: COUCHDB-1443
 URL: https://issues.apache.org/jira/browse/COUCHDB-1443
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Affects Versions: 1.1.1
Reporter: Vladimir Petrukhin

 I started 15000 parallel connections to CouchDb and writing 1 doc per 
 connection. I expected 15000 docs in CouchDb. But I get 15008 or 15014 or etc.
 I found that docs has different ids, but same content and revision.
 I use simple POST method to insert the docs. Not in batch mode.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




Re: [3/3] git commit: remove unnecessary eaccess special casing

2012-03-19 Thread Filipe David Manana
Any special reason why couch_log and couch_file don't get the same
treatment (properly formatted error message) as couch_config and
couch_config_writer?

Seems like a small (incidental) regression to me.

thanks

On Mon, Mar 19, 2012 at 3:56 AM,  rand...@apache.org wrote:
 remove unnecessary eaccess special casing

 It's better to let these errors bubble and/or not give them special
 treatment when file:format_error/1 can do a better job of describing
 the failure.


 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
 Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/48371335
 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/48371335
 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/48371335

 Branch: refs/heads/COUCHDB-1445
 Commit: 483713352cb397510111798c4b076afad83f6c46
 Parents: 29eac04
 Author: Randall Leeds rand...@apache.org
 Authored: Sun Mar 18 20:19:27 2012 -0700
 Committer: Randall Leeds rand...@apache.org
 Committed: Sun Mar 18 20:41:42 2012 -0700

 --
  src/couchdb/couch_config.erl        |   11 ---
  src/couchdb/couch_config_writer.erl |    8 +---
  src/couchdb/couch_file.erl          |    5 +
  src/couchdb/couch_log.erl           |    2 --
  src/couchdb/couch_server_sup.erl    |   14 +++---
  5 files changed, 17 insertions(+), 23 deletions(-)
 --


 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_config.erl
 --
 diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl
 index f669853..44a102d 100644
 --- a/src/couchdb/couch_config.erl
 +++ b/src/couchdb/couch_config.erl
 @@ -187,13 +187,10 @@ parse_ini_file(IniFile) -
     case file:read_file(IniFilename) of
         {ok, IniBin0} -
             IniBin0;
 -        {error, eacces} -
 -            throw({file_permission_error, IniFile});
 -        {error, enoent} -
 -            Fmt = Couldn't find server configuration file ~s.,
 -            Msg = ?l2b(io_lib:format(Fmt, [IniFilename])),
 -            ?LOG_ERROR(~s~n, [Msg]),
 -            throw({startup_error, Msg})
 +        {error, Reason} = Error -
 +            ?LOG_ERROR(Couldn't read server configuration file ~s: ~s,
 +                [IniFilename, file:format_error(Reason)]),
 +            throw(Error)
     end,

     Lines = re:split(IniBin, \r\n|\n|\r|\032, [{return, list}]),

 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_config_writer.erl
 --
 diff --git a/src/couchdb/couch_config_writer.erl 
 b/src/couchdb/couch_config_writer.erl
 index decd269..3a65c37 100644
 --- a/src/couchdb/couch_config_writer.erl
 +++ b/src/couchdb/couch_config_writer.erl
 @@ -22,6 +22,8 @@

  -export([save_to_file/2]).

 +-include(couch_db.hrl).
 +
  %% @spec save_to_file(
  %%           Config::{{Section::string(), Option::string()}, 
 Value::string()},
  %%           File::filename()) - ok
 @@ -38,9 +40,9 @@ save_to_file({{Section, Key}, Value}, File) -
     case file:write_file(File, NewFileContents) of
     ok -
         ok;
 -    {error, eacces} -
 -        {file_permission_error, File};
 -    Error -
 +    {error, Reason} = Error -
 +        ?LOG_ERROR(Couldn't write config file ~s: ~s,
 +            [File, file:format_error(Reason)]),
         Error
     end.


 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_file.erl
 --
 diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl
 index e195db0..5e476af 100644
 --- a/src/couchdb/couch_file.erl
 +++ b/src/couchdb/couch_file.erl
 @@ -58,10 +58,7 @@ open(Filepath, Options) -
             {trap_exit, true} - receive {'EXIT', Pid, _} - ok end;
             {trap_exit, false} - ok
             end,
 -            case Error of
 -            {error, eacces} - {file_permission_error, Filepath};
 -            _ - Error
 -            end
 +            Error
         end;
     Error -
         Error

 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_log.erl
 --
 diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
 index 8e24cab..7fb95a7 100644
 --- a/src/couchdb/couch_log.erl
 +++ b/src/couchdb/couch_log.erl
 @@ -89,8 +89,6 @@ init([]) -
     case file:open(Filename, [append]) of
     {ok, Fd} -
         {ok, #state{fd = Fd, level = Level, sasl = Sasl}};
 -    {error, eacces} -
 -        {stop, {file_permission_error, Filename}};
     Error -
         {stop, Error}
     end.

 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_server_sup.erl
 

Re: 1.2.0 status update

2012-03-19 Thread Bob Dionne
This is great, when we can expect the next build? I'd like to set aside some 
time to test it -- Bob

On Mar 19, 2012, at 5:34 AM, Jan Lehnardt wrote:

 tl;dr: 1.2.0 is finally ready to roll.
 
 
 Just to close this loop:
 
 COUCHDB-1426 is closed and committed.
 
 Shortly after, COUCHDB-1445 got reported and solved (woop).
 
 Thanks everybody for pushing hard on these last few steps!
 
 Cheers
 Jan
 -- 
 
 
 
 On Mar 16, 2012, at 05:31 , Randall Leeds wrote:
 
 On Mar 15, 2012 8:30 PM, Jason Smith j...@iriscouch.com wrote:
 
 On Thu, Mar 15, 2012 at 10:59 PM, Robert Newson robert.new...@gmail.com
 wrote:
 Noah = awesome. Kicking arse and takin' names.
 
 Completely agree.
 
 Also, your first sentence is a valid Erlang statement. If that's not
 evidence that God is on our side, I don't know what is.
 
 --
 Iris Couch
 
 I just LOL'd. I'm parsing out. I'll be in a standards meeting in eight
 hours, but should be available, with reasonable latency, to test 1426
 throughout.
 



Re: 1.2.0 status update

2012-03-19 Thread Jan Lehnardt

On Mar 19, 2012, at 15:00 , Bob Dionne wrote:

 This is great, when we can expect the next build? I'd like to set aside some 
 time to test it -- Bob

We never have and never will be making any commitments as to when a certain…ah, 
no :)

Noah mentioned to me he might get to it tonight his time, but I'll leave it to 
him to comment.

Cheers
Jan
--



 
 On Mar 19, 2012, at 5:34 AM, Jan Lehnardt wrote:
 
 tl;dr: 1.2.0 is finally ready to roll.
 
 
 Just to close this loop:
 
 COUCHDB-1426 is closed and committed.
 
 Shortly after, COUCHDB-1445 got reported and solved (woop).
 
 Thanks everybody for pushing hard on these last few steps!
 
 Cheers
 Jan
 -- 
 
 
 
 On Mar 16, 2012, at 05:31 , Randall Leeds wrote:
 
 On Mar 15, 2012 8:30 PM, Jason Smith j...@iriscouch.com wrote:
 
 On Thu, Mar 15, 2012 at 10:59 PM, Robert Newson robert.new...@gmail.com
 wrote:
 Noah = awesome. Kicking arse and takin' names.
 
 Completely agree.
 
 Also, your first sentence is a valid Erlang statement. If that's not
 evidence that God is on our side, I don't know what is.
 
 --
 Iris Couch
 
 I just LOL'd. I'm parsing out. I'll be in a standards meeting in eight
 hours, but should be available, with reasonable latency, to test 1426
 throughout.
 
 



Re: [3/3] git commit: remove unnecessary eaccess special casing

2012-03-19 Thread Randall Leeds
On Mon, Mar 19, 2012 at 04:48, Filipe David Manana fdman...@apache.orgwrote:

 Any special reason why couch_log and couch_file don't get the same
 treatment (properly formatted error message) as couch_config and
 couch_config_writer?


Hmm. I think maybe I should add it to couch_file because that makes a ton
of sense. At the time, I was thinking I would just let it bubble and it
would be caught above, as it certainly is in many cases.

For couch_log, how can we log anything? It felt futile to try to invoke log
calls when couch_log fails to start.



 Seems like a small (incidental) regression to me.

 thanks

 On Mon, Mar 19, 2012 at 3:56 AM,  rand...@apache.org wrote:
  remove unnecessary eaccess special casing
 
  It's better to let these errors bubble and/or not give them special
  treatment when file:format_error/1 can do a better job of describing
  the failure.
 
 
  Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
  Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/48371335
  Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/48371335
  Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/48371335
 
  Branch: refs/heads/COUCHDB-1445
  Commit: 483713352cb397510111798c4b076afad83f6c46
  Parents: 29eac04
  Author: Randall Leeds rand...@apache.org
  Authored: Sun Mar 18 20:19:27 2012 -0700
  Committer: Randall Leeds rand...@apache.org
  Committed: Sun Mar 18 20:41:42 2012 -0700
 
  --
   src/couchdb/couch_config.erl|   11 ---
   src/couchdb/couch_config_writer.erl |8 +---
   src/couchdb/couch_file.erl  |5 +
   src/couchdb/couch_log.erl   |2 --
   src/couchdb/couch_server_sup.erl|   14 +++---
   5 files changed, 17 insertions(+), 23 deletions(-)
  --
 
 
 
 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_config.erl
  --
  diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl
  index f669853..44a102d 100644
  --- a/src/couchdb/couch_config.erl
  +++ b/src/couchdb/couch_config.erl
  @@ -187,13 +187,10 @@ parse_ini_file(IniFile) -
  case file:read_file(IniFilename) of
  {ok, IniBin0} -
  IniBin0;
  -{error, eacces} -
  -throw({file_permission_error, IniFile});
  -{error, enoent} -
  -Fmt = Couldn't find server configuration file ~s.,
  -Msg = ?l2b(io_lib:format(Fmt, [IniFilename])),
  -?LOG_ERROR(~s~n, [Msg]),
  -throw({startup_error, Msg})
  +{error, Reason} = Error -
  +?LOG_ERROR(Couldn't read server configuration file ~s: ~s,
  +[IniFilename, file:format_error(Reason)]),
  +throw(Error)
  end,
 
  Lines = re:split(IniBin, \r\n|\n|\r|\032, [{return, list}]),
 
 
 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_config_writer.erl
  --
  diff --git a/src/couchdb/couch_config_writer.erl
 b/src/couchdb/couch_config_writer.erl
  index decd269..3a65c37 100644
  --- a/src/couchdb/couch_config_writer.erl
  +++ b/src/couchdb/couch_config_writer.erl
  @@ -22,6 +22,8 @@
 
   -export([save_to_file/2]).
 
  +-include(couch_db.hrl).
  +
   %% @spec save_to_file(
   %%   Config::{{Section::string(), Option::string()},
 Value::string()},
   %%   File::filename()) - ok
  @@ -38,9 +40,9 @@ save_to_file({{Section, Key}, Value}, File) -
  case file:write_file(File, NewFileContents) of
  ok -
  ok;
  -{error, eacces} -
  -{file_permission_error, File};
  -Error -
  +{error, Reason} = Error -
  +?LOG_ERROR(Couldn't write config file ~s: ~s,
  +[File, file:format_error(Reason)]),
  Error
  end.
 
 
 
 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_file.erl
  --
  diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl
  index e195db0..5e476af 100644
  --- a/src/couchdb/couch_file.erl
  +++ b/src/couchdb/couch_file.erl
  @@ -58,10 +58,7 @@ open(Filepath, Options) -
  {trap_exit, true} - receive {'EXIT', Pid, _} - ok end;
  {trap_exit, false} - ok
  end,
  -case Error of
  -{error, eacces} - {file_permission_error, Filepath};
  -_ - Error
  -end
  +Error
  end;
  Error -
  Error
 
 
 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_log.erl
  --
  diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
  index 

Re: [3/3] git commit: remove unnecessary eaccess special casing

2012-03-19 Thread Filipe David Manana
On Mon, Mar 19, 2012 at 6:33 PM, Randall Leeds randall.le...@gmail.com wrote:
 On Mon, Mar 19, 2012 at 04:48, Filipe David Manana fdman...@apache.orgwrote:

 Any special reason why couch_log and couch_file don't get the same
 treatment (properly formatted error message) as couch_config and
 couch_config_writer?


 Hmm. I think maybe I should add it to couch_file because that makes a ton
 of sense. At the time, I was thinking I would just let it bubble and it
 would be caught above, as it certainly is in many cases.

 For couch_log, how can we log anything? It felt futile to try to invoke log
 calls when couch_log fails to start.

For couch log just throw an exception/error containing the results of
file:format_error/1 and/or io:format it to stdout/stderr like it's
done in couch_server_sup.erl. Either approach will produce a much more
user friendly error.




 Seems like a small (incidental) regression to me.

 thanks

 On Mon, Mar 19, 2012 at 3:56 AM,  rand...@apache.org wrote:
  remove unnecessary eaccess special casing
 
  It's better to let these errors bubble and/or not give them special
  treatment when file:format_error/1 can do a better job of describing
  the failure.
 
 
  Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
  Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/48371335
  Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/48371335
  Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/48371335
 
  Branch: refs/heads/COUCHDB-1445
  Commit: 483713352cb397510111798c4b076afad83f6c46
  Parents: 29eac04
  Author: Randall Leeds rand...@apache.org
  Authored: Sun Mar 18 20:19:27 2012 -0700
  Committer: Randall Leeds rand...@apache.org
  Committed: Sun Mar 18 20:41:42 2012 -0700
 
  --
   src/couchdb/couch_config.erl        |   11 ---
   src/couchdb/couch_config_writer.erl |    8 +---
   src/couchdb/couch_file.erl          |    5 +
   src/couchdb/couch_log.erl           |    2 --
   src/couchdb/couch_server_sup.erl    |   14 +++---
   5 files changed, 17 insertions(+), 23 deletions(-)
  --
 
 
 
 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_config.erl
  --
  diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl
  index f669853..44a102d 100644
  --- a/src/couchdb/couch_config.erl
  +++ b/src/couchdb/couch_config.erl
  @@ -187,13 +187,10 @@ parse_ini_file(IniFile) -
      case file:read_file(IniFilename) of
          {ok, IniBin0} -
              IniBin0;
  -        {error, eacces} -
  -            throw({file_permission_error, IniFile});
  -        {error, enoent} -
  -            Fmt = Couldn't find server configuration file ~s.,
  -            Msg = ?l2b(io_lib:format(Fmt, [IniFilename])),
  -            ?LOG_ERROR(~s~n, [Msg]),
  -            throw({startup_error, Msg})
  +        {error, Reason} = Error -
  +            ?LOG_ERROR(Couldn't read server configuration file ~s: ~s,
  +                [IniFilename, file:format_error(Reason)]),
  +            throw(Error)
      end,
 
      Lines = re:split(IniBin, \r\n|\n|\r|\032, [{return, list}]),
 
 
 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_config_writer.erl
  --
  diff --git a/src/couchdb/couch_config_writer.erl
 b/src/couchdb/couch_config_writer.erl
  index decd269..3a65c37 100644
  --- a/src/couchdb/couch_config_writer.erl
  +++ b/src/couchdb/couch_config_writer.erl
  @@ -22,6 +22,8 @@
 
   -export([save_to_file/2]).
 
  +-include(couch_db.hrl).
  +
   %% @spec save_to_file(
   %%           Config::{{Section::string(), Option::string()},
 Value::string()},
   %%           File::filename()) - ok
  @@ -38,9 +40,9 @@ save_to_file({{Section, Key}, Value}, File) -
      case file:write_file(File, NewFileContents) of
      ok -
          ok;
  -    {error, eacces} -
  -        {file_permission_error, File};
  -    Error -
  +    {error, Reason} = Error -
  +        ?LOG_ERROR(Couldn't write config file ~s: ~s,
  +            [File, file:format_error(Reason)]),
          Error
      end.
 
 
 
 http://git-wip-us.apache.org/repos/asf/couchdb/blob/48371335/src/couchdb/couch_file.erl
  --
  diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl
  index e195db0..5e476af 100644
  --- a/src/couchdb/couch_file.erl
  +++ b/src/couchdb/couch_file.erl
  @@ -58,10 +58,7 @@ open(Filepath, Options) -
              {trap_exit, true} - receive {'EXIT', Pid, _} - ok end;
              {trap_exit, false} - ok
              end,
  -            case Error of
  -            {error, eacces} - {file_permission_error, Filepath};
  -            _ - Error
  -            end
  

[jira] [Created] (COUCHDB-1446) Config settings input validation

2012-03-19 Thread Jason Smith (Created) (JIRA)
Config settings input validation


 Key: COUCHDB-1446
 URL: https://issues.apache.org/jira/browse/COUCHDB-1446
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Affects Versions: 1.2
Reporter: Jason Smith
Assignee: Jason Smith
Priority: Minor


Today I received a bug report from a user who thought CouchDB might be relaxing 
and evaluate an arithmetic expression in the config. (That makes sense, since 
it seems to evaluate erlang terms elsewhere.)

https://getsatisfaction.com/iriscouch/topics/my_couchdb_is_broken_after_putting_a_badarg_for_a_configuration_value

It would be nice for CouchDB to validate config input, particularly when bad 
values permanently take it offline. (In this case, it returns 500 for all 
subsequent requests.)

IMO, a good bang-for-buck is to have three basic value types:

1. String
2. Erlang tuple
3. Integer

And each setting knows what type it must be.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Commented] (COUCHDB-1446) Config settings input validation

2012-03-19 Thread Paul Joseph Davis (Commented) (JIRA)

[ 
https://issues.apache.org/jira/browse/COUCHDB-1446?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13233207#comment-13233207
 ] 

Paul Joseph Davis commented on COUCHDB-1446:


I've seen similar reports but nothing scary enough to worry too much. Though 
your comment sparks an idea:

What if all config values are specified as Erlang terms, perhaps even so much 
as going to a full on Erlang term file format and then for each setting that's 
available we create a function that does input validation. Also, similarly we 
can store help information along with the function that does validation and 
then use that in building docs (we have a similar thing in Gunicorn that seems 
to work well enough).

Also, this would allow apps to register functions at boot to allow the system 
to be extensible. Settings that don't have a validator are stored but not used 
(or rather, if they they shouldn't cause failures, etc). Only thing I see is 
what to do if you register a handler for a value that exists but is invalid. 
Perhaps replace it?

Anyway, good idea, just not sure on the details (ie, tuples only? what about 
tuples that contain terms? Or our handful that are lists?)

 Config settings input validation
 

 Key: COUCHDB-1446
 URL: https://issues.apache.org/jira/browse/COUCHDB-1446
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Affects Versions: 1.2
Reporter: Jason Smith
Assignee: Jason Smith
Priority: Minor
  Labels: config

 Today I received a bug report from a user who thought CouchDB might be 
 relaxing and evaluate an arithmetic expression in the config. (That makes 
 sense, since it seems to evaluate erlang terms elsewhere.)
 https://getsatisfaction.com/iriscouch/topics/my_couchdb_is_broken_after_putting_a_badarg_for_a_configuration_value
 It would be nice for CouchDB to validate config input, particularly when bad 
 values permanently take it offline. (In this case, it returns 500 for all 
 subsequent requests.)
 IMO, a good bang-for-buck is to have three basic value types:
 1. String
 2. Erlang tuple
 3. Integer
 And each setting knows what type it must be.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Commented] (COUCHDB-1446) Config settings input validation

2012-03-19 Thread Paul Joseph Davis (Commented) (JIRA)

[ 
https://issues.apache.org/jira/browse/COUCHDB-1446?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13233218#comment-13233218
 ] 

Paul Joseph Davis commented on COUCHDB-1446:


Also, while I do agree this is a good idea, the setting that borked is a bug 
with how that value is used when it's found. Regardless of how strict you are 
on type information it'll always be possible to throw a wrench in the gears 
with an unexpected value in the config. But having some sort of internal 
tooling to handle the parsing and presentation of these values that is separate 
from the code where the value is used seems like it'd be quite beneficial from 
an engineering perspective.

 Config settings input validation
 

 Key: COUCHDB-1446
 URL: https://issues.apache.org/jira/browse/COUCHDB-1446
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Affects Versions: 1.2
Reporter: Jason Smith
Assignee: Jason Smith
Priority: Minor
  Labels: config

 Today I received a bug report from a user who thought CouchDB might be 
 relaxing and evaluate an arithmetic expression in the config. (That makes 
 sense, since it seems to evaluate erlang terms elsewhere.)
 https://getsatisfaction.com/iriscouch/topics/my_couchdb_is_broken_after_putting_a_badarg_for_a_configuration_value
 It would be nice for CouchDB to validate config input, particularly when bad 
 values permanently take it offline. (In this case, it returns 500 for all 
 subsequent requests.)
 IMO, a good bang-for-buck is to have three basic value types:
 1. String
 2. Erlang tuple
 3. Integer
 And each setting knows what type it must be.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira