Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-6307: Remove new local entries from onHeap map #2629

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1863,6 +1863,8 @@ protected final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(
if (tx == null || tx.implicit()) {
Map<KeyCacheObject, EntryGetResult> misses = null;

Set<GridCacheEntryEx> newLocalEntries = null;

final AffinityTopologyVersion topVer = tx == null ?
(canRemap ?
ctx.affinity().affinityTopologyVersion() : ctx.shared().exchange().readyAffinityVersion()) :
Expand Down Expand Up @@ -1937,6 +1939,8 @@ else if (storeEnabled)
}

if (!skipEntry) {
boolean isNewLocalEntry = this.map.getEntry(ctx, key) == null;

entry = entryEx(key);

if (entry == null) {
Expand All @@ -1946,6 +1950,13 @@ else if (storeEnabled)
break;
}

if (isNewLocalEntry) {
if (newLocalEntries == null)
newLocalEntries = new HashSet<>();

newLocalEntries.add(entry);
}

if (storeEnabled) {
res = entry.innerGetAndReserveForLoad(updateMetrics,
evt,
Expand Down Expand Up @@ -2140,6 +2151,11 @@ else if (storeEnabled)
ctx.evicts().touch(peekEx(key0), topVer);
}

if (newLocalEntries != null) {
for (GridCacheEntryEx entry : newLocalEntries)
removeEntry(entry);
}

return new GridFinishedFuture<>(e);
}
catch (IgniteCheckedException e) {
Expand Down
Expand Up @@ -919,13 +919,54 @@ public void testGetEntries() throws Exception {
/**
* @throws Exception In case of error.
*/
public void testGetAllWithNulls() throws Exception {
public void testGetAllWithLastNull() throws Exception {
final IgniteCache<String, Integer> cache = jcache();

final Set<String> c = new HashSet<>();
final Set<String> c = new LinkedHashSet<>();

c.add("key1");
c.add(null);

GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
cache.getAll(c);

return null;
}
}, NullPointerException.class, null);
}

/**
* @throws Exception In case of error.
*/
public void testGetAllWithFirstNull() throws Exception {
final IgniteCache<String, Integer> cache = jcache();

final Set<String> c = new LinkedHashSet<>();

c.add(null);
c.add("key1");

GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
cache.getAll(c);

return null;
}
}, NullPointerException.class, null);
}

/**
* @throws Exception In case of error.
*/
public void testGetAllWithNullInTheMiddle() throws Exception {
final IgniteCache<String, Integer> cache = jcache();

final Set<String> c = new LinkedHashSet<>();

c.add("key1");
c.add(null);
c.add("key2");

GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
Expand Down