[infinispan-dev] ISPN-3557: interactions between a clear() operation and a Transaction

Sanne Grinovero sanne at infinispan.org
Tue Oct 1 19:03:30 EDT 2013

I'd love to brainstorm about the clear() operation and what it means
on Infinispan.

I'm not sure to what extent, but it seems that clear() is designed to
work in a TX, or even create an implicit transaction if needed, but
I'm not understanding how that can work.

Obviously a clear() operation isn't listing all keys explicitly. Which
implies that it's undefined on which keys it's going to operate when
it's fired.. that seems like terribly wrong in a distributed key/value
store as we can't possibly freeze the global state and somehow define
a set of keys which are going to be affected, while an explicit
enumeration is needed to acquire the needed locks.

It might give a nice safe feeling that, when invoking a clear()
operation in a transaction, I can still abort the transaction to make
it cancel the operation; that's the only good part I can think of: we
can cancel it.

I don't think it has anything to do with consistency though? To make
sure you're effectively involving all replicas of all entries in a
consistent way, a lock would need to be acquired on each affected key,
which again implies a need to enumerate all keys, including the
unknown keys which might be hiding in a CacheStore: it's not enough to
broadcast the clear() operation to all nodes and have them simply wipe
their local state as that's never going to deal correctly
(consistently) with in-flight transactions working on different nodes
at different times (I guess enabling Total Order could help but you'd
need to make it mandatory).

So let's step back a second and consider what is the use case for
clear() ? I suspect it's primarily a method needed during testing, or
maybe cleanup before a backup is restored (operations), maybe a
manually activated JMX operation to clear the cache in exceptional

I don't think there would ever be a need for a clear() operation to
interact with other transactions, so I'd rather make it illegal to
invoke a clear() inside a transaction, or simply ignore the
transactional scope and have an immediate and distributed effect.

I'm likely missing something. What terrible consequences would this have?


More information about the infinispan-dev mailing list