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

MySql NullReferenceException when running with transaction #317

Closed
mmalik76 opened this issue Apr 6, 2018 · 3 comments
Closed

MySql NullReferenceException when running with transaction #317

mmalik76 opened this issue Apr 6, 2018 · 3 comments
Labels
MySQL specific MySQL specific issues

Comments

@mmalik76
Copy link
Contributor

mmalik76 commented Apr 6, 2018

Getting the following exception when trying to update a MySql database with transaction.

2018-04-06 00:14:15,402 [INFO ] - Setup, Backup, Create/Restore/Drop
2018-04-06 00:14:16,535 [ERROR] - RoundhousE encountered an error. You were running in a transaction though, so the database should be in the state it was in prior to this piece running. This does not include a drop/create or any creation of a database, as those items can not run in a transaction.
System.NullReferenceException: Object reference not set to an instance of an object.
at MySql.Data.MySqlClient.MySqlCommand.AddCallStatement(String query)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction(IsolationLevel iso)
at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction()
at MySql.Data.MySqlClient.MySqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at roundhouse.databases.AdoNetDatabase.open_connection(Boolean with_transaction)
at roundhouse.migrators.DefaultDatabaseMigrator.open_connection(Boolean with_transaction)
at roundhouse.runners.RoundhouseMigrationRunner.run()

@mmalik76
Copy link
Contributor Author

mmalik76 commented Apr 6, 2018

After doing some digging I was able to track down the root cause. The MySql.Data uses a util to read embedded resource files, in this case keywords.txt. This util method appends Assembly.GetExecutingAssembly().GetName().Name to the resource name passed in, which in this case becomes "rh.keywords.txt" which doesn't exist, when it is really looking for "MySql.Data.keywords.txt".

I'm not sure if this is the best way to fix this issue, but the solution I found that works was copying the resource file into the roundhouse.databases.mysql project and overriding the name to "rh.keywords.txt". I am going to submit a pull request shortly for this.

@mmalik76
Copy link
Contributor Author

mmalik76 commented Apr 6, 2018

Submitted pull request #318

@BiggerNoise
Copy link
Member

I'm going to pick up the conversation in the P/R.

@erikbra erikbra added the MySQL specific MySQL specific issues label Nov 28, 2018
@erikbra erikbra closed this as completed Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MySQL specific MySQL specific issues
Projects
None yet
Development

No branches or pull requests

3 participants