Solved

Best Practices Approach to Rollback Management

Posted on 2010-09-07
8
407 Views
Last Modified: 2012-05-10
Hi Techies--
What is the best way to package  multiple inserts and/or updates from a series of separate service requests? Under this particular application design, several independent web service methods will be sending elements to the database  which all together make up the data which will need to be inserted. If for some reason, the data cannot be saved, I will need to rollback all of it--any suggestions?

0
Comment
Question by:ditallop
  • 4
  • 3
8 Comments
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 33621359
SQL Server can handle as many inserts at a time without any issues. So no need to worry about failure of Inserts..
Reg the updates, it should not ideally fail unless otherwise the table or the particular records are not locked by any other process.

In the meantime, what is the isolation level configured in your database.

>> I will need to rollback all of it--any suggestions?

Just use the construct like this

BEGIN TRANSACTION

INSERT statements
UPDATE statements

IF @@error <> 0
COMMIT TRANSACTION
ELSE
ROLLBACK TRANSACTION
0
 

Author Comment

by:ditallop
ID: 33629722
Thanks rrjegan--
Under usual circumstances, I am used to receiving incoming parameters to a specific referenced stored proc from the requesting client/web service... then updating and/or inserting using the transaction method as you outlined within that stored proc. In this case, I am receiving multiple requests from different clients/web services with different incoming parameters...which when collected all together -- make up one very large transaction set ... which will need to be rolled back if there's an error.

Here's what is happening:

Web Service A  sends the  manufacturing header and detail data for insert or update

Web Service B  sends the  color palettes used for the manufacturing detail for  insert or update

Web Service C sends the customer's ship to info for the order of the manufacturing item for an insert or update.

What I want to do is to gather the parameters coming in from Web Service A,
Web Service B and Web Service C  .... to a procedure which will manage the actual insert as a transaction.

I am not sure how to do this...or if it is able to be done... with a combo of sprocs/triggers...
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 33634157
>> What I want to do is to gather the parameters coming in from Web Service A,
Web Service B and Web Service C  .... to a procedure which will manage the actual insert as a transaction.

May I know why are you trying to gather all parameters coming from several Web Services which would create performance issues too.
Ideally, transactions should be kept small as possible in order to avoid performance issues, blocking and deadlocks.

And merging several services at Application level and managing transactions is not a good idea..
0
 
LVL 11

Expert Comment

by:Ved Prakash Agrawal
ID: 33634969
Always use @@trancount to check if any transaction is open.

because if you do rollback it will rollback all open transaction for session while commit need for each open transaction.

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ditallop
ID: 33640601
rrjegan17--
The web services are registered from multiple departments in an SOA environment -- each offering a portion of a whole transaction. I'm not committed to gathering parameters as much as I am assuring that the end transaction (200+ elements spanning 34 tables).

ved17nov--
thanks for the @@transactioncount check info.
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 33643814
Since it is a SOA, you can commit the services hitting directly into the database right without the use of a transaction itself. Can you give more inputs as I am afraid that I didn't understood your requirements clearly.
0
 

Accepted Solution

by:
ditallop earned 0 total points
ID: 33688236
It looks like we'll have to resolve this via the wcf service. Thanks all!
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 33690772
Thanks for posting the solution you have identified.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now