Re: Statement Timeout and Locking

From: Kris Jurka <books(at)ejurka(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Markus Schaber <schabi(at)logix-tt(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Statement Timeout and Locking
Date: 2005-04-28 15:22:01
Message-ID: Pine.BSO.4.56.0504281015070.5783@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

On Thu, 28 Apr 2005, Kris Jurka wrote:
> On Thu, 28 Apr 2005, Tom Lane wrote:
> > Markus Schaber <schabi(at)logix-tt(dot)com> writes:
> > > conn.createStatement().execute("SET statement_timeout TO 5000; LOCK TABLE exampletable IN EXCLUSIVE MODE; SET statement_timeout TO DEFAULT;");
> >
> > At least in more recent JDBC drivers, I'd expect the above to fail
> > entirely because you can only put one SQL command per V3 Parse message.
> > Try splitting it into three statements.
>
> The JDBC driver splits this query itself and issues it in three queries
> internally.
>

This actually is the problem. It works as three separate statements, but
fails as one. The server doesn't seem to recognize the SET when other
commands come in before Sync.

Driver splitting queries:

<=BE ReadyForQuery(I)
simple execute,
handler=org(dot)postgresql(dot)jdbc2(dot)AbstractJdbc2Statement$StatementResultHandler(at)1aaa14a,
maxRows=0, fetchSize=0, flags=1
FE=> Parse(stmt=S_1,query="BEGIN",oids={})
FE=> Bind(stmt=S_1,portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Parse(stmt=null,query="SET statement_timeout TO 5000",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Parse(stmt=null,query=" LOCK TABLE locktest IN EXCLUSIVE
MODE",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Parse(stmt=null,query=" SET statement_timeout TO DEFAULT",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync

This hangs while a version split by the caller works:

<=BE ReadyForQuery(I)
simple execute,
handler=org(dot)postgresql(dot)jdbc2(dot)AbstractJdbc2Statement$StatementResultHandler(at)7a84e4,
maxRows=0, fetchSize=0, flags=1
FE=> Parse(stmt=S_1,query="BEGIN",oids={})
FE=> Bind(stmt=S_1,portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Parse(stmt=null,query="SET statement_timeout TO 5000",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync
<=BE ParseComplete [S_1]
<=BE BindComplete [null]
<=BE CommandStatus(BEGIN)
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE NoData
<=BE CommandStatus(SET)
<=BE ReadyForQuery(T)
simple execute,
handler=org(dot)postgresql(dot)jdbc2(dot)AbstractJdbc2Statement$StatementResultHandler(at)9ed927,
maxRows=0, fetchSize=0, flags=1
FE=> Parse(stmt=null,query="LOCK TABLE locktest IN EXCLUSIVE
MODE",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE NoData
<=BE ErrorMessage(ERROR: canceling query due to user request

Kris Jurka

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2005-04-28 15:38:55 Re: [HACKERS] Increased company involvement
Previous Message Mischa Sandberg 2005-04-28 15:21:36 Re: [HACKERS] Bad n_distinct estimation; hacks suggested?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2005-04-28 15:59:41 Re: Statement Timeout and Locking
Previous Message Thomas O'Dowd 2005-04-28 15:17:09 Re: Array support