You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Enda Farrell (JIRA)" <ji...@apache.org> on 2009/07/13 14:51:15 UTC

[jira] Created: (COUCHDB-412) CouchDB fails to start when log file is a pipe

CouchDB fails to start when log file is a pipe
----------------------------------------------

                 Key: COUCHDB-412
                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
             Project: CouchDB
          Issue Type: Bug
    Affects Versions: 0.9
         Environment: CentOS x86_64
            Reporter: Enda Farrell


I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Paul Joseph Davis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Joseph Davis updated COUCHDB-412:
--------------------------------------

    Skill Level: New Contributors Level (Easy)

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>         Attachments: COUCHDB_412_01.patch, pipe_wrapper.sh
>
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Enda Farrell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730350#action_12730350 ] 

Enda Farrell commented on COUCHDB-412:
--------------------------------------

Unfortunatly, the "log] pipe = ..." directive does not seem to work.

In my "defaults.ini" I have  "/usr/local/couchdb/var/log/couch.log" as the default log. In my per-instance ini (I run many instances on a single machine) I have overriding definitions tghat puts CouchDB logs into specific directories. When I change the per-instance ini, the override does not work, CouchDB is NOT logging into the pipe, it is logging into the default log. It's not failing on startup - it fails silently instead of thorwing an error.

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Adam Kocoloski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12740569#action_12740569 ] 

Adam Kocoloski commented on COUCHDB-412:
----------------------------------------

Found a thread from 2008 that recommends writing wrapper scripts around named pipes for use with open_port():

http://erlang.org/pipermail/erlang-questions/2008-August/037234.html

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Enda Farrell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806295#action_12806295 ] 

Enda Farrell commented on COUCHDB-412:
--------------------------------------

I favour the approach that allows the 'CustomLog "|/path/to/program" '  - but as I've not tried to write such a handoff, I don't know if it's difficult or simply a matter of a config ini setting.

I think it somewhat important that if there's no supervisor process to restart it, we at least have the ability to call (perhaps the  _status?) an API to test whether or not it is working/running.

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>         Attachments: COUCHDB_412_01.patch, pipe_wrapper.sh
>
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Enda Farrell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730348#action_12730348 ] 

Enda Farrell commented on COUCHDB-412:
--------------------------------------

Yes - the pipes were created by root using:
"mkfifo -m 777 5984.log"
and result in:
"prwxrwxrwx 1 root    root       0 Jul 13 13:57 5984.log"

A thought had occurred later - the ini file uses "[log] file = ..." and I tried "[log] pipe = ..." and CouchDB starts up and appears to run. I am starting tests now to see if this is actually the case.

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Adam Kocoloski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12740555#action_12740555 ] 

Adam Kocoloski commented on COUCHDB-412:
----------------------------------------

CouchDB executes the following code:

Filename = couch_config:get("log", "file", "couchdb.log"),
{ok, Fd} = file:open(Filename, [append]),

I tried using a pipe in a plain erl shell:

$ mkfifo -m 777 blah.log
$ ls -l blah.log
prwxrwxrwx  1 kocolosk  staff  0 Aug  7 09:45 blah.log

$ erl
Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.1  (abort with ^G)
1> file:open("blah.log", [append]).
{error,eisdir}

Sure enough, in the Erlang manual for file:open there's a list of common error codes that includes

eisdir:
             The  named  file  is not a regular file. It may be a directory, a
             fifo, or a device.

I'll do a little more digging to see how one is supposed to handle FIFOs in Erlang.

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Enda Farrell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730356#action_12730356 ] 

Enda Farrell commented on COUCHDB-412:
--------------------------------------

... as Paul Joseph Davis points out ...

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Matthew Hooker (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matthew Hooker updated COUCHDB-412:
-----------------------------------

    Attachment: pipe_wrapper.sh
                COUCHDB_412_01.patch

This is a "rough draft" of a potential fix for this issue. 

This patch makes it so all writes to the log file happen through a port to the attached wrapper script. 

If people think this is a good approach the problem, a few more things should be done:

1. only use the pipe wrapper if the target file is a named pipe, otherwise use standard file descriptors.
2. find win32 solution (if applicable)

I think a risk with this approach is if the wrapper script is aborted for some reason. There's no supervisor process to restart it, so logs will stop working.

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>         Attachments: COUCHDB_412_01.patch, pipe_wrapper.sh
>
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Matthew Hooker (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806207#action_12806207 ] 

Matthew Hooker commented on COUCHDB-412:
----------------------------------------

@Brian I think that makes a lot of sense, but is also a little beyond the scope of this bug.  Maybe we should close this out and open a new feature request?

If closing this bug out is the way to go, what do people think of this proposed solution?

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>         Attachments: COUCHDB_412_01.patch, pipe_wrapper.sh
>
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Brian Candler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12802805#action_12802805 ] 

Brian Candler commented on COUCHDB-412:
---------------------------------------

I think this should be made a general facility to log via an external program: i.e. don't hardcoded the path to pipe_wrapper.sh, or the fact that it requires a filename argument for the log destination.

This would then be comparable to the corresponding feature in Apache httpd:

CustomLog "|/path/to/program" ...

It would let you do lots of cool things: e.g. log to syslog or log via HTTP to another couchdb server, without having to launch another process which tails a pipe.


> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>         Attachments: COUCHDB_412_01.patch, pipe_wrapper.sh
>
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Paul Joseph Davis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730349#action_12730349 ] 

Paul Joseph Davis commented on COUCHDB-412:
-------------------------------------------

setting 'pipe = something' in the ini file will just result in an ignored value.

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Paul Joseph Davis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730336#action_12730336 ] 

Paul Joseph Davis commented on COUCHDB-412:
-------------------------------------------

Are we sure this isn't a permissions error?

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-412) CouchDB fails to start when log file is a pipe

Posted by "Adam Kocoloski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12740567#action_12740567 ] 

Adam Kocoloski commented on COUCHDB-412:
----------------------------------------

Hmm, weird stuff.  It looks like open_port() used to be able to work with named pipes (~2001), but I think that's no longer the case.  It's possible to redirect stdin and stdout to named pipes using run_erl

run_erl -daemon /tmp/ /tmp "/usr/local/bin/couchdb"

but I don't really care for that solution.

> CouchDB fails to start when log file is a pipe
> ----------------------------------------------
>
>                 Key: COUCHDB-412
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-412
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: CentOS x86_64
>            Reporter: Enda Farrell
>
> I have an 0.9 CouchDB. When the local.ini file's [log] file is actually a pipe (with a known to be running consumer) rather than a file, CouchDB fails to start.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.