Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0C0251337B4A for ; Thu, 11 Nov 2010 22:24:46 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 87133-08 for ; Fri, 12 Nov 2010 02:24:39 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id 9FAE5133798E for ; Thu, 11 Nov 2010 22:24:38 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id oAC2Objq037432 for ; Thu, 11 Nov 2010 22:24:38 -0400 (AST) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id oAC292g1031211 for pgsql-jdbc@postgresql.org; Thu, 11 Nov 2010 22:09:02 -0400 (AST) (envelope-from news) From: Lew X-Newsgroups: pgsql.interfaces.jdbc Subject: Re: PSQLException: The column name was not found in this ResultSet. Date: Thu, 11 Nov 2010 21:09:12 -0500 Organization: albasani.net Lines: 45 Message-ID: References: <270369.52816.qm@web113412.mail.gq1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit In-Reply-To: Cancel-Lock: sha1:4cX4XAhpAPmwgn2f/qkBNyQQjf4= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.14) Gecko/20101006 Thunderbird/3.0.9 Injection-Info: news.albasani.net; logging-data="/VeCIjXWj1crRxAprwtpgvbOvpfrwWn+NmBofmhl22hghteHqdNElbEY6WEtAkbm2UtN67rY7gymxZLLyHiljJejlYGipGkxLgnBAjjUtHrmyOe+Ih7oj2VhMb5bt3ml"; mail-complaints-to="abuse@albasani.net" To: pgsql-jdbc@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/25 X-Sequence-Number: 21146 On 11/10/2010 12:27 AM, Samuel Gendler wrote: > On Tue, Nov 9, 2010 at 4:10 PM, Kris Jurka > wrote: > > > > 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? IT is possible without proper synchronization for thread A to instantiate and fully population a shared Map reference, and for thread B subsequently to see a 'null', empty or partially populated view from that reference. > That looks like the correct diagnosis and fix to me. > > > That would only be a valid fix if ResultSet is intended to be inherently > threadsafe. I wouldn't think that is the case. There is no mention of > thread safety at all in the javadocs, which I would always take to imply > that there is no implicit thread safety. Code which utilizes a > ResultSet should do so in a thread safe manner, rather than attempting > to make the resultset implementation thread-safe - unless my assumptions > about the intent of the interface designers is incorrect. It is meaningless to talk about thread safety with respect to interfaces. -- Lew