I have a MySql database with nine tables within it. I need to dynamically upload to six of them from an asynchronous job within C#. However, to speed upload, four of them use MySqlBulkLoader, while the other two use a manual upload method. To support concurrency and prevent errors within the database, I need to upload them all at the same time. To do so, I decided to use transactions to make sure an "all or nothing" type upload.
Therein lies the problem: the MySqlCommand class allows for transaction support via the MySqlTransaction class within its Transaction property, and the MySqlBulkLoader allows for atomic upload (I use INNODB for the engine, see mysql - Can MySqlBulkLoader be used with a transaction?). However, the MySqlBulkLoader creates it's own transaction for atomic upload, while another separate transaction will be used for the MySqlCommand's I will be executing. This does not support serialization, and could still result in errors if one bulk loader completes it's job, yet the application closes before another can finish. This would be solvable if transactions could be nested; however, they cannot: php - Mysql transactions within transactions.
My questions is as follows: is there any way in the C# connector to allow the MySqlBulkLoader to be associated with a MySqlTransaction, and if not, if there is any way to automatically rollback changes made by previous MySqlBulkLoaders. I have looked in the API provided by the Connector.NET 6.9, and it seems this is potentially possible via the MySqlConnection.BeginTransaction() method, but a question from Werner Wolf suggests otherwise.
EDIT
I found this question by Saravanan. However, I do not think that question relates to this one by the factor of the MySqlBulkLoader intermingling with the MySqlCommand.