[jbosscache-dev] Handling invalid nodes

Elias Ross genman at noderunner.net
Thu May 15 22:51:21 EDT 2008


On Thu, May 15, 2008 at 3:52 PM, Manik Surtani <manik at jboss.org> wrote:

> So the question is this - with potentially likely events marking a node as
> invalid - especially with eviction - should we throw a
> NodeNotValidException?  Since (as of 2.1.0), the Node implementation that a
> user has is an instance of NodeInvocationDelegate which in turn has a
> reference to an UnversionedNode, perhaps we should handle the NNVE within
> the NodeInvocationDelegate and perform a lookup internally and refresh the
> UnversionedNode reference, and THEN throw a NNVE if we can't fetch the node?

Something feels wrong about using exceptions as message passing events
and flow control.

You should be able to check if a node is invalid before that exception
gets thrown. And if you do a retry, it seems possible to get stuck in
a loop: Exception, refresh succeeds, but immediate eviction again,
then exception again, etc. Maybe it's really unlikely, but it'd be a
bummer.

Wouldn't an evict require a write lock? If so, then this couldn't happen.

Or do this as part of the interception:
1. Pre-fetch node, mark as "do not evict", then check again if node is
valid (would have to use a volatile flag I think)
2. Do your business
3. Unmark



More information about the jbosscache-dev mailing list