Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Reading objects exclusively with a timeout from a cluster

Hello,

GigaSpace does not support a read with a timeout > 0 from a partitioned cluster. On the other hand, reading an object exclusively is much more convenient when a timeout may be specified: in many cases a small timeout (say, 1 second) may help when an exclusive read without a timeout can't lock an object.

In our application we use the following workaround when we want to read an object exclusively, but the routing key is not available:

  • Attempt to read an object as READ_COMMITTED. If nothing is found, the object does not exist.
  • If the object is found, get a routing key from the found object and attempt to execute the query again, this time with EXCLUSIVE_READ_LOCK and the routing key, using a timeout > 0. Now we could use a timeout > 0, because we have the routing key and the query is executed against a particular partition.

I wonder if there is a better solution? Also I wonder why GigaSpace does not provide something like this approach out-of-the box?

asked 2017-05-10 07:36:45 -0600

Alexey Serdyuk gravatar image

updated 2017-05-10 07:38:33 -0600

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

You can execute a Task that will perform the blocking exclusive read.

Its up to the client to consume the Future result or be notified about it.

answered 2017-05-10 07:43:36 -0600

shay hassidim gravatar image
edit flag offensive delete link more

Comments

Good idea, thank you. This will reduce a number of network trips from 2 to 1 when reading from a remote client.

Alexey Serdyuk gravatar imageAlexey Serdyuk ( 2017-05-10 07:54:45 -0600 )edit

A DistributedTask may be a part of a large transaction, right? So we could read an object exclusively using a trick with a DistributedTask, and write an updated object in the space in the same transaction.

Alexey Serdyuk gravatar imageAlexey Serdyuk ( 2017-05-10 08:01:39 -0600 )edit

Yes. You can start a distributed TX on the client side and continue it on the space side. Not sure you need this in such a case as the client would not touch the object , only the task.

From:forum@ask.gigaspaces.org [mailto:forum@ask.gigaspaces.org] Sent: Wednesday, May 10, 2017 9:02 AM

shay hassidim gravatar imageshay hassidim ( 2017-05-10 08:10:30 -0600 )edit

I mean a bit different case. There is some complicated transactional business logic on the client side. Currently it reads an object exlusively using the 2-step approach I described in the original post, makes some processing, modifies the object and writes the modified version back to the space. Exclusive read ensures that nobody else modifies the object when the business logic is being executed. Now the question is if we may use the same appoach using a DistributedTask read: on the client start a transaction, execute a DistributedTask which will read an object exclusively and return it, and afterwards just continue to execute on the client the same business logic which we do now. If this is possible, it would require only minimal code changes: call a DistributedTask to read an object instead of reading it explicitly.

Alexey Serdyuk gravatar imageAlexey Serdyuk ( 2017-05-10 08:13:56 -0600 )edit

Yes. Its possible. You start transaction at the client side , move it to the server side and later continue it on the client side.

shay hassidim gravatar imageshay hassidim ( 2017-05-11 08:00:28 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-05-10 07:36:45 -0600

Seen: 52 times

Last updated: May 10