Sometimes catch StorageException with this error

Simple query "ALTER TABLE [dbo].[Filter] REBUILD" repair this But maybe DO should execute this query? :)

Full error:

    Xtensive.Orm.StorageException: SQL error occured.
    SQL error details 'Type: Unknown;'
    Query 'UPDATE [dbo].[Filter] SET [Name] = (CASE WHEN ([Filter].[TempName] IS NULL) THEN N'' WHEN ([Filter].[TempName] IS NOT NULL) THEN CAST([Filter].[TempName] AS nvarchar(400)) END);
    EXEC sp_rename '[shchipacheva].[dbo].[Filter].[User_Id]', 'TempUser_Id', 'COLUMN';
    ALTER TABLE [dbo].[Filter] ADD [User_Id] uniqueidentifier DEFAULT '00000000-0000-0000-0000-000000000000' NOT NULL;'
    Original message 'Cannot create a row of size 8061 which is greater than the allowable maximum row size of 8060.
    The statement has been terminated.
    Caution: Changing any part of an object name could break scripts and stored procedures.
    Warning: The table "Filter" has been created, but its maximum row size exceeds the allowed maximum of 8060 bytes. INSERT or UPDATE to this table will fail if the resulting row exceeds the size limit.' ---> System.Data.SqlClient.SqlException: Cannot create a row of size 8061 which is greater than the allowable maximum row size of 8060.
    The statement has been terminated.
    Caution: Changing any part of an object name could break scripts and stored procedures.
    Warning: The table "Filter" has been created, but its maximum row size exceeds the allowed maximum of 8060 bytes. INSERT or UPDATE to this table will fail if the resulting row exceeds the size limit.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
    at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
    at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
    at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    at Xtensive.Orm.Providers.StorageDriver.ExecuteCommand[TResult](Session session, DbCommand command, Func`2 action)
    --- End of inner exception stack trace ---
    at Xtensive.Orm.Providers.StorageDriver.ExecuteCommand[TResult](Session session, DbCommand command, Func`2 action)
    at Xtensive.Orm.Providers.SqlExecutor.ExecuteManyBatched(IEnumerable`1 statements)
    at Xtensive.Orm.Upgrade.UpgradeActionSequence.ProcessWith(Action`1 regularProcessor, Action`1 nonTransactionalProcessor)
    at Xtensive.Orm.Upgrade.SchemaUpgrader.UpgradeSchema(SchemaExtractionResult extractedSchema, StorageModel sourceModel, StorageModel targetModel, ActionSequence upgradeActions)
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.SynchronizeSchema(Domain domain, SchemaUpgrader upgrader, SchemaExtractor extractor, SchemaUpgradeMode schemaUpgradeMode)
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.PerformUpgrade(Domain domain, UpgradeStage stage)
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.BuildMultistageDomain()
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.Run()
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.Build(DomainConfiguration configuration)

Up 7.10.2015 On perform without changes in model, DO execute strange queries DROP/CREATE INDEX, ALTER TABLE etc.

Sample

using System;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

class Program
{
    static void Main(string[] args)
    {
        var dc = new DomainConfiguration("sqlserver://localhost/DO40-Tests");

        /// First time dc.UpgradeMode = DomainUpgradeMode.Recreate;
        /// then 
        dc.UpgradeMode = DomainUpgradeMode.Perform;

        dc.Types.Register(typeof(Program).Assembly);

        using (var d = Domain.Build(dc))
        {
            using (var s = d.OpenSession())
            using (s.Activate())
            using (var t = s.OpenTransaction())
            {
                t.Complete();
            }

            Console.WriteLine(".");
        }
    }
}

/// <summary>
/// Saved grid filters
/// User defined grid filters
/// </summary>
/// <revision>$Rev$</revision>
[HierarchyRoot]
[Serializable]
[Index("Entity", "User", "Name", Unique = true)]
public class Filter : Entity
{
    /// <summary>
    /// Initializes a new instance of the entity
    /// </summary>
    /// <param name="id">Unique element identifier</param>
    public Filter(Guid id)
        : base(id)
    {
    }

    [Field, Key]
    public Guid Id { get; set; }

    [Association(OnTargetRemove = OnRemoveAction.Cascade)]
    [Field(Nullable = false, NullableOnUpgrade = true)]
    public Filter Entity { get; set; }

    [Field(Nullable = false, NullableOnUpgrade = true)]
    public string Name { get; set; }

    [Field(Length = 4000)]
    public string DynamicLinqExpression { get; set; }

    [Association(OnTargetRemove = OnRemoveAction.Cascade)]
    [Field(Nullable = false, NullableOnUpgrade = true)]
    public Filter User { get; set; }

    [Field]
    public EntitySet<Filter> AvailableFor { get; set; }
}

asked May 19 '15 at 09:25

Anton%20Guschin's gravatar image

Anton Guschin
73303035

edited Oct 07 '15 at 03:35


3 Answers:

Hi Anton

According to the information you posted on 7.10.2015,we continued the investigation. We decided that Rebuild of tables is not a responsibility of DataObjects.Net. We found that excessive additions and drops of columns took place in this case even if there was no reason to do it. These actions forced row size increasing much faster.

We will fix influence of FieldAttribute.NullableOnUpgrade property on appearing unreasonable additions and drops of columns.

answered Oct 09 '15 at 07:56

Alexey%20Kulakov's gravatar image

Alexey Kulakov
77225

edited Oct 09 '15 at 07:57

Hello Anton.

DO uses queries like in error to change type of column without losing data. First, DO rename old column to Temp<old name> (for example, TempName in your case), then it creates new column of new type and than tries to copy data from temp column to new with cast to new type. Finally, DO removes temp column. In your case new column exceeds sql server limitation.

DO does not support ALTER TABLE ... REBUILD statement.

answered May 21 '15 at 05:08

Alexey%20Kulakov's gravatar image

Alexey Kulakov
77225

What DO does not support? If he can execute sql statements, than he support that

Now, it turns out that DO make some data manipulation in SQL after which application can't work properly (can't work at all) without DB administrator help

Sounds like bug for me

(Jun 04 '15 at 10:11) Anton Guschin Anton%20Guschin's gravatar image

Hello Anton

We'll fix this behavior.

Updated: Thanks for additional information. We'll continue the investigation. Now I'm not sure that implementation of ALTER TABLE .. REBUILD is the best solution for the issue.

answered Jul 27 '15 at 05:35

Alexey%20Kulakov's gravatar image

Alexey Kulakov
77225

edited Oct 07 '15 at 05:19

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA