Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 6DFE82D0B0D for ; Fri, 10 Feb 2012 03:48:22 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RvlDS-0008FI-D7 for pgsql-jdbc@postgresql.org; Fri, 10 Feb 2012 07:48:22 +0000 Received: by iacb35 with SMTP id b35so3723440iac.19 for ; Thu, 09 Feb 2012 23:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=CzGdNlxGm3XjPpWpTFU/JtDB7LrCl4ST861n0m4Ad0s=; b=poDiz+JHjvIkkWDd7Uz8h+mb+S74w2Vf4AO2cZdPo4Wsw10uLCfQwBpEfzPiNFNEu7 FIuhosUEUDaQ0gCzL6qp3UwMQtqzxfzgAWOuqdBm16mgBJhmD5leQy3Lkoec+N0KhYwy 2ZN/DALDKg8CS9mL0RLXKuBc1G45O7OWm60MM= Received: by 10.50.189.137 with SMTP id gi9mr8699546igc.29.1328860064533; Thu, 09 Feb 2012 23:47:44 -0800 (PST) Received: from [10.1.10.22] (c-76-102-48-155.hsd1.ca.comcast.net. [76.102.48.155]) by mx.google.com with ESMTPS id x4sm11829535pbx.16.2012.02.09.23.47.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Feb 2012 23:47:43 -0800 (PST) Subject: Re: Patch to fix bug #6293 - regression in driver performance with regards to ResultSetMetaData-heavy workloads Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Steven Schlansker In-Reply-To: <4F34ADA6.4050008@kyon.de> Date: Thu, 9 Feb 2012 23:47:41 -0800 Cc: Dave Cramer , pgsql-jdbc@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <5CBAD10C-C4DB-4AE3-ADB4-8197E0AA4146@likeness.com> <20279E38-EDB7-4D2B-8DD1-A1CF5F3E9F1D@likeness.com> <4F34ADA6.4050008@kyon.de> To: Till Toenges X-Mailer: Apple Mail (2.1251.1) X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201202/28 X-Sequence-Number: 22681 (Switching to my non-corporate email address which hopefully is approved = to post to this list without moderator intervention) On Feb 9, 2012, at 9:39 PM, Till Toenges wrote: > On 2012-02-10 05:20, Steven Schlansker wrote: >> I'm not sure how locking applies here. There is no locking code that >> I see in any of the ResultSet classes, nor did I add any, and it's my >> understanding that ResultSet instances themselves are not to be >> shared amongst threads. So this is not relevant. >>=20 >> Let me know if I've misunderstood, Steven >=20 > I don't know about sharing the result set. But the code is thread safe = as it is. At worst, it would issue a few unneccessary extra requests to = the server. But since the write to metaData is atomic, and it never gets = set to null anywhere, eventually every thread would have a valid = instance, just not neccessarily the same. Unless it is absolutely = required that every call getMetaData() returns the same instance, that = will be good enough. I am reading over AbstractJdbc2ResultSet, and it seems that the code as = it exists today is very much *not* thread safe. For a simple example, = the instance variable this_row is modified extensively with no = coordination or synchronization whatsoever. So sharing a ResultSet = across threads is already a very bad idea, it will be about as close to = undefined behavior as Java allows. So IMO whether getMetaData() is thread safe or not is irrelevant, as = nothing else in the class is. Making the entire class thread safe would = probably not be worth the effort (sharing a ResultSet between threads = just sounds like a bad idea, and the increased synchronization overhead = would punish everyone who does it "right")