pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6602: concurrent psql session clobbers history
4+ messages / 3 participants
[nested] [flat]
* BUG #6602: concurrent psql session clobbers history
@ 2012-04-19 10:02 i+pgbugs@avdd.tk
0 siblings, 1 reply; 4+ messages in thread
From: i+pgbugs@avdd.tk @ 2012-04-19 10:02 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 6602
Logged by: Adrian Dries
Email address: i+pgbugs@avdd.tk
PostgreSQL version: 9.1.3
Operating system: Ubuntu ppa:pitti/postgresql
Description:
A concurrent psql session will overwrite the history of the first. This
does not look good: a database tool causing me to lose my data!
# session 1
$ psql -q
postgres=# \echo first session exits first
first session exits first
postgres=# \q
$ cat .psql_history
\echo first session exits first
\q
$ psql -q
postgres=#
$ cat .psql_history
\echo second session exits second
\q
$ psql -q
postgres=# \echo first session exits second
first session exits second
postgres=# \q
$ cat .psql_history
\echo second session exits second
\q
\echo first session exits second
\q
# session 2
$ psql -q
postgres=# \echo second session exits second
second session exits second
postgres=# \q
$ cat .psql_history
\echo second session exits second
\q
$ psql -q
postgres=# \echo second session exits first
second session exits first
postgres=# \q
$ cat .psql_history
\echo second session exits second
\q
\echo second session exits first
\q
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #6602: concurrent psql session clobbers history
@ 2012-04-19 19:00 Tom Lane <tgl@sss.pgh.pa.us>
parent: i+pgbugs@avdd.tk
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2012-04-19 19:00 UTC (permalink / raw)
To: i+pgbugs@avdd.tk; +Cc: pgsql-bugs
i+pgbugs@avdd.tk writes:
> A concurrent psql session will overwrite the history of the first. This
> does not look good: a database tool causing me to lose my data!
Works okay for me. I suspect you need to take this up with whoever
packages libreadline for Ubuntu, because it's going to be libreadline's
problem not ours.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #6602: concurrent psql session clobbers history
@ 2012-04-19 20:15 Peter Eisentraut <peter_e@gmx.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Eisentraut @ 2012-04-19 20:15 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: i+pgbugs@avdd.tk; pgsql-bugs
On tor, 2012-04-19 at 15:00 -0400, Tom Lane wrote:
> i+pgbugs@avdd.tk writes:
> > A concurrent psql session will overwrite the history of the first. This
> > does not look good: a database tool causing me to lose my data!
>
> Works okay for me. I suspect you need to take this up with whoever
> packages libreadline for Ubuntu, because it's going to be libreadline's
> problem not ours.
It's probably actually using libedit for the history part.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #6602: concurrent psql session clobbers history
@ 2012-04-25 17:54 Tom Lane <tgl@sss.pgh.pa.us>
parent: Peter Eisentraut <peter_e@gmx.net>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2012-04-25 17:54 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: i+pgbugs@avdd.tk; pgsql-bugs
Peter Eisentraut <peter_e@gmx.net> writes:
> On tor, 2012-04-19 at 15:00 -0400, Tom Lane wrote:
>> i+pgbugs@avdd.tk writes:
>>> A concurrent psql session will overwrite the history of the first. This
>>> does not look good: a database tool causing me to lose my data!
>> Works okay for me. I suspect you need to take this up with whoever
>> packages libreadline for Ubuntu, because it's going to be libreadline's
>> problem not ours.
> It's probably actually using libedit for the history part.
[ after further research... ] Mmm, maybe. I can reproduce the
misbehavior on a Mac build using libedit. There is a relevant-looking
comment in psql's saveHistory function:
* On newer versions of libreadline, truncate the history file as
* needed and then append what we've added. This avoids overwriting
* history from other concurrent sessions (although there are still
* race conditions when two sessions exit at about the same time). If
* we don't have those functions, fall back to write_history().
A check of the configure output shows that Apple's libedit lacks
append_history(), so that the fallback code path is used. The phrasing
of this comment suggests that older versions of libreadline might be
lacking as well.
There's not a lot we can do about this issue when using a libreadline
or libedit that lacks the necessary support functions, I think.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2012-04-25 17:54 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-04-19 10:02 BUG #6602: concurrent psql session clobbers history i+pgbugs@avdd.tk
2012-04-19 19:00 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-04-19 20:15 ` Peter Eisentraut <peter_e@gmx.net>
2012-04-25 17:54 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox