Issue with Ms.Sync framework 2.0 and odp.net managed driver — oracle-tech

    Forum Stats

  • 3,715,648 Users
  • 2,242,819 Discussions
  • 7,845,478 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Issue with Ms.Sync framework 2.0 and odp.net managed driver

3728700
3728700 Member Posts: 6
edited November 2019 in ODP.NET

Hi,

We have been using Ms.Sync framework 2.0 and ODP.NET Umanaged driver to sync data with Oracle database.

Now, we moved to ODP.NET, Managed driver.

The synchronization fails with this error when we call RelationalSyncProvider.ProcessChangeBatch.

Do you have any ideas?

Thanks very much.

System.ObjectDisposedException was unhandled by user code

  HResult=-2146232798

  Message=Cannot access a disposed object.

Object name: 'OracleCommand'.

  Source=Oracle.ManagedDataAccess

  ObjectName=OracleCommand

  StackTrace:

       at Oracle.ManagedDataAccess.Client.OracleCommand.set_Connection(OracleConnection value)

       at Oracle.ManagedDataAccess.Client.OracleCommand.set_DbConnection(DbConnection value)

       at Microsoft.Synchronization.Data.DbSyncScopeHandler.ReadScope(IDbConnection connection, IDbTransaction transaction, ReadKnowledgeType readType, ReadForgottenKnowledgeType readFKtype)

       at Microsoft.Synchronization.Data.RelationalSyncProvider.InitializeChangeApplicationTransaction()

       at Microsoft.Synchronization.Data.RelationalSyncProvider.SingleTransactionApplyChangesAdapter.PrepareForApplyOrRetry(DataSet ds)

       at Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChanges(DbSyncScopeMetadata scopeMetadata, DataSet dataSet, DbSyncSession dbSyncSession, Boolean commitTransaction)

       at Microsoft.Synchronization.Data.RelationalSyncProvider.ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)

Answers

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,751 Employee
    edited June 2018

    From the error, something is disposing your OracleCommand object before you try to use it with ProcessChangeBatch. You can turn on managed ODP.NET tracing (TraceLevel=7) and Sync Framework tracing to deduce what is disposing of your object too early.

  • Thiyagu - Oracle
    Thiyagu - Oracle Member Posts: 30
    edited June 2018

    Here the complete parameter for tracing

    app.config or web.config

    <oracle.manageddataaccess.client>

        <version number="*">

          <settings>

              <setting name="TraceLevel" value="7"/>

              <setting name="TraceFileLocation" value="d:\TestCase"/>       

            <setting name="TraceOption" value="1"/>

          </settings>

        </version>

        </oracle.manageddataaccess.client>

    Thanks

    Thiyagu

  • 3728700
    3728700 Member Posts: 6
    edited June 2018

    Thanks for your feedback.

    Please find the requested Oracle's log here. We have 2 components: a webapp and a windows service. The sync is conducted in the windows service one. I include logs for the both component just in case you find anything relevant to the issue. The sync occurs from a remote app at 14:43.

    https://1drv.ms/f/s!Apd0OZJa5B_Ffeynbyw8kL18KQ8

  • 3728700
    3728700 Member Posts: 6
    edited June 2018

    I've updated above link with this file: Oracle and SyncFramwork Log.zip

    it contains SvcTraceSampleLevel5.txt sync-framework log file.

    The sync occurs at 15:28.

    Thanks very much.

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,751 Employee
    edited June 2018

    I reviewed the trace, but couldn't find RelationalSyncProvider.ProcessChangeBatch. I found a couple times in which the following exception occurs repeatedly:

    System.IndexOutOfRangeException: Unable to find specified column in result set

       at OracleInternal.ServiceObjects.OracleDataReaderImpl.GetColumnOrdinal(String colName)

    From what I understand in MS Sync Framework, MS doesn't formally support Oracle sync. And I know that Oracle doesn't offer its own Sync provider. You may want to ask the vendor providing the Sync Framework provider whether it has certified with managed ODP.NET. If so, then the vendor should create a service request with Oracle Support to debug this issue.

    The sync provider interaction with ODP.NET is causing the error. The open issue is whether there's a bug in the snyc provider or in ODP.NET.

  • 3728700
    3728700 Member Posts: 6
    edited August 2018

    Hi,

    We have been actively working on this with Microsoft Support in regards to

    "The sync provider interaction with ODP.NET is causing the error. The open issue is whether there's a bug in the snyc provider or in ODP.NET."

    We captured a bunch of dump files when the issue occur. And here is the result from Microsoft.

    https://1drv.ms/f/s!Apd0OZJa5B_Ffeynbyw8kL18KQ8

    Please suggest what to do next.

    ===From Microsoft Support ===

    High Level Findings and Recommendations:

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    The fact that there was the other exceptions related to the connection to the Oracle Data base leads us to believe that it was the network or TCP connectivity that is the cause of the issue and again is only an educated guess.

    The code that was executed in Sync Framework was basically just trying to execute a simple statement against the backend data base as part of the update or conflict resolution process. Sync Framework does not verify the connection state etc. as it relies on the data provider to do this work or notify the thread if the connection state changes. In this case the Oracle Data Provider for .Net would be responsible for handling the TCP / Network issue and then notifying any threads with access or handles to those objects. 

    Based on the information we have this is not a Sync Framework issue and there is not anything we can really do from the Sync Framework side to address the Disposed Exception.  Currently all of the data points to an issue with the Oracle Provider or the network connection to the Oracle Data Base and how the Oracle provider handles these types of failures. Eliminating the network errors might just resolve your issue.The only recommendation we can provide is that you work with Oracle to try and capture an ODP trace and see if that can shed some light into what happened with the Oracle Connection etc

    .

    Summary:

    -=-=-=-=-=

    Basically after looking at all the dumps (and there was quite a few), the First Chance exception rule you configured with Debug Diag for the Kofax Service and W3WP.exe processes did contain the System.ObjectDisposedException exception.

    The Debug Diag was configured to catch all first chance exceptions and while Debug Diag was monitoring the processes the only exceptions we found where not related to the Disposed Exception. In addition all of the dumps collected using the First Chance exception rule basically came down to 1 of 2 exceptions. The 2 exceptions that we collected dumps in state were either System.IO.FileNotFoundException or System.IndexOutOfRangeException. In all the dumps these exceptions where expected and handled appropriately.

    In going through all the data you uploaded, I did find one dump of interest in the Misc Directory that you uploaded for the Kofax.KFS.Service.exe process

    --- “kofax.kfs.service.exe__pid__1336__date__07_04_2018__time_05_27_36pm__761__manual dump.dmp” ---

    In this dump we did find that the Disposed Exception did occur: (But was a manual dump and as a result not in state of the exception at the time it occurred)

    Exception:

    Address: 0x0000000005b2be50  In Generation: 1 from .NET v4.0.30319.34209

    HResult: 0x80131622

    Type: System.ObjectDisposedException

    Message: Cannot access a disposed object.

    The problem is that the exception happened much earlier in the process (As you can see was not in Generation 0) and was not on any of the current thread stacks allowing us to look at the issue in more depth.

    As mentioned above, the dump was just a normal Manual Dump taken with Debug Diag. As a result this was just a snapshot of the process in time and was not taken when any of the exceptions of interest where thrown or on any of the current threads in the process.

    The exception stack trace that was captured was showing that the Kofax Service was calling ApplyChanges which than called into the Sync  Framework to try and update the back end data base server. All Sync Framework was doing at this time was executing an update statement and tried to execute this on an existing Oracle Command Object that was created earlier on by the ODP.Net provider. However, this time the Command Object which is part of the connection object created earlier was no longer valid. At some point the connection object had already been cleaned up and disposed and the attempt to execute a statement on that connection resulted in the error “Cannot access a disposed object”

    Now the interesting part is that in the same dump we see several other exceptions that had occurred in the process that could lead to connection object no longer being valid.

    The additional exceptions that had occurred where:

    Type: System.Net.Sockets.SocketException

    Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

    Type: Oracle.ManagedDataAccess.Client.OracleException

    Message: Network Transport: TCP transport address connect failure

    Type: System.Net.Sockets.SocketException

    Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

    Type: OracleInternal.Network.NetworkException

    Message: Network Transport: TCP transport address connect failure

    Based on this, it is possible that there was a network related issue which caused the Oracle Provider to clean up the connection and when the Kofax process went to execute the statement the object had already been disposed resulting in the error you are trying to track down “Cannot access a disposed object.”. It is possible that at the time this connection object was referenced it was pulled from a Connection Pool and was in the process of being cleaned up when it was handed to the thread wanting to apply data changes.

    This is just an educated guess based on the data. In addition we do not have a good understanding how the Oracle Provider handles network issues like this. But If I was to compare it the Microsoft SQL Providers, a network exception like the ones pointed out above could cause a very similar issue.

    It is only an educated guess since the dump was not taken in state of the exception and none of the threads running in the current in the process did not have any exception frames in state. In addition we are not sure how Oracle handles TCP Network errors or how it monitors state information on connections in a Connection pool. In addition we only have the one dump with any information on the Disposed Exception, and having another dump even if not in state would be useful to help prove the current theories.

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,751 Employee
    edited August 2018

    I would recommend opening up an Oracle Support service request to investigate this issue on the Oracle side. Finding the root cause does not appear straightforward.

    From a managed ODP.NET level 7 trace, you should be able to see the timestamp when connections are closed/disposed and what triggered that to occur. Presumably then, you can see whether the connection is attempted to be used after close/dispose.

    One possible cause that may be worth trying out is whether the problem is due to managed ODP.NET using a different connection pooling algorithm than unmanaged ODP.NET's default. UnManaged ODP.NET can use its traditional CP algorithm (CPVersion=1.0) or the newer one (CPVersion=2.0) . Managed ODP.NET only uses the newer one.

  • 3728700
    3728700 Member Posts: 6
    edited August 2018

    Thanks Alex,

    Please advise how to open up Oracle Support service request. I am new to this.

    Please also advise how to change to make UnManaged ODP.NET to use the newer CPVersion 2.0. I am happy to test with this!

    Thanks very much.

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,751 Employee
    edited November 2019

    Go to https://support.oracle.com/

    Log in and create a SR.

    Your organization should have a support identifier as part of the purchased Oracle license. Generally, dev teams have their DBA create the Oracle SR for them to streamline the process since the DBA is familiar with the process.

    CPVersion is an attribute under the <settings> section of the .NET config file. See here for the description:

    https://docs.oracle.com/cd/E85694_01/ODPNT/InstallManagedConfig.htm#ODPNT8162

    ******UPDATE November, 2019******

    This bug (29211153) was filed and investigated. From Oracle's analysis, one of the Microsoft APIs Oracle uses is calls the Dispose() function on one of the OracleCommand objects, then later on trying to use the same object. Oracle will inform MS of this bug.

This discussion has been closed.