You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Juan Ramos (Jira)" <ji...@apache.org> on 2019/12/04 15:58:00 UTC
[jira] [Created] (GEODE-7535) Race Condition in LocalRegion.getAll
Juan Ramos created GEODE-7535:
---------------------------------
Summary: Race Condition in LocalRegion.getAll
Key: GEODE-7535
URL: https://issues.apache.org/jira/browse/GEODE-7535
Project: Geode
Issue Type: Bug
Components: client/server, regions
Reporter: Juan Ramos
The issue only happens for client regions with local storage ({{CACHING_PROXY}} or similar), and in the absence of transactions.
The {{getAll}} operation first retrieves the entry using the {{accessEntry}} method and, if the result is not {{null}}, it uses {{NonTxEntry.getValue()}} to obtain the actual value and add it to the result {{Map}}. The method {{NonTxEntry.getValue()}}, in turn, ends up callingĀ {{region.basicGetEntry(key)}} again.
{code:java|title=LocalRegion.java|borderStyle=solid}
// Some comments here
Map basicGetAll(Collection keys, Object callback) {
...
if (hasServerProxy()) {
...
// Gather any local values
// We only need to do this if this region has local storage
if (getTXState() == null && hasStorage()) {
...
for (Iterator iterator = keysList.iterator(); iterator.hasNext();) {
Object key = iterator.next();
Object value;
Region.Entry entry = accessEntry(key, true);
if (entry != null && (value = entry.getValue()) != null) {
allResults.put(key, value);
iterator.remove();
}
}
}
...
{code}
{code:java|title=NonTxEntry.java|borderStyle=solid}
private RegionEntry basicGetEntry() {
RegionEntry re = region.basicGetEntry(key);
if (re == null) {
throw new EntryDestroyedException(key.toString());
}
return re;
}
{code}
If the entry is locally destroyed between the two retrievals ({{accessEntry}} and {{basicGetEntry}}), which is rare but can happen as a consequence of eviction/expiration as an example, the {{getAll}} operation will fail and the following exception will be returned to the caller:
{noformat}
[vm2] [info 2019/12/04 15:51:52.949 GMT <RMI TCP Connection(1)-127.0.0.1> tid=0x13] Got result: EXCEPTION_OCCURRED
[vm2] org.apache.geode.cache.EntryDestroyedException: Key1
[vm2] at org.apache.geode.internal.cache.NonTXEntry.basicGetEntry(NonTXEntry.java:62)
[vm2] at org.apache.geode.internal.cache.NonTXEntry.getValue(NonTXEntry.java:91)
[vm2] at org.apache.geode.internal.cache.NonTXEntry.getValue(NonTXEntry.java:86)
[vm2] at org.apache.geode.internal.cache.LocalRegion.basicGetAll(LocalRegion.java:8611)
[vm2] at org.apache.geode.internal.cache.AbstractRegion.getAll(AbstractRegion.java:530)
[vm2] at org.apache.geode.internal.cache.AbstractRegion.getAll(AbstractRegion.java:520)
[vm2] at org.apache.geode.internal.cache.ClientCachingProxyRegionDistributedTest.lambda$getAllShouldNotThrowExceptionWhenEntryIsLocallyDeletedBetweenFetches$bb17a952$1(ClientCachingProxyRegionDistributedTest.java:102)
[vm2] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[vm2] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[vm2] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[vm2] at java.lang.reflect.Method.invoke(Method.java:498)
[vm2] at org.apache.geode.test.dunit.internal.MethodInvoker.executeObject(MethodInvoker.java:123)
[vm2] at org.apache.geode.test.dunit.internal.RemoteDUnitVM.executeMethodOnObject(RemoteDUnitVM.java:78)
[vm2] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[vm2] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[vm2] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[vm2] at java.lang.reflect.Method.invoke(Method.java:498)
[vm2] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
[vm2] at sun.rmi.transport.Transport$1.run(Transport.java:200)
[vm2] at sun.rmi.transport.Transport$1.run(Transport.java:197)
[vm2] at java.security.AccessController.doPrivileged(Native Method)
[vm2] at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
[vm2] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
[vm2] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
[vm2] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
[vm2] at java.security.AccessController.doPrivileged(Native Method)
[vm2] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
[vm2] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[vm2] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[vm2] at java.lang.Thread.run(Thread.java:748)
[vm2] from org.apache.geode.internal.cache.ClientCachingProxyRegionDistributedTest$$Lambda$135/2143459709.run with 0 args on object: org.apache.geode.internal.cache.ClientCachingProxyRegionDistributedTest$$Lambda$135/2143459709@7d3c7d1c (took 929 ms)
{noformat}
The {{getAll}} operation should not throw this {{Exception}}; it should, instead, retry internally and retrieve the entry from the server as it usually does for non locally existing entries.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)