Hello all,
recently I came across an odd behavior in the oracle database in the production environment. I am not sure if this is the correct behavior.
I managed to reproduce the behavior in test environment.
my scenario:
1)I have a local database, a remote database and a DBLink in the local database pointing to the remote one.
2) read a value from the remote database.
3) insert or update values in a table in the local database.
4)disconnect the local database from the remote database(either a-unplug the network cable from the remote database b- unplug the network cable from the local database).
5) commit the changes on the local database.
for whatever strange reason it's the database decided to start a 2PC commit.
what I don't get is that I only read from the remote database, so why is the database trying to start a 2PC commit.
I could not find a viable solution. so had to implement the following workaround:
1) change the read operation into calling a procedure.
2) have the procedure call the remote database.
3) defined the procedure as having an autonomous transaction.
4) after reading the value , rollback the autonomous transaction.
it seems since the read from the remote database was not in the main transaction, when I try to commit it , it is not changed into a 2PC commit.