Re: log session end - again

Lists: pgsql-hackerspgsql-patches
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: log session end - again
Date: 2004-02-02 19:48:27
Message-ID: 401EA98B.1040401@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


This patch brings up to date what I did last year (now unfortunately
bitrotted) to allow the logging of the end of a session, enabled by the
config setting "log_session_end - true". It produces lines like these:

for a local connection:
[21340] LOG: session end: duration: 0:00:23.41 user=andrew
database=template1 host=[local]

for a tcp connection:
[21351] LOG: session end: duration: 0:00:20.22 user=andrew
database=template1 host=127.0.0.1 port=33419

for a tcp connection when log_hostname = true:
[21373] LOG: session end: duration: 0:00:02.25 user=andrew
database=template1 host=alphonso port=33421

enjoy

andrew

Attachment Content-Type Size
log_session_end.patch text/plain 7.9 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: log session end - again
Date: 2004-02-02 19:54:11
Message-ID: 200402022054.11502.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan wrote:
> This patch brings up to date what I did last year (now unfortunately
> bitrotted) to allow the logging of the end of a session, enabled by
> the config setting "log_session_end - true". It produces lines like
> these:

If we log "session" end, shouldn't we also log "session" start, rather
than "connection" start? It seems there should be some symmetry here,
also for the configuration parameter names.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-02 20:02:37
Message-ID: 401EACDD.7040608@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

[redirecting to hackers]

If you like. I originally just made it happen if log_connections was
set, but Neil wanted a separate setting for it. What is the consensus
about a name?

cheers

andrew

Peter Eisentraut wrote:

>Andrew Dunstan wrote:
>
>
>>This patch brings up to date what I did last year (now unfortunately
>>bitrotted) to allow the logging of the end of a session, enabled by
>>the config setting "log_session_end - true". It produces lines like
>>these:
>>
>>
>
>If we log "session" end, shouldn't we also log "session" start, rather
>than "connection" start? It seems there should be some symmetry here,
>also for the configuration parameter names.
>
>
>


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-02 22:40:27
Message-ID: 200402022240.i12MeRJ29342@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan wrote:
> [redirecting to hackers]
>
> If you like. I originally just made it happen if log_connections was
> set, but Neil wanted a separate setting for it. What is the consensus
> about a name?

log_disconnect?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-02 23:02:49
Message-ID: 401ED719.4000403@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:

>Andrew Dunstan wrote:
>
>
>>[redirecting to hackers]
>>
>>If you like. I originally just made it happen if log_connections was
>>set, but Neil wanted a separate setting for it. What is the consensus
>>about a name?
>>
>>
>
>log_disconnect?
>
>

Not bad. Maybe for symmetry "log_disconnections" would be better.

Here's what the log lines look like:

for a local connection:
[21340] LOG: session end: duration: 0:00:23.41 user=andrew
database=template1 host=[local]

for a tcp connection:
[21351] LOG: session end: duration: 0:00:20.22 user=andrew
database=template1 host=127.0.0.1 port=33419

for a tcp connection when log_hostname = true:
[21373] LOG: session end: duration: 0:00:02.25 user=andrew
database=template1 host=alphonso port=33421

Do we want to change those too? Maybe "session end: duration:" should be
"disconnection: session time:" or some such.

cheers

andrew


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-02 23:21:52
Message-ID: 200402022321.i12NLqA05711@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


Also, Andrew, on your other patch for log_session_info line, Magnus had
the idea of giving each session an id based on the first transaction of
the session. That seems like a useful addition to that variable, though
I am not sure what value to give a session before it executes its first
query.

---------------------------------------------------------------------------

Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
>
> >Andrew Dunstan wrote:
> >
> >
> >>[redirecting to hackers]
> >>
> >>If you like. I originally just made it happen if log_connections was
> >>set, but Neil wanted a separate setting for it. What is the consensus
> >>about a name?
> >>
> >>
> >
> >log_disconnect?
> >
> >
>
> Not bad. Maybe for symmetry "log_disconnections" would be better.
>
> Here's what the log lines look like:
>
> for a local connection:
> [21340] LOG: session end: duration: 0:00:23.41 user=andrew
> database=template1 host=[local]
>
> for a tcp connection:
> [21351] LOG: session end: duration: 0:00:20.22 user=andrew
> database=template1 host=127.0.0.1 port=33419
>
> for a tcp connection when log_hostname = true:
> [21373] LOG: session end: duration: 0:00:02.25 user=andrew
> database=template1 host=alphonso port=33421
>
> Do we want to change those too? Maybe "session end: duration:" should be
> "disconnection: session time:" or some such.
>
> cheers
>
> andrew
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-02 23:48:06
Message-ID: 401EE1B6.90409@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:

>Also, Andrew, on your other patch for log_session_info line, Magnus had
>the idea of giving each session an id based on the first transaction of
>the session. That seems like a useful addition to that variable, though
>I am not sure what value to give a session before it executes its first
>query.
>
>
>

We can think about that. I am planning to tackle these separately (hence
today's patch).

I did think about using a cluster-wide sequence, if we can make such a
thing (might also be useful for system generated UIDs too).

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 03:31:40
Message-ID: 10833.1075779100@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Bruce Momjian wrote:
>> Also, Andrew, on your other patch for log_session_info line, Magnus had
>> the idea of giving each session an id based on the first transaction of
>> the session.

> I did think about using a cluster-wide sequence, if we can make such a
> thing (might also be useful for system generated UIDs too).

Not a good idea IMHO. If you do that, then there will be no such thing
as a purely read-only transaction, because *every* transaction will
include a nextval() call. That means even read-only transactions cannot
commit till the disk spins.

If we want a unique id for transient purposes like logging, then make
some kind of counter in shared memory. Don't use a sequence, it's much
too heavyweight.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 06:06:58
Message-ID: 401F3A82.50004@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:

>Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>
>>Bruce Momjian wrote:
>>
>>
>>>Also, Andrew, on your other patch for log_session_info line, Magnus had
>>>the idea of giving each session an id based on the first transaction of
>>>the session.
>>>
>>>
>
>
>
>>I did think about using a cluster-wide sequence, if we can make such a
>>thing (might also be useful for system generated UIDs too).
>>
>>
>
>Not a good idea IMHO. If you do that, then there will be no such thing
>as a purely read-only transaction, because *every* transaction will
>include a nextval() call. That means even read-only transactions cannot
>commit till the disk spins.
>
>If we want a unique id for transient purposes like logging, then make
>some kind of counter in shared memory. Don't use a sequence, it's much
>too heavyweight.
>
>
>

I'm not sure I understand. I didn't suggest that a sequence should be
used for txn ids. For the purpose I had in mind we would call nextval()
once per connection, and, for the other purpose where I suggested it
would be useful, once per "create user". That doesn't seem very heavyweight.

cheers

andrew


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: session IDs
Date: 2004-02-03 14:00:43
Message-ID: 401FA98B.7020703@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


[note change of subject]

I wrote:

>
>
> Tom Lane wrote:
>
>> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>>
>>> I did think about using a cluster-wide sequence, if we can make such
>>> a thing (might also be useful for system generated UIDs too).
>>>
>>
>>
>> Not a good idea IMHO. If you do that, then there will be no such thing
>> as a purely read-only transaction, because *every* transaction will
>> include a nextval() call. That means even read-only transactions cannot
>> commit till the disk spins.
>>
>> If we want a unique id for transient purposes like logging, then make
>> some kind of counter in shared memory. Don't use a sequence, it's much
>> too heavyweight.
>>
>
> I'm not sure I understand. I didn't suggest that a sequence should be
> used for txn ids. For the purpose I had in mind we would call
> nextval() once per connection, and, for the other purpose where I
> suggested it would be useful, once per "create user". That doesn't
> seem very heavyweight.
>

If we really want a loggable session id then ISTM it should be not
transient at all, but in fact unique even across server restart. One
moderately simple scheme that occurred to me is to have to postmaster
keep a 64 bit counter, initialised by a call to gettimeofday(), and
bumped on every connection. The postmaster would just put the new
counter value into the port structure for the backend (and in the exec
case it would be written out and then read back by the backend, along
with the other port stuff set by postmaster). No need for a persistent
sequence or for shared memory, and it would be unique unless time went
backwards by exactly the right amount between server starts (you do run
ntp on your machines, don't you?).

I am less sure of the utility of such an ID, though. After all, if you
see a disconnect log message for a given PID you must know that any
reuse of that PID indicates a new session, or even if you just see a
connection message you know it must be a new session. OTOH, having a
unique SessionID might simplify the logic required of log analysis tools.

cheers

andrew


From: Kris Jurka <books(at)ejurka(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: session IDs
Date: 2004-02-03 14:18:10
Message-ID: Pine.LNX.4.33.0402030914080.15293-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


> >
> > Tom Lane wrote:
> >
> >> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> >>
> >>> I did think about using a cluster-wide sequence, if we can make such
> >>> a thing (might also be useful for system generated UIDs too).
> >>
> >> Not a good idea IMHO. If you do that, then there will be no such thing
> >> as a purely read-only transaction, because *every* transaction will
> >> include a nextval() call. That means even read-only transactions cannot
> >> commit till the disk spins.
> >>

A sequence could be used if it was created with a sufficiently large CACHE
value, so a read only transaction would only have to hit the disk if it
happened to be the one to hit an exhausted cache.

Kris Jurka


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 14:49:16
Message-ID: 17606.1075819756@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> I'm not sure I understand. I didn't suggest that a sequence should be
> used for txn ids. For the purpose I had in mind we would call nextval()
> once per connection,

Oh, okay, I misunderstood. But why not just use the PID?

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: session IDs
Date: 2004-02-03 15:47:59
Message-ID: 200402031647.59293.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan wrote:
> I am less sure of the utility of such an ID, though. After all, if
> you see a disconnect log message for a given PID you must know that
> any reuse of that PID indicates a new session, or even if you just
> see a connection message you know it must be a new session. OTOH,
> having a unique SessionID might simplify the logic required of log
> analysis tools.

The PID *is* a unique session ID. Why is it not sufficient?


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: session IDs
Date: 2004-02-03 16:12:03
Message-ID: 401FC853.1070105@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Peter Eisentraut wrote:

>Andrew Dunstan wrote:
>
>
>>I am less sure of the utility of such an ID, though. After all, if
>>you see a disconnect log message for a given PID you must know that
>>any reuse of that PID indicates a new session, or even if you just
>>see a connection message you know it must be a new session. OTOH,
>>having a unique SessionID might simplify the logic required of log
>>analysis tools.
>>
>>
>
>The PID *is* a unique session ID. Why is it not sufficient?
>

It's unique for the duration of the session, but it won't be for logs
covering a sufficient period of time, because PIDs are reused, in some
cases not even by cycling but being allocated randomly.

As I said elsewhere, I can live with that, but others wanted something
that was more unique (if such a term has meaning ;-)

cheers

andrew ("You are unique. Just like everybody else.")


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 16:14:34
Message-ID: 200402031614.i13GEY310454@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan wrote:
> Tom Lane said:
> > Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> >> I'm not sure I understand. I didn't suggest that a sequence should be
> >> used for txn ids. For the purpose I had in mind we would call
> >> nextval() once per connection,
> >
> > Oh, okay, I misunderstood. But why not just use the PID?
> >
>
> Bruce and others have suggested that PID is not sufficiently unique.
> Personally, I can live with it :-)

The nice things about using xid for session id is that is is unique for
a long time, rather than pid.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 16:29:05
Message-ID: 1736.24.211.141.25.1075825745.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane said:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> I'm not sure I understand. I didn't suggest that a sequence should be
>> used for txn ids. For the purpose I had in mind we would call
>> nextval() once per connection,
>
> Oh, okay, I misunderstood. But why not just use the PID?
>

Bruce and others have suggested that PID is not sufficiently unique.
Personally, I can live with it :-)

cheers

andrew


From: Larry Rosenman <ler(at)lerctr(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: session IDs
Date: 2004-02-03 16:33:51
Message-ID: 142570000.1075826031@lerlaptop-red.iadfw.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

--On Tuesday, February 03, 2004 11:12:03 -0500 Andrew Dunstan
<andrew(at)dunslane(dot)net> wrote:

>
>
> Peter Eisentraut wrote:
>
>> Andrew Dunstan wrote:
>>
>>
>>> I am less sure of the utility of such an ID, though. After all, if
>>> you see a disconnect log message for a given PID you must know that
>>> any reuse of that PID indicates a new session, or even if you just
>>> see a connection message you know it must be a new session. OTOH,
>>> having a unique SessionID might simplify the logic required of log
>>> analysis tools.
>>>
>>>
>>
>> The PID *is* a unique session ID. Why is it not sufficient?
>>
>
> It's unique for the duration of the session, but it won't be for logs
> covering a sufficient period of time, because PIDs are reused, in some
> cases not even by cycling but being allocated randomly.
>
> As I said elsewhere, I can live with that, but others wanted something
> that was more unique (if such a term has meaning ;-)
How about pid+unix time of start of backend?

LER

>
> cheers
>
> andrew ("You are unique. Just like everybody else.")
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler(at)lerctr(dot)org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 16:56:06
Message-ID: 19327.1075827366@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Andrew Dunstan wrote:
>> Bruce and others have suggested that PID is not sufficiently unique.

> The nice things about using xid for session id is that is is unique for
> a long time, rather than pid.

Hmm. Now that I think about it, InitPostgres() always runs a
transaction during backend startup. If we simply saved aside the XID
assigned to that transaction, it would cost next to nothing to do and
would provide a reasonably unique ID. However, this happens much later
than the postmaster currently prints the log_connection message ...

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 18:10:46
Message-ID: 401FE426.9030101@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:

>Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>
>
>>Andrew Dunstan wrote:
>>
>>
>>>Bruce and others have suggested that PID is not sufficiently unique.
>>>
>>>
>
>
>
>>The nice things about using xid for session id is that is is unique for
>>a long time, rather than pid.
>>
>>
>
>Hmm. Now that I think about it, InitPostgres() always runs a
>transaction during backend startup. If we simply saved aside the XID
>assigned to that transaction, it would cost next to nothing to do and
>would provide a reasonably unique ID. However, this happens much later
>than the postmaster currently prints the log_connection message ...
>
>
>

Right. And if we have sessionids we would want them logged there, I
think. And that would rule out anything based on xid or backend pid.
OTOH I am quite sure I can implement the time based counter idea I
suggested earlier with a very small amount of disturbance and very low
cost. Unless someone can see a flaw in the scheme.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-03 23:09:26
Message-ID: 2611.1075849766@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Right. And if we have sessionids we would want them logged there, I
> think. And that would rule out anything based on xid or backend pid.

Uh, what's wrong with backend pid? Since we fork before we start doing
anything with a connection, it should surely be available soon enough
for the connection log message.

Larry's idea about combining PID and backend start time didn't sound too
unreasonable to me.

regards, tom lane


From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-04 00:50:51
Message-ID: 1797.24.211.141.25.1075855851.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane said:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> Right. And if we have sessionids we would want them logged there, I
>> think. And that would rule out anything based on xid or backend pid.
>
> Uh, what's wrong with backend pid? Since we fork before we start doing
> anything with a connection, it should surely be available soon enough
> for the connection log message.
>
> Larry's idea about combining PID and backend start time didn't sound
> too unreasonable to me.
>

It did to me too. I was just looking at this code 2 days ago. Somehow when
I looked again I thought we logged connections in the postmaster. Larry's
idea should work just fine. For log compactness I think I'd hexencode it -
the SessionID doesn't need any semantics, it's just like a cookie.

cheers

andrew


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: log session end - again
Date: 2004-02-04 01:03:42
Message-ID: 402044EE.7000905@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Peter Eisentraut wrote:

>Andrew Dunstan wrote:
>
>
>>This patch brings up to date what I did last year (now unfortunately
>>bitrotted) to allow the logging of the end of a session, enabled by
>>the config setting "log_session_end - true". It produces lines like
>>these:
>>
>>
>
>If we log "session" end, shouldn't we also log "session" start, rather
>than "connection" start? It seems there should be some symmetry here,
>also for the configuration parameter names.
>
>
>

OK, this version of the patch uses the config parameter name
"log_disconnections" for the sake of symmetry, and changes the message
wording slightly accordingly.

cheers

andrew

Attachment Content-Type Size
log_disconnections.patch text/plain 8.0 KB

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-05 13:48:30
Message-ID: 200402051348.i15DmUY16787@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> > Right. And if we have sessionids we would want them logged there, I
> > think. And that would rule out anything based on xid or backend pid.
>
> Uh, what's wrong with backend pid? Since we fork before we start doing
> anything with a connection, it should surely be available soon enough
> for the connection log message.
>
> Larry's idea about combining PID and backend start time didn't sound too
> unreasonable to me.

Wow, like the idea too --- pid plus time_t start time of backend.
Actully, it would be good to have star time first so you can sort
everything in order of start time.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To:
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-05 14:34:33
Message-ID: 40225479.2040305@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:

>Tom Lane wrote:
>
>
>>Larry's idea about combining PID and backend start time didn't sound too
>>unreasonable to me.
>>
>>
>
>Wow, like the idea too --- pid plus time_t start time of backend.
>Actully, it would be good to have star time first so you can sort
>everything in order of start time.
>
>

Yes. Of course, you would need either to sort additionally on log
timestamp or use an order-preserving sort.

Based on Larry's idea, I had in mind to provide a third escape in the
log_line_info string (in addition to the %U and %D that I had previously
done) of %S for sessionid, which would look something like this:
402251fc.713f

I will start redoing this feature when the log_disconnections patch is
dealt with.

cheers

andrew


From: Chester Kustarz <chester(at)arbor(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-05 20:17:15
Message-ID: Pine.BSO.4.44.0402051512590.30592-100000@detroit.arbor.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, 5 Feb 2004, Bruce Momjian wrote:
> Wow, like the idea too --- pid plus time_t start time of backend.
> Actully, it would be good to have star time first so you can sort
> everything in order of start time.

Why not just add a printf like pattern so the user can output
whatever they like?
%p - backend pid
%t - connect time
%C - standard connection string "%t:%p"
%a - autoincrement number
...

People could add more in later if they want more options.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-05 21:44:37
Message-ID: 4022B945.5030409@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Chester Kustarz wrote:

>On Thu, 5 Feb 2004, Bruce Momjian wrote:
>
>
>>Wow, like the idea too --- pid plus time_t start time of backend.
>>Actully, it would be good to have star time first so you can sort
>>everything in order of start time.
>>
>>
>
>Why not just add a printf like pattern so the user can output
>whatever they like?
> %p - backend pid
> %t - connect time
> %C - standard connection string "%t:%p"
> %a - autoincrement number
>
>

log_line_info where this would be implemented is indeed done with a
printf like string, which is easily extensible The following is adapted
from the description of the original patch which it is my intention to
bring up to date soon and resubmit:

Prefixes each message in the server log file or syslog with extra
information as specified in the string. The default is an empty
string. The following sequences in the string are translated:
'%U' is replace with the username,
'%D' is replaced by the database name,
and '%%' is replaced by '%'.
All other characters are copied literally to the log. For example,
log_line_info = '<%U%%%D> '
will produce output like this:
<myuser%mydb> LOG: query: create table foo(blah text);

cheers

andrew


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-13 04:53:22
Message-ID: 200402130453.i1D4rMN04104@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan wrote:
> Based on Larry's idea, I had in mind to provide a third escape in the
> log_line_info string (in addition to the %U and %D that I had previously
> done) of %S for sessionid, which would look something like this:
> 402251fc.713f
>
> I will start redoing this feature when the log_disconnections patch is
> dealt with.

Andrew, I can't find the log_disconnections patch. I know I saw it, but
I can't find it now. Would you resent it please?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-13 11:59:38
Message-ID: 402CBC2A.50001@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


You can find it here.

http://archives.postgresql.org/pgsql-patches/2004-02/msg00072.php

I know Neil was reviewing it and had a minor doc style quibble, as well
as the question he raised on -hackers about psql tab completion.

cheers

andrew

Bruce Momjian wrote:

>Andrew Dunstan wrote:
>
>
>>Based on Larry's idea, I had in mind to provide a third escape in the
>>log_line_info string (in addition to the %U and %D that I had previously
>>done) of %S for sessionid, which would look something like this:
>>402251fc.713f
>>
>>I will start redoing this feature when the log_disconnections patch is
>>dealt with.
>>
>>
>
>Andrew, I can't find the log_disconnections patch. I know I saw it, but
>I can't find it now. Would you resent it please?
>
>
>


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-13 14:15:54
Message-ID: 200402131415.i1DEFsC26586@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Andrew Dunstan wrote:
>
> You can find it here.
>
> http://archives.postgresql.org/pgsql-patches/2004-02/msg00072.php
>
> I know Neil was reviewing it and had a minor doc style quibble, as well
> as the question he raised on -hackers about psql tab completion.
>
> cheers
>
> andrew
>
> Bruce Momjian wrote:
>
> >Andrew Dunstan wrote:
> >
> >
> >>Based on Larry's idea, I had in mind to provide a third escape in the
> >>log_line_info string (in addition to the %U and %D that I had previously
> >>done) of %S for sessionid, which would look something like this:
> >>402251fc.713f
> >>
> >>I will start redoing this feature when the log_disconnections patch is
> >>dealt with.
> >>
> >>
> >
> >Andrew, I can't find the log_disconnections patch. I know I saw it, but
> >I can't find it now. Would you resent it please?
> >
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] log session end - again
Date: 2004-02-17 03:56:07
Message-ID: 200402170356.i1H3u7Q03428@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


Patch applied. Thanks.

I modified the doc wording a bit --- patch attached.

---------------------------------------------------------------------------

Andrew Dunstan wrote:
>
> You can find it here.
>
> http://archives.postgresql.org/pgsql-patches/2004-02/msg00072.php
>
> I know Neil was reviewing it and had a minor doc style quibble, as well
> as the question he raised on -hackers about psql tab completion.
>
> cheers
>
> andrew
>
> Bruce Momjian wrote:
>
> >Andrew Dunstan wrote:
> >
> >
> >>Based on Larry's idea, I had in mind to provide a third escape in the
> >>log_line_info string (in addition to the %U and %D that I had previously
> >>done) of %S for sessionid, which would look something like this:
> >>402251fc.713f
> >>
> >>I will start redoing this feature when the log_disconnections patch is
> >>dealt with.
> >>
> >>
> >
> >Andrew, I can't find the log_disconnections patch. I know I saw it, but
> >I can't find it now. Would you resent it please?
> >
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 11.9 KB