Does entity bean lock work across a cluster or only for the one server it's executed in?
posted 4 years ago
We're using an @Asynchronous method to pull some data from a table, and depending on some criteria, we update one row with a status. The problem we came across is that our async method can potentially (and has as we discovered in testing) be called simultaneously by two (or more) incoming requests to the method. Because of this, it seems it's possible that while one of the threads is reading the table, another could be updating the status, and we seem to get into trouble here. I've not been able to find any good info with regards to locking entities, how to use them correctly with multiple threads and so on. But more so, as the title suggests, we're also a bit worried with scaling our service and having multiple servers in a cluster that all refer to the same DB table. Does the entity bean locking mechanism work on the table level, or only within the container server the lock is initiated from? Is there some way to make sure it's on the DB table or row instead of just the container it's executed in?