[
https://issues.apache.org/jira/browse/IGNITE-29276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Reza Taroosheh updated IGNITE-29276:
------------------------------------
Description:
h3. Problem
In an ATOMIC cache, three kinds of values are created inside
{{BPlusTree.invoke()}}, in {{GridCacheMapEntry.AtomicCacheUpdateClosure}}, and
marshaled there:
* the value returned by {{CacheInterceptor.onBeforePut()}}, in
{{AtomicCacheUpdateClosure.update()}};
* the value merged by a conflict resolver
({{GridCacheVersionConflictContext.mergeValue()}}), in
{{AtomicCacheUpdateClosure.resolveConflict()}};
* the old value loaded by read-through for a {{put}}, in
{{AtomicCacheUpdateClosure.readOldValue()}}. A {{put}} reads through when
{{CacheConfiguration.isLoadPreviousValue()}} is set and the old value is
needed, for example by an interceptor, a filter or {{getAndPut()}}.
If such a value is of an {{Externalizable}} class that isn't registered yet,
the thread waits for the class registration inside the tree. An interrupt ends
the wait with a {{BinaryObjectException}}, {{BPlusTree.invoke()}} reports it as
{{CorruptedTreeException}}, and the failure handler stops the node, although
nothing is corrupted.
IGNITE-29241 fixes the same problem for the values of {{put}}, {{putAll}},
{{invoke}} and {{invokeAll}} by making their bytes before the tree. It doesn't
cover these three values, because on these paths they only exist inside the
tree.
h3. Reproducer
[PR #13828|https://github.com/apache/ignite/pull/13828] adds
{{AtomicInterceptorPutInterruptTest}} (in {{IgniteCacheTestSuite9}}). It holds
back the class name registration with a discovery hook, runs a {{put}} on an
interrupted thread into a cache whose interceptor returns an {{Externalizable}}
value, and checks that the put fails and the failure handler isn't called.
Expected: the put fails, and the failure handler isn't called.
Actual: the failure handler is called with {{CorruptedTreeException}}, caused
by {{BinaryObjectException: Failed to register class}} from
{{UserCacheObjectImpl.prepareForCache()}} in
{{AtomicCacheUpdateClosure.update()}}, caused by
{{IgniteInterruptedCheckedException}}.
The conflict resolver and read-through values are marshaled by the same
{{prepareForCache()}} calls inside the tree. No tests cover them yet; we'll add
them with the fix.
h3. Notes
* Moving {{onBeforePut()}} before the tree isn't a simple change: inside the
tree it runs after the checks that can still reject the update (version check,
filter, conflict resolution, expiry), so calling it earlier would also call it
for updates that are rejected later.
* In {{GridDhtAtomicCache.updateWithBatch()}} (multi-key update with a
write-through store), the interceptor already runs before the tree, so the
bytes of its value can be made right after it, as IGNITE-29241 does for the
entry processor's value.
* For {{invoke}}, IGNITE-29241 already reads the old value (with read-through)
before the tree, in {{AtomicCacheUpdateClosure.prepareInvoke()}}. Only {{put}}
still reads through inside the tree.
was:
h3. Problem
In an ATOMIC cache, {{CacheInterceptor.onBeforePut()}} is called inside
{{BPlusTree.invoke()}}, from
{{GridCacheMapEntry.AtomicCacheUpdateClosure.update()}}. If it returns a value
of an {{Externalizable}} class that isn't registered yet, the value is
marshaled there by {{prepareForCache()}}, and the thread waits for the class
registration inside the tree. An interrupt ends the wait with a
{{BinaryObjectException}}, {{BPlusTree.invoke()}} reports it as
{{CorruptedTreeException}}, and the failure handler stops the node, although
nothing is corrupted.
IGNITE-29241 fixes the same problem for {{put}}, {{putAll}}, {{invoke}} and
{{invokeAll}} by making the bytes of the new value before the tree. It doesn't
cover the interceptor, because on this path the interceptor's value only exists
inside the tree.
h3. Reproducer
In {{AtomicPutInterruptTest}} (added by IGNITE-29241):
{code:java}
/** The interceptor replaces the new value with an Externalizable value inside
the cache update. */
@Test
public void
testInterruptedPutWithInterceptorReturningUnregisteredExternalizableClass()
throws Exception {
IgniteCache<Integer, Object> cache = grid(0).createCache(new
CacheConfiguration<Integer, Object>("interceptor")
.setAtomicityMode(ATOMIC)
.setInterceptor(new ExternalizableInterceptor()));
checkInterruptedUpdateFails(() -> cache.put(1, 1));
cache.put(1, 2);
assertEquals(2, ((ExternalizableValue)cache.get(1)).val);
}
/** Replaces the new value with an Externalizable value, so the value is
created inside the cache update. */
private static class ExternalizableInterceptor extends
CacheInterceptorAdapter<Integer, Object> {
/** {@inheritDoc} */
@Override public Object onBeforePut(Cache.Entry<Integer, Object> entry,
Object newVal) {
return new ExternalizableValue((Integer)newVal);
}
}
{code}
Expected: the put fails, and the failure handler isn't called.
Actual: the failure handler is called with {{CorruptedTreeException}}, caused
by {{BinaryObjectException: Failed to register class}} from
{{AtomicCacheUpdateClosure.update()}} -> {{prepareForCache()}}, caused by
{{IgniteInterruptedCheckedException}}.
h3. Notes
* Moving {{onBeforePut()}} before the tree isn't a simple change: inside the
tree it runs after the checks that can still reject the update (version check,
filter, conflict resolution, expiry), so calling it earlier would also call it
for updates that are rejected later.
* In {{GridDhtAtomicCache.updateWithBatch()}} (multi-key update with a
write-through store), the interceptor already runs before the tree, so the
bytes of its value can be made right after it, as IGNITE-29241 does for the
entry processor's value.
> An interrupted ATOMIC update is reported as a corrupted B+Tree when an
> interceptor, a conflict resolver or read-through makes a value of a new
> Externalizable class
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: IGNITE-29276
> URL: https://issues.apache.org/jira/browse/IGNITE-29276
> Project: Ignite
> Issue Type: Bug
> Reporter: Reza Taroosheh
> Assignee: Reza Taroosheh
> Priority: Major
> Fix For: 2.20
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> h3. Problem
> In an ATOMIC cache, three kinds of values are created inside
> {{BPlusTree.invoke()}}, in {{GridCacheMapEntry.AtomicCacheUpdateClosure}},
> and marshaled there:
> * the value returned by {{CacheInterceptor.onBeforePut()}}, in
> {{AtomicCacheUpdateClosure.update()}};
> * the value merged by a conflict resolver
> ({{GridCacheVersionConflictContext.mergeValue()}}), in
> {{AtomicCacheUpdateClosure.resolveConflict()}};
> * the old value loaded by read-through for a {{put}}, in
> {{AtomicCacheUpdateClosure.readOldValue()}}. A {{put}} reads through when
> {{CacheConfiguration.isLoadPreviousValue()}} is set and the old value is
> needed, for example by an interceptor, a filter or {{getAndPut()}}.
> If such a value is of an {{Externalizable}} class that isn't registered yet,
> the thread waits for the class registration inside the tree. An interrupt
> ends the wait with a {{BinaryObjectException}}, {{BPlusTree.invoke()}}
> reports it as {{CorruptedTreeException}}, and the failure handler stops the
> node, although nothing is corrupted.
> IGNITE-29241 fixes the same problem for the values of {{put}}, {{putAll}},
> {{invoke}} and {{invokeAll}} by making their bytes before the tree. It
> doesn't cover these three values, because on these paths they only exist
> inside the tree.
> h3. Reproducer
> [PR #13828|https://github.com/apache/ignite/pull/13828] adds
> {{AtomicInterceptorPutInterruptTest}} (in {{IgniteCacheTestSuite9}}). It
> holds back the class name registration with a discovery hook, runs a {{put}}
> on an interrupted thread into a cache whose interceptor returns an
> {{Externalizable}} value, and checks that the put fails and the failure
> handler isn't called.
> Expected: the put fails, and the failure handler isn't called.
> Actual: the failure handler is called with {{CorruptedTreeException}}, caused
> by {{BinaryObjectException: Failed to register class}} from
> {{UserCacheObjectImpl.prepareForCache()}} in
> {{AtomicCacheUpdateClosure.update()}}, caused by
> {{IgniteInterruptedCheckedException}}.
> The conflict resolver and read-through values are marshaled by the same
> {{prepareForCache()}} calls inside the tree. No tests cover them yet; we'll
> add them with the fix.
> h3. Notes
> * Moving {{onBeforePut()}} before the tree isn't a simple change: inside the
> tree it runs after the checks that can still reject the update (version
> check, filter, conflict resolution, expiry), so calling it earlier would also
> call it for updates that are rejected later.
> * In {{GridDhtAtomicCache.updateWithBatch()}} (multi-key update with a
> write-through store), the interceptor already runs before the tree, so the
> bytes of its value can be made right after it, as IGNITE-29241 does for the
> entry processor's value.
> * For {{invoke}}, IGNITE-29241 already reads the old value (with
> read-through) before the tree, in
> {{AtomicCacheUpdateClosure.prepareInvoke()}}. Only {{put}} still reads
> through inside the tree.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)