473,378 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 1611
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**************@TK2MSFTNGP12.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********@comcast.nospam.net> wrote in message news:OY**************@TK2MSFTNGP12.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
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...
8
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...
4
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...
0
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...
1
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. ...
66
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...
4
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
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...
10
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.