-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to return cx_Oracle connection to "normal" state after using begin() w xid, e.g. xa_end (?) #530
Comments
I think cx_Oracle should/could expose XA_END. We were waiting to hear from our XA team about this and anything other gaps they want to discuss. A pure PL/SQL example I used to use is like:
Session 1:
Session 2:
Session 3:
Management has lots of doc e.g. Managing In-Doubt or Pending Oracle XA Transactions. I am happy to start a dialog with the XA team if you have questions. |
sorry for my lack of knowledge on PL/SQL calling forms how do I run that with the cursor?
fails with "ORA-00900: invalid SQL statement". How does the argument to DBMS_XA_XID relate to the arguments I'm passing to connection.begin() ? (e.g. can you make my example script work) |
I can get it to execute like this:
but the connection still doesn't work after that. |
I took a quick look. It would appear that the transaction remains associated with the connection even after commit/rollback takes place! I did a quick patch to ODPI-C to have it remove the transaction on commit and the code you provided works fine, then. I'll check internally if this is the right thing to do and, if so, provide a patch. :-) |
does that also mean that in my test, when I call vanilla begin() it's still using the global xid silently? |
No, that transaction has been cleared so local transactions start as usual when needed. You would need to call connection.begin() again to start a 2nd distributed transaction. I'm still waiting on confirmation that what I did is the right way to do that. Once I get confirmation I'll create a patch -- which you can try yourself if you have the ability and desire to do so! |
I was referring with the current, buggy behavior - " the transaction remains associated with the connection even after commit/rollback takes place" , but even when that issue occurs, " that transaction has been cleared so local transactions start as usual when needed" ? or once the bug is fixed? |
Apologies for the confusion! In the current (buggy) behavior, the transaction appears to remain associated with the connection even after commit/rollback takes place. With the proposed patch, commit/rollback clears that transaction so that subsequent local transactions start as usual when needed. Does that make more sense? |
yup that clarifies thanks! |
I'm marking this as an enhancement so it doesn't get auto-closed. We may still want to augment the XA support, in addition to the ODPI-C change. |
… now cleared on commit or rollback (`cx_Oracle issue 530 <https://github.com/oracle/python-cx_Oracle/issues/530>`__).
… now cleared on commit or rollback (`issue 530 <https://github.com/oracle/python-cx_Oracle/issues/530>`__).
cx_Oracle 8.2 has just been released which contains this patch. The XA support may be augmented further in the future, probably to use the names recommended by the database API (tpc_begin, etc.) |
hey all -
Just as we were discussing this recently, we now have a user dealing with 2pc for Oracle. On the SQLAlchemy side, I've had 2pc marked as "deprecated" as I was misled by the removal of the "twophase" flag indicating this meant two phase support was being dropped.
Looking now to re-establish complete 2pc support for Oracle this is the API question I have, which is how to revert a cx_Oracle connection back to "non 2pc" state after a begin(*xid) / prepare()/ commit() sequence has completed.
It appears that once conn.begin(*xid) is called, and then prepare() and commit() are done, all subsequent calls to commit() or rollback() will emit "ORA-24776: cannot start a new transaction", unless conn.begin() was called first, but I suspect the connection is still using that same XID.
It looks like I want the equivalent of XA_END https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_xa.htm#BABGAGII to be somehow available. But I don't know how to get that to work. If cx_Oracle had API to de-associate the connection from the prepared transaction entirely that would be best.
Demo so far. If you can show me what to put in the "cant get this part to work" part, I can move forward.
Also, once an XA transaction is created, what's the lifecycle of the "branch" ? that is, if I run a prepared transaction test in my CI, is it creating transaction artifacts on each run that are persistent? if so how do I get rid of them? thanks for your help!
The text was updated successfully, but these errors were encountered: