SQL - Retrieving work

In which condition wont it? I have used this mechanism in a telco application to enforce uniqueness where we handled tens of million events an hour. Never had an issue
Contention...
Handling millions of events per hour is simple if there is no update contention, not so when there is.
 
Sure I understand that. But in the context of the suggestion?
The OP has described a contention scenario I.e. Where more than one data capture clerk tries to update the same record set; a rollback transaction won't resolve that.
 
Transactions allow you to control your changes but as @Johnatan56 is hinting, you need locking on the row level when implementing the change.
Exactly, but one also need to understand what in their workflow is serving up the same work to more than one data capture clerk. I can only assume; it's a case of poor contention design where a SQL query simply checks a flag; which under load can result in more than one clerk contending for the same update.
Locking can resolve that but so too queuing.
 
Last edited:
Exactly, but one also need to understand what in their workflow is serving up the same work to more than one data capture clerk. I can only assume; it's a case of poor contention design where a SQL query simply checks a flag; which under load can result in more than one clerk contending for the same update.
Locking can resolve that but so too queuing.

yep, a basic LIFO stack would work, something to add to the stack on upload and a manager to pop items off the stack for assignment, manager being a single instance of code.
 
yep, a basic LIFO stack would work, something to add to the stack on upload and a manager to pop items off the stack for assignment, manager being a single instance of code.
WHy LIFO in particular. OP didnt tell us whether there are priorities etc...
 
The OP has described a contention scenario I.e. Where more than one data capture clerk tries to update the same record set; a rollback transaction won't resolve that.
In my example the update is not important at all. It is the insert that prevents assigning a job multiple times
 
sounds like someone from your IT team solved the locking issues they experienced with "select * from xyz with(nolock)" to try and alleviate the performance issues they have. the issue with that, and transactions (hoping they have that in place) is that you get, what is called, a "dirty read", which means the same record can go out to multiple people as you've experienced.
 
sounds like someone from your IT team solved the locking issues they experienced with "select * from xyz with(nolock)" to try and alleviate the performance issues they have. the issue with that, and transactions (hoping they have that in place) is that you get, what is called, a "dirty read", which means the same record can go out to multiple people as you've experienced.

:laugh: That thought also crossed my mind.
 
In my example the update is not important at all. It is the insert that prevents assigning a job multiple times

Update and Insert should both create a lock on the row. Insert may be longer due to initial index/statistic creation.
 
A lot of these posts go over my head, I'll just copy and paste it into an email for IT and hope for the best.

Is this a new issue, or has it always been there?

Quite embarrassingly it's been an issue for years, it just gets worse the more popular my company becomes. I've just started getting really fed up that IT is not making progress, so I thought I'd ask the good ol' MyBB.

Contention...
Handling millions of events per hour is simple if there is no update contention, not so when there is.

We have on our busiest season around 11000-13000+ forms scanned per day, not so busiest is 8000 or so.
 
I'd get a consultant, could be a quick fix, but it may be more serious. Sounds like a biggish business so it will probably be worth it. Data integrity is super important
 
In my example the update is not important at all. It is the insert that prevents assigning a job multiple times
Sure, you avoid the final update conflict, but you don't avoid the contention; because the sanctity of the process you've defined hinges on exceptions / rollbacks.

Which is an anti-pattern, for example:
  • Don't use exceptions for control flow
  • POLA : Principle of least astonishment
Reference : http://wiki.c2.com/?DontUseExceptionsForFlowControl
 
Last edited:
We have on our busiest season around 11000-13000+ forms scanned per day, not so busiest is 8000 or so.
As @WAslayer surmised I think your best way to cleanly resolve this would be rearchitect part of the workflow to use a proper message queuing solution, however as a quick and dirty you could consider @Spacerat proposal, which would also avoid two or more clerks interpreting the same scans more than once including avoiding conflictis during the capturing of the metadata.
 
Last edited:
A lot of these posts go over my head, I'll just copy and paste it into an email for IT and hope for the best.



Quite embarrassingly it's been an issue for years, it just gets worse the more popular my company becomes. I've just started getting really fed up that IT is not making progress, so I thought I'd ask the good ol' MyBB.



We have on our busiest season around 11000-13000+ forms scanned per day, not so busiest is 8000 or so.

TBH, you are probably looking at a legacy issue in design. Also, depending on your IT team, they could be out of their depth ie: don;t expect techs or a network admin to do/troubleshoot a dba or developers job.
 
A lot of these posts go over my head, I'll just copy and paste it into an email for IT and hope for the best.



Quite embarrassingly it's been an issue for years, it just gets worse the more popular my company becomes. I've just started getting really fed up that IT is not making progress, so I thought I'd ask the good ol' MyBB.



We have on our busiest season around 11000-13000+ forms scanned per day, not so busiest is 8000 or so.
sounds like you might work for docIT or someone who might have implemented it 4 years ago
 
Sure, you avoid the final update conflict, but you don't avoid the contention; because the sanctity of the process you've defined hinges on exceptions / rollbacks.

Which is an anti-pattern, for example:
  • Don't use exceptions for control flow
  • POLA : Principle of least astonishment
Reference : http://wiki.c2.com/?DontUseExceptionsForFlowControl
agree 100%, just thought it may be a quick fix retrofit / bandaid. But I think there is bigger architectural issues
 
Top
Sign up to the MyBroadband newsletter
X