This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have this application where around 40-60 threads process some rows from a table, then it saves what it processed for those rows on the column Result, and then it removes them from the table. The table has a trigger on delete so when the row is deleted it is inserted in a history table.So after a row is processed, you can go to history and view the results column to see what has been done for that row. I have this issue that sometimes, for some rows (about 10%), the last uow.save() is not processed (as in the result column does not contain the latest addition to it.
Here's the code :
if (offerbundles != null && offerbundles.Count > 0) { String parameters = "SMSISDN=" + subscriberul.Swmsisdn.Substring(1, 9) + ";OP_CRED=" + ceva.BdlValue + ";SENDER=" + ceva.CpId + ";ACTION=" + ceva.Action + ";OP_ACDUR=0;OP_UNDUR=1;A_DEPCON=" + ceva.ADepcon+";"; counterAlarm.Result = counterAlarm.Result + " +transID: " + tranzactie.Id.ToString(); var shi2 = uow3.Insertppbilloffervantivelines( } uow.SaveChanges(); You see, I do a counterAlarm.Restult = counterAlarm.Result + "something else" then I do a uow.save() then i do a uow.remove(counterAlarm) then I once again to a uow.savechanges() to delete the row As I was saying, sometimes the last thing that I add on that column does not get persisted. I also log everything using log4net, and log4net so i can see this:
database content: changeId: 434485077 changeItemId: 611111725 changeItemId: 611111726 +transID: 1778723651
same row logged in log4net notice how it actually has 2 transaction ID's: 2010-10-05 14:16:07,578 [Consumer Thread 18] INFO ProcessAlarm1.Implementation - Finished processing alarm: [A_7777_1] [0742332230] result: [ changeId: 434485077 changeItemId: 611111725 changeItemId: 611111726 +transID: 1778723651 +transID: 1778723656] took: 00:00:00.3620000 I believe this is a lighspeed bug since i did say savechanges everytime i was supposed to. Please help. |
|
|
This is more likely to be a race condition than a LightSpeed bug. It is likely that multiple threads are working with the same database record at the same time, so that one thread is deleting a row before another thread can write its changes (so the second thread emits the UPDATE with the latest change, but there are no longer any rows matching its WHERE clause). You can use the LightSpeedContext.Logger to see what SQL LightSpeed is emitting: this will enable you to determine whether LightSpeed is in fact failing to emit the final UPDATE or whether (as I suspect) it is emitting the final UPDATE but the row has already been deleted. |
|