Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V13.3.0 - Upgrade Error - SqlException: Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong. #16267

Open
justin-nevitech opened this issue May 10, 2024 · 5 comments
Labels

Comments

@justin-nevitech
Copy link
Contributor

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.3.0

Bug summary

Upgrading a site to V13.3.0 throws the following SQL exception on a database that was previously migrated from V7:

Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong.###

Specifics

The error is caused by the following SQL statement for the V13.3.0 upgrade in the AlignContentVersionTable function within AlignUpgradedDatabase:

EXEC sp_rename N'DF_cmsContentVersion_VersionDate', N'DF_umbracoContentVersion_versionDate', N'OBJECT'

See here:

"EXEC sp_rename N'DF_cmsContentVersion_VersionDate', N'DF_umbracoContentVersion_versionDate', N'OBJECT'");

This is assuming the name of the constraint being renamed is DF_cmsContentVersion_VersionDate, but for some reason the name of the constraint in my database was DF__umbracoCo__Versi__6DCC4D03. Once I manually renamed the constraint to DF_cmsContentVersion_VersionDate the upgrade would continue and run successfully.

The database had recently been upgraded from V7 to V13.2.2 (via V8, V10, v11 and v12) but checking a copy of the V7 database the name of the constraint had been there since V7.

The full stack trace is:

Microsoft.Data.SqlClient.SqlException (0x80131904): Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean isAsync, Int32 timeout, Boolean asyncWrite)
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteNonQuery() in C:\\projects\\dotnet\\src\\MiniProfiler.Shared\\Data\\ProfiledDbCommand.cs:line 268
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.<ExecuteNonQuery>b__32_0()
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.<>c__DisplayClass38_0`1.<Execute>b__0()
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.Execute[T](Func`1 f)
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.ExecuteNonQuery()
at NPoco.Database.<>c__DisplayClass296_0.<ExecuteNonQueryHelper>b__0()
at NPoco.Database.ExecutionHook[T](Func`1 action)
at NPoco.Database.ExecuteNonQueryHelper(DbCommand cmd)
at NPoco.Database.Execute(String sql, CommandType commandType, Object[] args)
at NPoco.Database.Execute(Sql Sql)
at Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_3_0.AlignUpgradedDatabase.AlignContentVersionTable(ColumnInfo[] columns)
at Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_3_0.AlignUpgradedDatabase.Migrate()
at Umbraco.Cms.Infrastructure.Migrations.MigrationBase.Run()
at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunMigration(Type migrationType, MigrationContext context)
at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunScopedMigration(Type migrationType, MigrationPlan plan)
at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunMigrationPlan(MigrationPlan plan, String fromState)

I'm mainly included this here so anyone else that comes across this can find a solution.

Steps to reproduce

I've checked a few other V7 databases and found one other instance where the constraint was named differently, so I don't know at what point that constraint was created or by what. I don't have any other steps to reproduce other than what is already described above.

Expected result / actual result

The upgrade should not fail if it cannot find the constraint being renamed. As the constraint already exists (albeit with the wrong name), this should not cause any problems. If possible, the incorrect constraint name should be detected and renamed.

Copy link

Hi there @justin-nevitech!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

  • We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@PhilMakower
Copy link

Great I had the same error message.
I had also migrated a site from v7 and the constraint had a similar name to yours but with a different hex value on the end.
Once I changed the name to the correct one as above, the migration completed and I got a site!

@PhilMakower
Copy link

PhilMakower commented May 16, 2024

I created different databases for the various stages of migration: v7 to v8, v8 to v10 then v10 to v13.
So I can see those databases and what they contained at the various stages.
I can see that the constraint in the v7 database is called DF__cmsConten__Versi__5C6CB6D7 in my case.
I guess that changing the constraint name in the v7 database before I start the migration again would solve the issue?
The name does not seem to be changed during the migrations apart from the v13 to v13.3, so hopefully this won't stop the other migrations from working and will fix the v10 to v13.3 migration?

@justin-nevitech
Copy link
Contributor Author

That's great you managed to recreate the problem and the same fix worked, that's why I raised the issue mainly so it helped others! I guess you can change the constraint name at any point before migrating to v13.3?

@PFEW-ITSD
Copy link

Thanks for this @justin-nevitech! I was having a similar issue in trying to upgrade some sites from v7 to v13, with the error occurring in the upgrade from v10 to v13. Changing the constraint name got everything working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants