Domain creation fails when in UpgradeMode=Perform on PostgreSQL 9.2. I'm running DataObjects.NET 4.6.4 along with the matching PostgreSQL provider. It only fails during creation, not during update. I’ve traced the error through to a query looking for the missing metadata table faulting the transaction and causing subsequent queries to fail, specifically:

SELECT "a"."Name" AS "Name", "a"."Version" AS "Version" FROM "Workflow"."Metadata.Assembly" "a"

logs the following:

ERROR relation "Workflow.Metadata.Assembly" does not exist at character 62

This is expected, I guess, as the schema is empty. However, it follows up with


which fails with:

ERROR current transaction is aborted, commands ignored until end of transaction block

Running the same code with the UpgradeMode=Recreate works fine, so our workaround for now is to use this to lay down the schema.

The part of the stack trace you’d be interested in is as follows:

    Error Details:
Xtensive.Orm.StorageException: SQL error occured.
SQL error details 'Type: Unknown;'
Original message 'ERROR: 25P02: current transaction is aborted, commands ignored until end of transaction block' ---> Npgsql.NpgsqlException: ERROR: 25P02: current transaction is aborted, commands ignored until end of transaction block
   at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext() in C:\projects\Npgsql2\src\Npgsql\NpgsqlState.cs:line 853
   at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1175
   at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1191
   at Npgsql.ForwardsOnlyDataReader.NextResult() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1377
   at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError) in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1041
   at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb) in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 613
   at Npgsql.NpgsqlCommand.ExecuteNonQuery() in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 512
   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(SqlExtractionResult 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)

I'm assuming that this is not expected behaviour, and that running Perform should work properly on an empty database. I'd appreciate it if you could either confirm this as a fault or point out what I'm doing wrong.

Thanks for your help.

asked Nov 10 '13 at 19:11

Matthew%20Burnell's gravatar image

Matthew Burnell

One Answer:

Hello Matthew,

DataObjects.Net somehow supports what you want (Perform from empty database). But there are issues with actual implementation. In Perform mode DO tries to fetch existing metadata from the DB. If this fails, DO just ignores any error. You could see a warning in the log if it is configured. It seems that such errors are critical for PostgreSQL. If error occurs connection is no longer usable. I think we need to improve handling of this situation. Maybe reset connection or something like that. I'll post an update when there is more information on this issue.

answered Nov 11 '13 at 07:13

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov

Hi Denis,

Thanks for the response. Yes, I understand the exception is expected and I think you're exactly right: you need to reset the connection (or at least the transaction) before continuing on with further queries. As I said, it's easy for us to work around for now, as when in "Recreate" mode it obviously doesn't try to do this check, but we'd still appreciate a fix. I'll mark the question as answered, and hope to hear from you when a fix is available.

(Nov 12 '13 at 18:17) Matthew Burnell Matthew%20Burnell's gravatar image
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