livehelpnow / tds_ecto

TDS Adapter for Ecto
57 stars 34 forks source link

Weird error messages from failed migrations #59

Closed rzane closed 6 years ago

rzane commented 6 years ago

When a migration fails, Tds.Ecto generates cryptic error messages:

** (Tds.Error) Line 1 (Error 3971): The server failed to resume the transaction. Desc:3400000008.

If I add the @disable_ddl_transaction true attribute, I am able to read the real error message.

This isn't a huge deal, but it took me a while to figure out why my migration was failing. At least by creating an issue, other people might be able to figure out what's wrong with their migration.

mjaric commented 6 years ago

if possible, could you please provide us the case which fails with this message?

rzane commented 6 years ago

I've created an app here: https://github.com/rzane/tds_ecto_repro.

Here's the migration with the wierd error message: https://github.com/rzane/tds_ecto_repro/blob/master/priv/repo/migrations/20180208141326_one.exs

To reproduce, clone the repo and run mix do deps.get, ecto.create, ecto.migrate. You might need to change the connection config in config/dev.exs.

mjaric commented 6 years ago

Thanks! I will check it.

indyone commented 6 years ago

@mjaric I faced a similar case, where I got exactly the same error,

** (Tds.Error) Line 1 (Error 3971): The server failed to resume the transaction. Desc:3300000001

In my case, i was passing an Ecto.Multi to a Repo.transaction/2 and one of the queries was failing, making the transaction to rollback. If the rollback, also fails then the above error is the one that gets raised, silently ignoring the actual error of my failed query.

To find out what was the actual error... I "hacked" the Tds.Protocol module so that it outputs in the console all errors.

I think that somehow, we should include in the Tds.Error the inner or related errors, for easier error re-solving... What do you think?

mjaric commented 6 years ago

It is probably due bad return flow in tds app, could be that some func. raises error instead of returning labeled value.

What version of TDS are you using?

mjaric commented 6 years ago

Solved in tds_ecto 2.2