Repository navigation
Conversation
The multithreaded asynchronous nature of the transaction manager (MSDTC) makes it hard to deal with connections, timeouts and backend faults. All these fixes are the result of more than 2 years of debugging the provider running on medium to high traffic WCF Service based real world applications. Note that it is nearly impossible to validate these by writing tests because they spans scenario ranging from invalid consumer code to poorly performing queries and backends. They all have been fixed by the help of extending logging added in the provider to really understand what was going on. Unfortunately, you can't mimmic production environment.
|
Thanks for this patch @omatrot! Unfortunately I'm currently busy with other things (EF7, .NET Core support, and after that connection pool redo). A serious look and probably a redo is definitely something I want to do for 3.1 (or maybe 3.2), so I'll get around to it. BTW, you can also take a look at #513 and #634 to see other PRs on distributed transactions. |
|
No problem, it will allow me to push other fixes I've done in the resource manager and in other places as well. The goal for me was to have a rock solid transaction aware provider. Plenty of resources for you alongside other contributions to do a rewrite. |
2321a43 to
d1fbc1e
Compare
beae0a3 to
968113d
Compare
|
@omatrot, I've had a close look at the issue of TransactionScope timeout triggering a rollback at random times, and your attempt to handle this. I think there are several issues, which to be honest aren't really solvable.
To be honest, I find the idea of a rollback-on-timeout pretty bad. Rollback is something that should be taken care of by the application itself, when it knows in what state things are, rather than at some random point from a timer. Since user threads may be performing arbitrary database operations when the timeout triggers, it's going to be very difficult (read impossible) to provide a 100% safe and predictable solution. Here's what I did in my PR (#1380), it's similar to what you did, except that it simply attempts to send a rollback in a loop, catching NpgsqlOperationInProgressException exceptions to detect if the connection is in use, sending a cancel and sleeping for a bit. |
|
@roji The connector is tied to the current distributed transaction so I think there is little chance that it becomes busy after the check. I may be wrong but the code you're talking about is only involved during a distributed transaction. I may have pushed code in a wrong place, I'm not used to Git. And I'm pretty sure it is incomplete because I did it again on the latest 3.1.9 source code. Can I send you a zip file will al the latest code I'm using ? I faced another issue lately when a distributed transaction is commited without being first prepared. In the current implementation the connector is leaked. Anyway I think your solution will work fine, provided you exit your loop after a max number of tentative. |
|
@omatrot if you'd like, you can push your latest changes on 3.1.9 to some branch and simply post the link there - I think it'll be easier than exchanging ZIPs (although we can do that too). Regardless, any comment you have on my PR would be greatly appreciated, I need feedback for people with actual experience with distributed transaction :) At the moment, I didn't place a limit on the number of loops - that may be a good idea. I have a hard time imagining a scenario where we would loop forever: we can cancelling and reattempting to rollback. At some point it has to work, although to be extra safe you may be right. |
|
You probably know that nothing can replace production. Everything will fail at some point for various reasons. Poorly managed virtualized environments are still giving me a hard time with PostgreSQL/Npgsql. |
|
OK. I'm especially interested in anything missing (or wrong) in #1380. |
The multithreaded asynchronous nature of the transaction manager (MSDTC) makes it hard to deal with connections, timeouts and backend faults. All these fixes are the result of more than 2 years of debugging the provider running on medium to high traffic WCF Service based real world applications.
Note that it is nearly impossible to validate these by writing tests because they spans scenario ranging from invalid consumer code to poorly performing queries and backends.
They all have been fixed by the help of logs added in the provider to really understand what was going on.
Unfortunately, you can't mimmic production environment.