How To Make A Bulk Transaction Entirely Asynchronous
Aug 13, 2010
i'm dealing with an ASP.NET 4.0 Web Forms Application in which the DAL is built with a combination of LINQ-SQL and classic ADO.NET (for auditing transactions, and bulk updates).
I have an admin page on the site which performs an update on a bunch of records (could be thousands), and not to mention there is T-SQL triggers in place on those records. Needless to say, its a killer of an update.
So of course, the page is timing out. The update transaction is performing with the following code:
db.ExecuteCommand("UPDATE [tblFoo] SET [IsFoo] = 0 WHERE [Bar] = {0}", bar.Id);
So it's a classic ADO.NET bulk update.
What i've tried to do is make the call to this method asynchronous, by firing off a thread on the button click on the form:
[code]...
The method OnMyAsyncMethod simply executes the above ADO.NET call.
This solved the UI problem, being the page now posts back and refreshes immediately. But then around 30 seconds lateri see that wonderful little flashing light on my Visual Studio toolbar - "an unhandled exception has occured, would you like to attach to process, etc".
So of course, now the actual call in the DAL is timing out.
Am i doing this wrong - is there a way i can perform the update transaction (db.ExecuteCommand) totally asynchrously?
Hopefully you see what im trying to do - i just need to fire off a killer of a T-SQL transaction. The only thing i need back from the call is the number of rows updated.
I want to know how much data is recommended to make transaction in web application at a time. I have 30,000 data. I want to insert and update in different transaction. When I do 30,000 data update at one time, some times it becomes hang web application, sometimes, it becomes timeout. So I want to know what the best amount of data to do Insert or Update at a time. It may be 1000/5000.
I have a try-catch inside a method that is called asynchronously. When an error occurs, inside the catch I have a Response.Redirect because I need to redirect to the login page.
This is my issue.
But my problem doesn't involve things that expire, so the idea of a timer isn't the best way to resolve it.
I've got all of my ASP.NET requests wrapped in a Session and a Transaction that gets commited only at the very end of the request. At some point during execution of the request, I would like to insert an object and make it visible to other potential threads - i.e. split the insertion into a new transaction, commit that transaction, and move on. The reason is that the request in question hits an API that then chain hits another one of my pages (near-synchronously) to let me know that it processed, and thus double submits a transaction record, because the original request had not yet finished, and thus not committed the transaction record.
So I've tried wrapping the insertion code with a new SessionScope, TransactionScope(TransactionMode.New), combination of both, flushing everything manually, etc. However, when I call Refresh on the object I'm still getting the old object state. Here's some code sample for what I'm seeing:
Post outsidePost = Post.Find(id); // status of this post is Status.Old using (TransactionScope transaction = new TransactionScope(TransactionMode.New)) { Post p = Post.Find(id); p.Status = Status.New; // new status set here p.Update(); SessionScope.Current.Flush(); transaction.Flush(); transaction.VoteCommit(); } outsidePost.Refresh(); // refresh doesn't get the new status, status is still Status.Old
We can catch the error log information by use EXEC xp_readerrorlog. I am just wondering is SQL have other types of log for us to reference information
I didn't wrote trigger for my tables... one table was missing, would it possible to know when the table was be deleted by some kind of transaction log?
What is the best way to format a transaction id?Conditions Max 15 characters: XXXXXXXXXXXXXXX -All transaction must be unique -Can contain both numerical and alphabetical characters -May contain Year, month, day
disconnected mode and transaction.it's give to me ERROR message
Quote.ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized PHP Code: da.InsertCommand = cb.GetInsertCommand
my code is:
PHP Code: Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("DBCon").ConnectionString) Dim cmd As New SqlCommand("insert into Customer (customer_id, customer_name, note) values (@cid, @cname, @note)", con) Dim da As New SqlDataAdapter("select * from CustomerPhone", con)
table 1 [Code].... Table 2 [Code].... my stored procedure [Code]....
when ever i m passing the wrong the value in second table while updating its not updating the table but the problem it is inserting the value in first table i want the whole trans should proceed if success if not rollback
I want to know is there any method or any concept to save transactions before system crash or failure. I am doing project in C# and backend is sql server 2005.
i'm using the entity data model to insert data to my database. the thing is that when inserting data to more than one table i want to ensure that all actions completed correctly(or catch an exeption if not).
T is type YYYY is year MM is month DD is day N is sequencial number X is check digit
The problem is, how do I generate the sequencial number? since my primary key is not an auto increment integer value, if it was i would use that, but its not.
EDIT can I have the sequencial number resets itself after 1 day (24hours).
P201012080000000001X <-- first transaction of 2010/12/08 P2010120810000000002X <--- second transaction of 2010/12/08 P201012090000000001X <--- First transaction of 2010/12/09 (X is the check digit)
I am writing a simple ASP.NET MVC using session per request and transaction per request patterns (custom HttpModule).It seems to work properly, but.. the performance is terrible (a simple page loads ~7 seconds). For every http request, graphical resources incuding (all images on the site) a transaction is created and that seems to delay the loading times (without the transactions loading times per one image are ~1-10 ms with transactions they are over 1 second).What is the proper way to manage transactions in ASP.NET MVC + NH stack?
When i've put all transactions into my repository methods, for some obscure reasons I got 'implicit transactions' warning in NHProf (the SQL statements were executed outside transaction, even that in code session.Save()/Update()/etc methods were invoked within transaction 'using' scope and before transaction.Commit() call) BTW are implicit transactions really bad?
Looking to build a web application which provides a platform for sending bulk SMS on reasonable rates. Whether i have to sign an agreement with GSM providers for sending SMS or is there an alternative for this? If so, how can i embed the SMS service with my application code?
I want to send and receive sms in my asp.net website.I am currently targetting users in India.I may need to send the same sms to thousands of users at the same time.How can I achieve this?
Now i got it to work but the bulk copy is inserting the rows twice, instead of once
and i know the table has the correct rows because i can see it in the gridview correctly
I FIXED THIS PART
my program works fine when i run it in debug mode but not when i place it on the server, it doesnt run the stored procedure when i put it on my server.
have the DataTable having thousands of record ,I need to modify the rows using some c# function,I do not want to iterate through each row.So how can I use linq for it.
I'm working on a project for my companies intranet which requires that multiple attached documents to the main DTO of the project need to be autoprinted in the background. The problem is it's a web project and I want the printing to be done under the surface. Now because it's on an intranet only certain people can use it and I can set a communal printer in the background but I'm wondering hwo to actually print under the surface, the attachments could be anything from photocopy gifs/jpegs to pdf/word docs. Should I use the PrintDocument class? Not really sure how to implement this one.
I am working on a project that requires a part of it to send Bulk SMS to a particular town( eg Toronto) or any other town, I can generate the coordinates of the town, but my problem is how to get the GSM numbers in the town.
I'm using checkbox to select the rows in the gridview. How do I insert the muliple selected rows into the table opening the connection for only one time.
The problem is that the transaction is not working.For instance,now the code is correct so both sql statements are getting executed.However,yesterday the 'update' statement was incorrect but I could not realise that IT WAS NOT ALRIGHT, because the function was not throwing myTrans.Rollback().I had put a breakpoint and there was no rollback.Apparently, now the sql statements,above,are ok,so there is no issue at the moment,however if there was an error,still the function would execute as if the sql statements were successful.
I know that I can use a Stored procedure and finish with it.But i want to see it how the Transaction works using SQLtransaction class.
I have written several queries under one single transaction. When any of the query throws an error then the whole transaction should rollback. However, in some rare cases say 2% cases even after the error the next transaction is getting comitted.
note that all transaction processes (opening, committing and rollback) is done through .net.
I am using 64bit windows 2003 for data and application server. And website is configured for runapp32on64.