ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Concurrency problem WBIMB-DB2

Post new topic  Reply to topic
 Concurrency problem WBIMB-DB2 « View previous topic :: View next topic » 
Author Message
martinrydman
PostPosted: Tue Dec 07, 2004 3:02 am    Post subject: Concurrency problem WBIMB-DB2 Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Hi,

We have a flow that needs to set a counter-value for each message it processes, such that each consecutive message gets the last value incremented by 1. Simple enough, we create a DB2-table to hold a counter. Works fine.

Now, we have the flow running in a clustered environment. This means that two instances of the flow will potentially access the same counter field in the DB2-table. Classic multi-user problem.

How exactly shall we make sure that we don't run into concurrency problems? Fiddling with isolation levels, we seem to either

a) be too lax (the flows seem to spordically access the same value, i.e F1 reads the value, F2 reads the same value before F1 has updated it)

b) be too strict (we get DB2 error indicating that the table is locked and message gets rolled back)

This seems to be a common enough problem, but I can find hardly anything in neither docs nor Google

Any hints greatly appreciated!

/Martin
Back to top
View user's profile Send private message
JLRowe
PostPosted: Tue Dec 07, 2004 5:21 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

In the case of (b), you are locking the entire table? Try just locking the row with SELECT .... FOR UPDATE. Make sure that flow's that lock the row complete as quickly as possible.
Back to top
View user's profile Send private message Send e-mail
EddieA
PostPosted: Tue Dec 07, 2004 12:10 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Using the "new" feature in FP4 to call Java functions, I've written a Lock and Unlock function that can be used to ensure that 2 messages flows do not update a common "element" at the same time. Note, that this "locking" is within a single Execution Group only.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
martinrydman
PostPosted: Tue Dec 07, 2004 11:06 pm    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Thanks for your replies!

Locking only a single record won't help, since the problem arises when 2 processes accesses the same record.

It seems that in the b) case what we would need is for F2 to wait (timeout) before deciding an error has occurred, instead of jumping ship immediately.

It would seem that this scenario is common enough to have 'best practice', but maybe not...?

/Martin
Back to top
View user's profile Send private message
JLRowe
PostPosted: Wed Dec 08, 2004 6:06 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Surely the second process will wait a while for the lock and not just fail immediately?

Have you gone through the DB2 documentation?
Back to top
View user's profile Send private message Send e-mail
martinrydman
PostPosted: Sat Dec 11, 2004 12:47 am    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Hi all,

We now seem to have a solution, but it turns out to be a combination of things:

- We make use of FOR UPDATE (Thanks timna!)
- We set the COMMIT level of the ODBC driver to Repeatable Read
- We set the CL parameter WAITFILE in iSeries to *CLS

This is my understanding of why we need all three. Any guru seeing this and shaking his/her head at this point, please feel free to correct me!

The COMMIT level controls the Isolation Level, and in this case we need Repeatable Read. This much we assumed from the start.

WAITFILE make sure that the first process has time to finnish its job without the second process timing out.

FOR UPDATE makes sure the record gets locked in preparation for the subsequent UPDATE.

Not so hard once you get all the pieces in place, but pretty obscure before you get there!

/martin
Back to top
View user's profile Send private message
kirani
PostPosted: Sat Dec 11, 2004 7:50 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

martinrydman wrote:
- We make use of FOR UPDATE (Thanks timna!)

I thought only this was required.

Have you tried to set a timeout value on DB instead of using these two parameters?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
martinrydman
PostPosted: Sun Dec 12, 2004 1:22 am    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Hi,

We've been experimenting with various things (I don't know exactly what we've tried and didn't, since a collegue of mine has done the actual fiddling), so I can't say for sure.

How exactly do we set the time-out value on the DB?

Thanks,

/Martin
Back to top
View user's profile Send private message
kirani
PostPosted: Sun Dec 12, 2004 11:51 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Take a look at this thread,
http://www.mqseries.net/phpBB2/viewtopic.php?t=18946&highlight=timeout

I think the property name is LOCKTIMEOUT.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
martinrydman
PostPosted: Mon Dec 13, 2004 1:25 am    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Thanks!

/Martin
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Concurrency problem WBIMB-DB2
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.