pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fork <mfork00@yahoo.com>
To: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PSQLException: The column name <col> was not found in this ResultSet.
Date: Wed, 10 Nov 2010 09:49:40 -0800 (PST)
Message-ID: <476129.36153.qm@web113402.mail.gq1.yahoo.com> (raw)
In-Reply-To: <alpine.BSO.2.00.1011091909160.7107@leary.csoft.net>
References: <270369.52816.qm@web113412.mail.gq1.yahoo.com>
	<alpine.BSO.2.00.1011091909160.7107@leary.csoft.net>

Looking into this further, I think the initial fix was insufficient.  I think 
there are two ways to go.  One is to synchronize the entire findColumnIndex. 
Since we are using a standard HashMap and not a synchronized one, the additional 
put could cause issues when doing a get if a resize was underway.  The 
alternative would be to use Collections.synchronizedMap at instantiation of the 
HashMap and wrap the initial load of it in the synchronized(this) block as 
proposed below.  Once loaded, the get/puts would be synchronized by the map.

Thanks.

Michael

----- Original Message ----
From: Kris Jurka <books@ejurka.com>
To: Michael Fork <mfork00@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Sent: Tue, November 9, 2010 7:10:18 PM
Subject: Re: [JDBC] PSQLException: The column name <col> was not found in this 
ResultSet.



On Mon, 8 Nov 2010, Michael Fork wrote:

> Caused by: org.postgresql.util.PSQLException: The column name mdn was not 
found
> in this ResultSet.
> 
> I receive the above error message when accessing the JDBC resultset from 
>multiple threads.  It does not occur consistently, but roughly every 20 or 30 
>runs and almost immediately upon invocation.  Looking at 
>org/postgresql/jdbc2/AbstractJdbc2ResultSet.java it appears there is a race 
>condition around building columnNameIndexMap
> 
> I cannot confirm this, but I would guess that on thread enters, has the NULL 
>map and creates the new HashMap.  The second thread enters, sees the non-NULL 
>columnNameIndexMap, and gets to the HashMap.get call prior to the first thread 
>fully populating the map.  If this is the problem, would wrapping the IF block 
>in a synchronized(this) block fix it? 
>

That looks like the correct diagnosis and fix to me.

Kris Jurka


-- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc




view thread (20+ messages)  latest in thread

Message-ID: <476129.36153.qm@web113402.mail.gq1.yahoo.com>
Permalink:  ../476129.36153.qm@web113402.mail.gq1.yahoo.com/
Also on:    postgresql.org/message-id/476129.36153.qm@web113402.mail.gq1.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mfork00@yahoo.com, books@ejurka.com
  Subject: Re: PSQLException: The column name <col> was not found in this ResultSet.
  In-Reply-To: <476129.36153.qm@web113402.mail.gq1.yahoo.com>
  References: <270369.52816.qm@web113412.mail.gq1.yahoo.com> <alpine.BSO.2.00.1011091909160.7107@leary.csoft.net> <476129.36153.qm@web113402.mail.gq1.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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