Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sometimes, error "ORA-00933" occurs when using entity framework to query to Oracle DB but when I restart the webapp, it works

I have used Entity Framework 5 for Oralce Database of web-based application. Sometimes (rarely happens), error "ORA-00933" occurs but when I restart the webapp, it gets work again. This is log:

System.Data.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> Oracle.ManagedDataAccess.Client.OracleException: ORA-00933: SQL command not properly ended at OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution(OracleConnectionImpl connectionImpl, Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone) at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, OracleException& exceptionForArrayBindDML, Boolean isDescribeOnly, Boolean isFromEF) at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) --- End of inner exception stack trace --- at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues) at System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
at MOS.DAO.HisTreatment.HisTreatmentGet.GetById(Int64 id, HisTreatmentSO search)

This is the code "HisTreatmentGet.GetById":

HIS_TREATMENT result = null;
try
{
    bool valid = true;
    using (var ctx = new AppContext())
    {
        var query = ctx.HIS_TREATMENT.AsQueryable().Where(p => p.ID == id);
        ...
        result = query.SingleOrDefault();
    }
}
catch (Exception ex)
{
    ....
}
return result;

I've tried searching on google but there's no solution. Anyone can give me advices?

like image 234
TienCB Avatar asked Apr 22 '17 02:04

TienCB


1 Answers

There is a bug in the provider for Entity Framework from Oracle.

Seems like the Oracle.ManagedDataAccess.EntityFramework.SqlGen.SqlSelectStatement.Top_s is the culprit that gets borrowed by a parallel query. This should either be thread static (quick hack) or moved to some contextual state (proper fix, e.g. to SqlGenerator).

https://community.oracle.com/thread/3728543

No answer from Oracle support. That being said, there is a new version of the nuget package : 12.2.110. You may give it a try and check if the issue is fixed.

like image 155
Guillaume Avatar answered Nov 17 '22 00:11

Guillaume