we have written a C# 3.5 client talking to an Oracle database (11g) using the ODP.NET.
This application has a batch process where a long running task is performed ma
Addressing the main issue first:
- How is it possible that a timeout exception can occur when the timeout setting is (presumably, aside from inner workings that I do not know about) the same for all transaction scopes and has a timeout value defined of 1 day, where the exception occurs after approx. 10 minutes?
There is the TransactionManager.MaximumTimeout
property which is the upper bound of whatever you are trying to set via your scope. On your system, it is set to 10 minutes
, but according to the documentation
This value can be set in the MachineSettingsSection of the config file.
As to the other questions:
- Is it necessary to define timeout values for nested transactions or do they inherit this from the ambient transaction?
The scope initiating a transaction (i.e. any RequiresNew
scope, any outermost Required
scope, and any Required
scope that has a Suppress
scope one level up the nesting stack) will establish a transaction timeout
, and as far as my reading of the sources goes, this timeout is not affected by nested scopes.
However, every nested scope participating in an existing transaction (i.e. any Required
scope that has a Required
or RequiresNew
scope one level up the stack) will establish its own scope timeout that runs in addition to the transaction timeout mentioned above.
Transaction timeouts and scope timeouts are implemented differently internally, but if any one of these timeouts hits, a transaction yet to be Complete()
d would be rolled back.
Btw, aforementioned TransactionManager.MaximumTimeout
only applies to transaction timeouts. Scope timeouts do not have an upper bound. Not that it really matters, as the shortest timeout is what counts anyway.
- Is it possible to prevent Oracle from creating a distributed transaction for transactions where the connectionstring is the same?
As long as you have only one "physical" DB connection open at any single point in time, the scope will not escalate to DTC. If I recall correctly, this works with Oracle ODP.Net, despite (this) seemingly claiming the opposite (maybe it did not work with the version at the time?).
You may or may not be able to prevent concurrent connections even with nested scopes, and for different databases (as long as they are on the same server).