Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjpk3-00077x-R1 for pgsql-jdbc@arkaria.postgresql.org; Mon, 12 May 2014 12:54:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wjpk3-0001Tp-AX for pgsql-jdbc@arkaria.postgresql.org; Mon, 12 May 2014 12:54:03 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjmn4-0005jL-HX for pgsql-jdbc@postgresql.org; Mon, 12 May 2014 09:44:58 +0000 Received: from mail-db3lp0076.outbound.protection.outlook.com ([213.199.154.76] helo=emea01-db3-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjmmy-0007PR-KN for pgsql-jdbc@postgresql.org; Mon, 12 May 2014 09:44:57 +0000 Received: from DB4PR06MB173.eurprd06.prod.outlook.com (10.242.155.139) by DB4PR06MB174.eurprd06.prod.outlook.com (10.242.155.148) with Microsoft SMTP Server (TLS) id 15.0.939.12; Mon, 12 May 2014 09:44:49 +0000 Received: from DB4PR06MB173.eurprd06.prod.outlook.com ([169.254.10.219]) by DB4PR06MB173.eurprd06.prod.outlook.com ([169.254.10.219]) with mapi id 15.00.0939.000; Mon, 12 May 2014 09:44:49 +0000 From: Ludovic POLLET To: Kevin Grittner , "pgsql-jdbc@postgresql.org" Subject: Re: TR: [BUGS] BUG #8842: lo_open/fastpath transaction inconsistency Thread-Topic: [JDBC] TR: [BUGS] BUG #8842: lo_open/fastpath transaction inconsistency Thread-Index: AQHPWZz/dNRWtKzbxU2a1gGvRNBdupsV9ChQgAGGmOCAABmeEIAai5qAgAqcDJA= Date: Mon, 12 May 2014 09:44:48 +0000 Message-ID: References: <20140115124935.30128.15593@wrigleys.postgresql.org> <20140416175501.GG7443@momjian.us> <1399298097.47090.YahooMailNeo@web122305.mail.ne1.yahoo.com> In-Reply-To: <1399298097.47090.YahooMailNeo@web122305.mail.ne1.yahoo.com> Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [80.11.149.154] x-forefront-prvs: 0209425D0A x-forefront-antispam-report: SFV:NSPM; SFS:(10019001)(6009001)(428001)(24454002)(76104003)(189002)(199002)(51704005)(2656002)(101416001)(19300405004)(16601075003)(50986999)(87936001)(77982001)(74316001)(19580395003)(81542001)(15975445006)(551934003)(15202345003)(81342001)(66066001)(83322001)(79102001)(31966008)(46102001)(85852003)(83072002)(86362001)(74662001)(76576001)(33646001)(20776003)(76176999)(4396001)(54356999)(21056001)(19273905006)(99396002)(92566001)(19580405001)(64706001)(21314002)(24736002)(562404015)(563064011); DIR:OUT; SFP:1102; SCL:1; SRVR:DB4PR06MB174; H:DB4PR06MB173.eurprd06.prod.outlook.com; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; A:0; LANG:en; received-spf: None (: kurmi-software.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ludovic.pollet@kurmi-software.com; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: kurmi-software.com X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org I encountered this problem while using exactly the pattern you describe! "Always add the large object before setting a reference to it, and always e= liminate references to a large object before deleting it." The problem is that you cannot delete references that have been seen by tra= nsaction that started in the past ! So even with this pattern, it is import= ant that older transaction can access LOB that are concurrently deleted/rep= laced. And this is only possible if they access it in readonly mode. (This = is coherent with the fact that they won't be able to perform modification o= n it at that time) My patch just make LOB access read only by default until a modification is = required. =20 Ludovic -----Message d'origine----- De=A0: Kevin Grittner [mailto:kgrittn@ymail.com]=20 Envoy=E9=A0: lundi 5 mai 2014 15:55 =C0=A0: Ludovic POLLET; pgsql-jdbc@postgresql.org Objet=A0: Re: [JDBC] TR: [BUGS] BUG #8842: lo_open/fastpath transaction inc= onsistency Ludovic POLLET wrote: > We are facing a bug where our application cannot read a Lob > because of concurrent removal. However, we are using the > serializable isolation level and a correct transaction scope. > We're using the latest JDBC driver snapshot (and hibernate but > that does not really matter). > > The problematic use case is basically a thread that read the LOB > while another thread replace it with a new one and release the > old one. In this case, the reader will get a "large object xxx > does not exist". > > From what I understand, it is due to the opening of the large > object that is always done in read/write mode and thus behave as > a read commited one (as written in the doc). > > This behaviour is at least very surprising especially when > working in SERIALIZABLE concurrency level. > > The attached patch implements the following changes: > -=A0 Opening the lob in read mode until a write function is called. > In such a case, the LOB will be reopened in read/write mode. It > totally solves my problem since our application does not modify > Lob, but creates new ones indeed. > -=A0 Deferring the first lo_open until a Blob function is really > called (hibernate seems to be creating blob even if it does not > even read them...) > > What do you think about these behaviors ? As one of the developers of the implementation of serializable transactions used by PostgreSQL, I remember that we needed to exclude large objects from the transaction serialization because it basically did not follow transactional semantics in any other regard.=A0 The only workaround I can think to suggest is to only insert and delete large objects -- never update them, and rely on the serialization of modifications to the OID columns which *reference* the large objects.=A0 Always add the large object before setting a reference to it, and always eliminate references to a large object before deleting it.=A0 A crash at the wrong time could leave a large object which is unreferenced, so you might want to look at the vacuumlo executable: http://www.postgresql.org/docs/current/static/vacuumlo.html Unfortunately, I don't know how that approach interacts with Hibernate or its use of the JDBC driver. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc