Sybase Internal Error 30016

谁说胖子不能爱 提交于 2019-12-11 07:28:18

问题


Database server is migrated from version 12.5x to version 15.03 Sybase.Data.AseClient version - 1.15.50.0

I am getting below exception when I run few stored procedures through .Net app (using AseClient)

Internal Error :30016 Unknown Dataitem Dataitem

Stack Trace - 

   at Sybase.Data.AseClient.AseDataReader.CheckResult(Int32 res)
   at Sybase.Data.AseClient.AseDataReader.RetrieveNextResult()
   at Sybase.Data.AseClient.AseDataReader.GetNextResult()
   at Sybase.Data.AseClient.AseDataReader.NextResult()
   at Sybase.Data.AseClient.AseDataReader.CloseUrsHandle()
   at Sybase.Data.AseClient.AseDataReader.Close()
   at Sybase.Data.AseClient.AseDataReader.Dispose(Boolean disposing)
   at Sybase.Data.AseClient.AseDataReader.Dispose()
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
   at HSBC.STPMapper.SybaseDAL.Utilities.SybaseHelper.ExecuteDataset(CommandType commandType, String commandText, DataSet dataset, String table, AseParameter[] commandParameters) in C:\Utilities\SybaseHelper.cs:line 119

Note - Application was working fine before we migrated to new server.


回答1:


We were running into this issue with some code running under .NET Framework 3.5 and using Sybase.Data.AseClient.dll (version 1.1.510.0) when we upgraded our production server from 12.5 to 15. Everything worked well in the dev and test environments after upgrading, but failed in production, even though ASP classic code and PowerBuilder code was able to call the production Sybase server (big legacy system).

If I tried calling the Read method of the AseDataReader for a single record, everything was fine. But if we allowed all the records to be read, it would read only 22 out of the 67 records that would be retrieved if you invoked the stored procedure via the Sybase SQL Advandage client. I boiled it down to a toy command line app to reproduce the issue. Here are the error details that would come out of the Read:

Type: Sybase.Data.AseClient.AseException
Message: Internal Error: 30016
StackTrace:    at Sybase.Data.AseClient.AseDataReader.?(Int32 A_0)
   at Sybase.Data.AseClient.AseDataReader.?(Boolean A_0)
   at Sybase.Data.AseClient.AseDataReader.?()
   at Sybase.Data.AseClient.AseDataReader.Read()
   at SybaseError.Program.TestCall(String friendlyName, String connectionString)
 in C:\Projects\SybaseUpgradeError\SybaseError\Program.cs:line 42

Assuming that you declared your IDataReader / AseDataReader in a using block, you would actually get the following error when the reader went out of scope when the original error from the Read was thrown:

Type: Sybase.Data.AseClient.AseException
Message: Internal Error: 30016
StackTrace:    at Sybase.Data.AseClient.AseDataReader.?(Int32 A_0)
   at Sybase.Data.AseClient.AseDataReader.?(Boolean A_0)
   at Sybase.Data.AseClient.AseDataReader.?()
   at Sybase.Data.AseClient.AseDataReader.?()
   at Sybase.Data.AseClient.AseDataReader.?(Boolean A_0)
   at Sybase.Data.AseClient.AseDataReader.NextResult()
   at Sybase.Data.AseClient.AseDataReader.?()
   at Sybase.Data.AseClient.AseDataReader.Close()
   at Sybase.Data.AseClient.AseDataReader.?(Boolean A_0)
   at Sybase.Data.AseClient.AseDataReader.Dispose()
   at SybaseError.Program.TestCall(String friendlyName, String connectionString)
 in C:\Projects\SybaseUpgradeError\SybaseError\Program.cs:line 54

You'll notice that the Dispose method of the AseDataReader is throwing an exception, which is a big no-no. Even worse is that if you catch the exception as an AseException and iterate over the Errors collection property, reading those will throw exceptions. Apparently, checking the properties of an AseError object actually invokes some dynamic code in the property that tries to look things up from an active connection. I'm not particularly impressed by this version of the Sybase .NET client code.

The issue boiled down to a packet size setting that was different on the production server than on the dev and test servers. I don't have admin access, but I believe they were set to min 2048 and max 4096 on the dev and test servers but both min and max set to 4096 on the production server. That's based on my recollection of a conference call, so your mileage may vary. I just wanted to put it out here in case it helps somebody else later. It took us a while to track the problem down. Changing the minimum packet size and rebooting the production database server did fix the problem for us.

In case it helps, here's my test console app with the connection strings scrubbed. Again, the commented lines at the bottom would throw errors if uncommented. Hope this helps you!

using System;
using System.Data;
using Sybase.Data.AseClient;

namespace SybaseError
{
    public class Program
    {
        public static void Main(string[] args)
        {
            const string DevelopmentConnection = "Data Source='**********';Port='****';UID='**********';PWD='**********';Database='**********';";
            const string ReportConnection = "more secret stuff";
            const string ProductionConnection = "yet more secret stuff";

            TestCall("Development", DevelopmentConnection);
            TestCall("Report", ReportConnection);
            TestCall("Production", ProductionConnection);

            Console.ReadKey();
        }

        private static void TestCall(string friendlyName, string connectionString)
        {
            Console.WriteLine("Calling procedure on " + friendlyName + ".");

            int recordsRead = 0;

            try
            {
                using (var connection = new AseConnection(connectionString))
                {
                    connection.Open();

                    using (var command = connection.CreateCommand())
                    {
                        ConfigureCommand(command);

                        using (var reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            try
                            {
                                while (reader.Read())
                                {
                                    // Would usually read things here...
                                    recordsRead++;
                                }
                            }
                            catch (Exception exRead)
                            {
                                Console.WriteLine("Error on read:");
                                ShowError(exRead);
                                throw;
                            }
                        }
                    }
                }

                Console.WriteLine("Success calling procedure on " + friendlyName + ".");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Outer error:");
                ShowError(ex);
                Console.WriteLine("Failure calling procedure on " + friendlyName + ".");
            }

            Console.WriteLine("Finished calling procedure on " + friendlyName + ".  Read " + recordsRead + " records.");
            Console.WriteLine(string.Empty);
        }

        private static void ConfigureCommand(AseCommand command)
        {
            command.CommandText = "sp_s_educator_route_tests";
            command.CommandType = CommandType.StoredProcedure;

            var spidParameter = new AseParameter("@spid", AseDbType.Integer);
            spidParameter.Value = 1355945;
            command.Parameters.Add(spidParameter);

            var vendorIdParameter = new AseParameter("@vendor_id", AseDbType.Integer);
            vendorIdParameter.Value = 1;
            command.Parameters.Add(vendorIdParameter);
        }

        private static void ShowError(Exception ex)
        {
            Console.WriteLine("Type: " + ex.GetType());
            Console.WriteLine("Message: " + ex.Message);
            Console.WriteLine("StackTrace: " + ex.StackTrace);

            var exAse = ex as AseException;

            if (exAse != null)
            {
                //foreach (AseError error in exAse.Errors)
                //{
                //    Console.WriteLine("SqlState: " + error.SqlState);
                //    Console.WriteLine("State: " + error.State);
                //}
            }
        }
    }
}



回答2:


Have a look at this; looks like you have a problem in your data that Sybase is now more picky about.




回答3:


There are a couple of things you might want to check. Firstly do you get this error when working with a smalldatetime which is NOT NULL. If yes can you change it to be NULLABLE and see if that fixes the problem. Secondly take a look at the ODBC DSN packet size, if it is 8192 try to set it down to 4096.

I hope it helps.



来源:https://stackoverflow.com/questions/1913779/sybase-internal-error-30016

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!