views:

210

answers:

2

The architecture of the application is straight forward. There is a web application which maintain account holder data. This data is processed and the status of account holders is updated based on number of business rules. This process is initiated using a button on the page and is a long running process (say 15 mins). A component is developed to do this data processing which internally calls stored procedures. Most of the business rules are kept in stored procedure.

To handle timeouts the processing is done asynchornously(using Thread Pool or custom thread or Async Callback Delegates). The entire process run under a transaction. I would like to know your view on what happens to the transaction if the app pool is recycled or the worker process is terminated forcefully?

A: 

If the worker process is terminated, I think application rollbacks.

But you have to test.

Daniel Dolz
If there is noone there to perform the commit, eventually it will time out and the RDBMS will rollback.I made a mistake, i wrote "application rollbacks" but I should have written "transaction rollbacks"
Daniel Dolz
+2  A: 

I'm going to assume you're using a SQL database like SQL Server, MySQL or Oracle.

These database platforms have their own internal transactional model. When you communicate with them and initiate a transaction, the server manages the transaction for you.

For a transaction to commit, the database has to be told by the client to commit the changes. If the transaction never receives this instruction, the transaction remains in a "pending" state. Eventually, after the transaction is "pending" without any further instructions, the server will consider it "dead" and will abandon it, perform a rollback on the transaction.

This is the worst-case scenario for transaction-handling, as a pending transaction may (depending on isolation level) cause resources in the database (rows, pages, entire tables) to be unavailable. Normally you see this when a network connection has failed mid-transaction (e.g. from power loss) and the client does not send the "close connection" command to the server.


If your application is terminated by having the Application Pool recycled whilst in the middle of working against the database during a transaction, the connection to the database will be closed. This act of closing the connection should cause the server to abandon any pending transactions associated with the connection.

The exact behaviour will depend on the specific database and configuration.

In either case, your database's data will remain intact.

Programming Hero
Exactly! that's what i said!!
Daniel Dolz
This is what I was looking for a simple straight forward explaination.
ARS