-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Not really Hibernate, but: database races with SLSBs?
PostPosted: Wed Aug 04, 2004 4:26 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
OK, I know this is not primarily a Hibernate question, but the smartest database/enterprise people I know are on this forum, so I'm going to try picking your brains here.

We have a pretty typical stateless-session-bean service layer (facade, if you will) on our Hibernate domain model.

We have a number of integration tests that make EJB invocations of this service layer.

We seem to be in a situation where in some deployment configurations (namely those with the database on a different machine than the EJB app server), database races are causing our tests to fail.

In other words, let's say we have a BidServiceBean, with two methods, createBid and updateBid. And we have a test case that does:

Code:
BidService bidService = //... jndi lookup for remote BidService ...
Bid bid = bidService.createBid();
bidService.updateBid(bid.getId(), newPrice);


What we get is an exception from the updateBid method, saying that the id of the bid is not found.

This only happens sometimes -- it is definitely timing-dependent -- and it happens a lot less when the database is colocated with the app server.

It looks to me as though the app server is saving the bid in a transaction, getting the bid's id, committing the transaction, and then returning the bid with the id. But the commit takes a while (this is with Postgres) and the test case is running much faster. So the updateBid call comes in before the commit has hit the database and the app server's transaction for the updateBid request does not see the new Bid!

Is this a well-known, boring, yawner problem with some solution that I am just ignorant of? Basically, is there any good way to tune the system such that database commits done by (stateless) session beans are guaranteed to be seen by subsequent (stateless) session bean invocations? If not, are there design principles for avoiding these kinds of races?

Thanks very much,
Rob


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


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

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.