Skip site navigation (1) Skip section navigation (2)

Re: BUG #6602: concurrent psql session clobbers history

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: i+pgbugs(at)avdd(dot)tk, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6602: concurrent psql session clobbers history
Date: 2012-04-25 17:54:16
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On tor, 2012-04-19 at 15:00 -0400, Tom Lane wrote:
>> i+pgbugs(at)avdd(dot)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

In response to

pgsql-bugs by date

Next:From: ghircoiascamilDate: 2012-04-25 19:34:11
Subject: BUG #6613: tablespace data ignored after reinstalling windows
Previous:From: Tom LaneDate: 2012-04-25 16:23:15
Subject: Re: BUG #6612: Functions can be called inside CHECK statements

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group