microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
307 stars 18 forks source link

Error SQL0: Data cannot be imported into target because it contains one or more user objects #296

Open mikejwhat opened 1 year ago

mikejwhat commented 1 year ago

DacFx Version:

Steps to Reproduce:

  1. Export database to bacpac on Azure storage account
  2. Attempt to restore bacpac to a new Azure SQL database

The below error is thrown:

Data cannot be imported into target because it contains one or more user objects. Import should be performed against a new, empty database. Error SQL0: Data cannot be imported into target because it contains one or more user objects. Import should be performed against a new, empty database.

I think this is when the databases are on the larger size (over around 5GB), though I have just seen a 1GB database restore fail.

I'm wondering whether DacFX is doing retries under the hood? I can't find any evidence of this though. Assuming this is something you've seen before?

dzsquared commented 1 year ago

If this is implemented using durable functions, the assumption is that the code is deterministic: https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-orchestrations?tabs=csharp-inproc#reliability

SqlPackage import is not deterministic, as in, if it is run more than once the result will not be the same (the subsequent times will error out). It isn't DacFx doing retries under the hood, it's the durable functions runtime.

If you're trying durable functions to accomplish longer functions runtime, you may be interested in modifying the host.json for a premium plan app: https://learn.microsoft.com/azure/azure-functions/functions-premium-plan?tabs=portal#longer-run-duration

mikejwhat commented 1 year ago

If this is implemented using durable functions, the assumption is that the code is deterministic: https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-orchestrations?tabs=csharp-inproc#reliability

SqlPackage import is not deterministic, as in, if it is run more than once the result will not be the same (the subsequent times will error out). It isn't DacFx doing retries under the hood, it's the durable functions runtime.

If you're trying durable functions to accomplish longer functions runtime, you may be interested in modifying the host.json for a premium plan app: https://learn.microsoft.com/azure/azure-functions/functions-premium-plan?tabs=portal#longer-run-duration

Thanks for the prompt response. I did consider the possibility that durable functions might be doing retries but the logging didn’t give me any indication that this was the case.

I have already increased the timeout in host.json. Are you suggesting increasing the timeout in place of using durable functions or as well as?

dzsquared commented 1 year ago

In place of using durable functions - due to the lack of control on the activity function (as in, you can't stop it from retrying), I really don't recommend them for this use case.