Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

Best Practices Approach to Rollback Management

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
Paula DiTallo
Asked:
Paula DiTallo
  • 4
  • 3
1 Solution
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
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
 
Paula DiTalloIntegration developerAuthor Commented:
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
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
>> 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Ved Prakash AgrawalDatabase Consultant/Performance ArchitectCommented:
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
 
Paula DiTalloIntegration developerAuthor Commented:
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
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
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
 
Paula DiTalloIntegration developerAuthor Commented:
It looks like we'll have to resolve this via the wcf service. Thanks all!
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Thanks for posting the solution you have identified.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now