473,587 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Isolating Data Access

I need help with what I think may be a design issue.

I need to access a record for processing. I need to do it in such a fashion that several concurrent processes do not access the same
record.

I've set up a stored procedure that first queries the table for a record to process than marks the record so that it is now
unavailable.

The process that executes this stored procedure runs on multiple threads on multiple machines.

My problem is that I have occasions where two or more threads access the same record at the same time which causes unwanted
redundant processing. IOW, I need to be able to guarantee that a record will never be processed by more than a single thread of
execution.

Does anyone have a solution or suggestion? Is there a design pattern for this?

FWIW, the parent process is a Windows Service written in C#.NET (v1.1) running against a SQL Server 2000 database.

ChrisG

Jul 21 '05 #1
2 1628
Chris:

Do you mean the record on the DB side or locally? If you mean on the db,
I'm not sure I understand. Let's say that I have record with a field called
CustNumber and process one with user Bill is accessing it. I pull the
record down into a dataset. During the select I mark the record as Used to
that the same query run now won't return the record b/c the where clause
specifies "where UsageFlag <> '1'" or whatever you do for indicating used.
Is this the scenario? Or do you mean you have 3 or four processes running
locally? If it's locally than you can sync lock the datatable (or the row)
and be done with it (well, that may be an overstatement, I don't want to
overgeneralize when we're talking about threading).

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Chris Gallucci" <ch***@gallucci .com> wrote in message
news:eZ******** ******@TK2MSFTN GP12.phx.gbl...
I need help with what I think may be a design issue.

I need to access a record for processing. I need to do it in such a fashion that several concurrent processes do not access the same record.

I've set up a stored procedure that first queries the table for a record to process than marks the record so that it is now unavailable.

The process that executes this stored procedure runs on multiple threads on multiple machines.
My problem is that I have occasions where two or more threads access the same record at the same time which causes unwanted redundant processing. IOW, I need to be able to guarantee that a record will never be processed by more than a single thread of execution.

Does anyone have a solution or suggestion? Is there a design pattern for this?
FWIW, the parent process is a Windows Service written in C#.NET (v1.1) running against a SQL Server 2000 database.
ChrisG

Jul 21 '05 #2
"William Ryan eMVP" <do********@com cast.nospam.net > wrote in message news:OY******** ******@TK2MSFTN GP12.phx.gbl...
| Chris:
|
| Do you mean the record on the DB side or locally?
On the DB side.

| If you mean on the db,
| I'm not sure I understand. Let's say that I have record with a field called
| CustNumber and process one with user Bill is accessing it. I pull the
| record down into a dataset. During the select I mark the record as Used to
| that the same query run now won't return the record b/c the where clause
| specifies "where UsageFlag <> '1'" or whatever you do for indicating used.
| Is this the scenario?
Yes. And I do as you suggest in a stored procedure call in an attempt to isolate the selection/marking.

Or do you mean you have 3 or four processes running
| locally? If it's locally than you can sync lock the datatable (or the row)
| and be done with it (well, that may be an overstatement, I don't want to
| overgeneralize when we're talking about threading).
I have several threads that call the aforementioned SP. At times it happens that 2 more threads appear to call the SP at the same
time in which case they grab the same record.

| --
| W.G. Ryan MVP Windows - Embedded

ChrisG
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3686
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various pages. I have been programming in PHP for over 2 years now and have never encountered a problem like the one I am having now. To me this seems...
8
4229
by: yerk5 | last post by:
Does js have some way of doing what I want here: I want to paste a multiline block of text into a TEXTAREA form field, and there is data in the block of text that I want to extract into a variable. It's always going to be as the same column and row position of the block of text. For example, I want to extract the text from the block from...
4
2298
by: Mike Thomas | last post by:
Access 2000 - Is there a 3rd party tool available, or perhaps some method built into Access 2000, which could isolate unused Access reports, queries, forms, etc? I have a 5 year old app which has not always been cleaned up. I know there are quite a few such no longer used items. I have a "Find" utility which is good, but I need to look...
0
1054
by: Christian Rank | last post by:
Hello, I'm setting up a PostgreSQL installation accessible by many different users. The layout is: - all users connect to the same database - every user has its own schema, no write access to the public schema - by default no additional privileges for the users Thus, a user cannot access the data (e. g. contents of a table) of another...
1
280
by: Chris Gallucci | last post by:
I need help with what I think may be a design issue. I need to access a record for processing. I need to do it in such a fashion that several concurrent processes do not access the same record. I've set up a stored procedure that first queries the table for a record to process than marks the record so that it is now unavailable. The...
66
5329
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it occurs. After the program has read the file, it should offer a menu with three choices. the first is to list all the words along with the number of...
4
2495
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
1
1596
by: jryanii | last post by:
hi i have a fla file of a website a friend gave me..i would love to use some of the features from the site.. all the code in in the fla file im having trouble isolating the correct pieces of code.. id like to put each effect into a separate fla file so i could easily update the content and transfer the effect to the site im currently building.....
10
3139
by: alhomam | last post by:
hi all, i found a program that provide a solution of how to create a timeline report similar to microsoft project i made my changes on the program some of the results is berfict and others is wrong in the same report please if any one can help me in this regard i will be thankful
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.