Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CC0CD200BB1 for ; Thu, 3 Nov 2016 16:16:04 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CAB0A160AFE; Thu, 3 Nov 2016 15:16:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3389D160AFF for ; Thu, 3 Nov 2016 16:16:03 +0100 (CET) Received: (qmail 91560 invoked by uid 500); 3 Nov 2016 15:16:02 -0000 Mailing-List: contact users-help@tomee.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@tomee.apache.org Delivered-To: mailing list users@tomee.apache.org Received: (qmail 91501 invoked by uid 99); 3 Nov 2016 15:16:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Nov 2016 15:16:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 480FA18030C for ; Thu, 3 Nov 2016 15:16:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.38 X-Spam-Level: ** X-Spam-Status: No, score=2.38 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id SQFot1nFC4-a for ; Thu, 3 Nov 2016 15:15:58 +0000 (UTC) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 5C1485FBDF for ; Thu, 3 Nov 2016 15:15:58 +0000 (UTC) Received: by mail-wm0-f49.google.com with SMTP id a197so211799137wmd.0 for ; Thu, 03 Nov 2016 08:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=rVUJXea0gTaf+Fc8k6JubD7nrizbQy12cNfj7kkX9Ig=; b=JCo0TM/Km61Eiy9HaOn2kkAcbqqHePypASBV+2GmjIxU3VGOiljCo27n+xzCYHyP8j Zgm+rRxp0/D98lQx1niV7Jq51bwr32bvGejwLMfN4awIm1S+K48LMkjBXQcu//+tp8GT Nzoz7UueEp2ZaTKfwkocnXg1Ith9Kvm1uk4gbvKk97mfbSjceKfmC1fg0EJijTlmc8iW yheeuyoSENR+rYX/xhUUbMldqnMkY2GMHTilra1GLIGEjEr1Wg4RduGyTUekfQjB8NKg 5MAY58vV5MfOgkK9DjQ6ts1JqDJDfuVT40YljsK0rnVCaieFCuaAwJafFItt4pS05ejO OCGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=rVUJXea0gTaf+Fc8k6JubD7nrizbQy12cNfj7kkX9Ig=; b=k4c+Hmw+NJLYH4HoL0wUqi3jRFU4iqMJCIzH1YgoFfcT/6HeYG48NaATnfvW3m0B4e vOWXipW5HXIR1RDJ7wp+484hWXmzHfhzfWianmIA864jEYDU2iY1SS/oit9mep92Yzej anII1SdwXwmsj0GqaMIGMfnpqz22uEUjcz6rhsW9n31RsZw+lx/o3OAxObsJmfnI9TAV sV1QI2NdUnKbC51ME0uBNhA2tAgj6u0HKrni/DeF44rbpDqPG5NIVDd46YvbegGLI7Sh CF1ueJbnBLz2Ppe+gfpdv7vwb1BUuSO8vza4OaZ0QJqS24g4NSZqGZDEpWK9n9MgQVE/ P0BA== X-Gm-Message-State: ABUngvcq43Z+oA9WXVsUUgi0DgHAosdv0nlSKC5BzXhM8ImTIvSrk1nxow8sVF0sk5afaqlQDvaLpefapLza8A== X-Received: by 10.28.55.203 with SMTP id e194mr2457204wma.97.1478186157748; Thu, 03 Nov 2016 08:15:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.13.38 with HTTP; Thu, 3 Nov 2016 08:15:37 -0700 (PDT) In-Reply-To: References: <3D9A019D-00C2-47A8-A142-12EFCE422F9A@nycourts.gov> From: Romain Manni-Bucau Date: Thu, 3 Nov 2016 16:15:37 +0100 Message-ID: Subject: Re: Oracle XA with different credentials fails To: "users@tomee.apache.org" Content-Type: multipart/alternative; boundary=001a1143abd6d84d6705406708e3 archived-at: Thu, 03 Nov 2016 15:16:05 -0000 --001a1143abd6d84d6705406708e3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-11-03 16:10 GMT+01:00 Zachary Bedell : > The only place I can find that would be able to wrap the XAResource is in > org.apache.openejb.resource.jdbc.managed.local.ManagedConnection#newConne= ction(). > The assignment xaResource =3D xaConnection.getXAResource(); (line 186) co= uld > interpose a wrapper or proxy. It looks like everything that needs the > xaResource including the enlistResource() call in invoke() would get the > wrapped XAResource which could like about isSameRM(). > > The proposal was to wrap oraclexadatasource to change getXAResource to impl it the way you want. That said geronimo-transaction uses an IdentityHashMap for that so means Oracle is really broken. Anyway this is few lines of code and solves the issue without modifying any class of tomee stack for this workaround. > I don't see any way from ManagedConnection to access datasource propertie= s > or other attributes that would allow triggering that behavior > non-globally. Neither of the standard interfaces for XAResource nor > Connection have a way to get the username of the connection without doing > reflective things on Oracle internals. > > Any thoughts on where to get configuration information to control the > isSameRM override? > > FWIW, I cooked up a local version of geronimo-transaction based on the > 3.1.3 tag with isSameRM modified to always return false if a system > property is set. Replacing the version in TomEE & setting the system > property makes my Oracle XA connections work. > > -Zac > > > On Nov 2, 2016, at 19:28, Romain Manni-Bucau > wrote: > > > > Ji > > > > There is a useEqual option on the connectionmanager of the ra in geroni= mo > > but these datasource dont use a resource adapter so easiest solution is > to > > wrap the xadatasource to have this behavior > > > > Le 2 nov. 2016 21:53, "Zachary Bedell" a =C3=A9c= rit : > > > >> I ran into additional issues w/ Oracle XA datasources while figuring o= ut > >> the JMX stats issue, but this seems distinct enough to separate into i= ts > >> own thread. > >> > >> Oracle's XA driver returns true to isSameRM() in oracle.jdbc.xa. > OracleXAResource > >> if two XAResource's are on the same Oracle instance, even if they're > using > >> different login credentials. This seems to be a long standing > >> bug/misfeature in Oracle's JDBC driver going back to at least 2010 [ > >> https://community.oracle.com/message/4226001]. > >> > >> When using two datasources which point to the same Oracle instance but > >> have different credentials, org.apache.geronimo.transaction.manager. > >> TransactionImpl#enlistResource() tries to TMJOIN the transactions > because > >> isSameRM() returns true. This fails with "ORA-24774: cannot switch t= o > >> specified transaction" (see longer stack below) if the datasources > aren't > >> using the same credentials. > >> > >> Coming from a JBoss background, there was a kludge in the JBoss > datasource > >> descriptor of adding " > false" > >> which forced it to always assume isSameRM=3Dfalse without actually cal= ling > >> the underlying XAResource's implementation. This assumed two Oracle > >> datasources were on different transaction managers and ran them with > >> two-phase commit instead of trying to TMJOIN them. There was a > performance > >> hit in cases where the credentials were the same AND the connections > were > >> on the same instance, but it at least didn't fail outright. > >> > >> Looking through the source of TomEE & Geronimo-Transaction, it doesn't > >> like like there's any existing mechanism to override the "TMJOIN if > >> isSameRM=3Dtrue" behavior. This means it's not possible to include tw= o > >> Oracle datasources on the same instance with different credentials in > one > >> transaction. It works if the creds are the same OR if the datasources > are > >> on different instances. > >> > >> > >> I'm not sure how best to address this or whether the change ultimately > >> lies in TomEE or Geronimo-Transaction. Our DBA's prefer one user per > >> schema and multiple connection pools, even when things are on the same > >> instance. We can push to change that practice, but it seems like ther= e > >> should be a way to make this case work. > >> > >> Any thoughts? > >> > >> Here's what the stack looks when it fails: > >> > >> 16:32:12,206 WARN [Transaction] Unable to enlist XAResource > >> oracle.jdbc.driver.T4CXAResource@27a7b18f, errorCode: -3 > >> oracle.jdbc.xa.OracleXAException > >> at oracle.jdbc.xa.OracleXAResource.checkError( > >> OracleXAResource.java:1229) > >> at oracle.jdbc.xa.client.OracleXAResource.start( > >> OracleXAResource.java:246) > >> at org.apache.geronimo.transaction.manager.TransactionImpl. > >> enlistResource(TransactionImpl.java:202) > >> at org.apache.openejb.resource.jdbc.managed.local. > >> ManagedConnection.invoke(ManagedConnection.java:132) > >> at com.sun.proxy.$Proxy249.prepareStatement(Unknown Source) > >> at ucs.util.ormap.db.JDBCClientImpl.prepareStatement( > >> JDBCClientImpl.java:31) > >> at ucs.util.ormap.db.SQLGenerator.getPreparedStatement( > >> SQLGenerator.java:1867) > >> [...] > >> Caused by: java.sql.SQLException: ORA-24774: cannot switch to specifie= d > >> transaction > >> at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450= ) > >> at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:392= ) > >> at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:385= ) > >> at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java: > 1018) > >> at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522) > >> at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257) > >> at oracle.jdbc.driver.T4CTTIOtxse.doOTXSE(T4CTTIOtxse.java:164) > >> at oracle.jdbc.driver.T4CXAResource.doStart( > >> T4CXAResource.java:188) > >> at oracle.jdbc.xa.client.OracleXAResource.start( > >> OracleXAResource.java:241) > >> ... 81 more > >> > >> > >> Best regards, > >> Zac Bedell > >> > >> > > --001a1143abd6d84d6705406708e3--