Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISPN-3197 Message ordering of Get and Invalidation can cause L1 to be in... #1922

Merged
merged 1 commit into from Jul 18, 2013

Conversation

wburns
Copy link
Member

@wburns wburns commented Jun 24, 2013

...consistent.

  • Implemented single entry point for concurrent gets.
  • Also support concurrent invalidation for reads with limited blocking
  • Added tests for various concurrency/edge issues

@@ -62,44 +69,219 @@
private CommandsFactory cf;
private LockManager lockManager;
private EntryFactory entryFactory;
private DataContainer dataContainer;

private final ConcurrentMap<Object, L1ReadSynchronizer> concurrentReads = new ConcurrentHashMap<Object, L1ReadSynchronizer>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use CollectionFactory.makeConcurrentMap instead. It allows us to swap between the JDK's CHM and the new CHMv8 which we've backported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for pointing that out.

@galderz
Copy link
Member

galderz commented Jun 26, 2013

@danberindei @mmarkus This pull req requires careful review.

@wburns
Copy link
Member Author

wburns commented Jun 26, 2013

Yes, as many eyes as can be spared would be best for this 👍

Unfortunately this was the simplest way I could find out of all the things I tried, that covered various inconsistency edge cases.

One thing to note is that this fix will need to be ported over to tx L1 as well at some point as it has the same issues, so if there are any pointers there you can think of, let me know!

@pruivo
Copy link
Member

pruivo commented Jun 27, 2013

I did a quick look at the discussion and I have some comments:

  • The invalidation does not need to wait for the remote get. When you receive an invalidation, you can mark the current remote get invalid. The invalidation command can return immediately and the remote get can be repeated. Also, it removes the key from data container (if exists)
  • The writes can update the L1 through your L1Synchronized by adding a simple method like updateL1(newValue). The blocking threads will return immediately the new value and they don't need to wait for the reply.
  • With both points above, you don't need to lock the key via LockManager, sine the L1Synchronized takes care of it. In addition, only the remote get threads (for read or write) are blocked (as expected IMO). However, we need to find a way to synchronize the L1 with the state transfer (rehash).

wdyt?

@danberindei
Copy link
Member

@pruivo Except the remote get may be actually over, and that thread is now updating the entry in the data container. I think that's the meaning of the RUNNING state...

For write commands we now decide whether to write a regular entry or an L1 entry in EntryWrappingInterceptor... doing another write in another interceptor would require us to acquire the shared state transfer lock again.

@pruivo
Copy link
Member

pruivo commented Jun 27, 2013

@danberindei I see... However, I think that all the events should synchronize at some point (update by remote get, update by local put and invalidation).

@wburns
Copy link
Member Author

wburns commented Jun 27, 2013

I am attempting to write up a dev list to nicely summarize and will include the latest comments to start it off.

@wburns
Copy link
Member Author

wburns commented Jul 5, 2013

@danberindei Updated it with most recent changes.

Object returnValue;
if (ctx.isOriginLocal()) {
Object key = command.getKey();
// If the value isn't possible to return a remote value - don't single request it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really understand the comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I mention single request, I am basically referring to the "corralling" part. Essentially if we know the value isn't going to look remotely or is already in the data container it just lets the invocation go down the interceptor chain.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think something like is better?

// If the command isn't going to return a remote value - just pass it down the interceptor chain

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds better :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 :-)

@wburns
Copy link
Member Author

wburns commented Jul 15, 2013

I fixed up rework items. Some comments still persist. Also this discussion is not confirmed good, but I removed the catch block #1922 (comment)

… inconsistent.

* Implemented single entry point for concurrent gets.
* Also support concurrent invalidation for reads with limited blocking
* Added tests for various concurrency/edge issues
@wburns
Copy link
Member Author

wburns commented Jul 16, 2013

Changed up comments so it says whether the get worked or not. Also added in static variable to hold whether trace is enabled.

@danberindei
Copy link
Member

Looks good, pulling.

@danberindei danberindei merged commit 7d08f0f into infinispan:master Jul 18, 2013
@danberindei
Copy link
Member

Integrated, thanks @wburns!

@wburns wburns deleted the ISPN-3197-singlethread branch November 4, 2014 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants