[ 
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. There are no tests for them yet; 
they will be added 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, 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.



> 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. There are no tests for them yet; 
> they will be added 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)

Reply via email to