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

ISPN-7096 Remove CacheTransaction.lookedUpRemoteVersions #4611

Merged
merged 1 commit into from
Oct 21, 2016
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,7 @@ public boolean performWriteSkewCheck(DataContainer container, PersistenceManager
if (trace) {
log.tracef("No entry for key %s found in data container" , toStr(key));
}
prevVersion = ctx.getCacheTransaction().getLookedUpRemoteVersion(key);
if (prevVersion == null) {
if (trace) {
log.tracef("No looked up remote version for key %s found in context" , toStr(key));
}
//in this case, the key does not exist. So, the only result possible is the version seen be the NonExistingVersion
return versionGenerator.nonExistingVersion().compareTo(versionSeen) == InequalVersionComparisonResult.EQUAL;
}
prevVersion = versionGenerator.nonExistingVersion();
} else {
prevVersion = ice.getMetadata().version();
if (prevVersion == null)
Expand All @@ -73,7 +66,9 @@ public boolean performWriteSkewCheck(DataContainer container, PersistenceManager
if (trace) {
log.tracef("Comparing versions %s and %s for key %s: %s", prevVersion, versionSeen, key, result);
}
return InequalVersionComparisonResult.AFTER != result;
// TODO: there is a risk associated with versions that are not monotonous per entry - if an entry is removed
// and then written several times, it can reach the previous version.
return InequalVersionComparisonResult.EQUAL == result;
}

// This entry is only used when versioning is enabled, and in these
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,6 @@ protected InternalCacheEntry remoteGet(InvocationContext ctx, Object key, boolea
InternalCacheEntry ice = retrieveFromProperSource(key, ctx, command, isWrite).get();

if (ice != null) {
if (useClusteredWriteSkewCheck && ctx.isInTxScope()) {
((TxInvocationContext) ctx).getCacheTransaction().putLookedUpRemoteVersion(key, ice.getMetadata().version());
}

EntryFactory.Wrap wrap = isWrite ? EntryFactory.Wrap.WRAP_NON_NULL : EntryFactory.Wrap.STORE;
entryFactory.wrapExternalEntry(ctx, key, ice, wrap, false);
return ice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public abstract class AbstractCacheTransaction implements CacheTransaction {

private EntryVersionsMap updatedEntryVersions;
private EntryVersionsMap versionsSeenMap;
private EntryVersionsMap lookedUpRemoteVersions;

/** mark as volatile as this might be set from the tx thread code on view change*/
private volatile boolean isMarkedForRollback;
Expand Down Expand Up @@ -291,19 +290,6 @@ public void setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions) {
this.updatedEntryVersions = updatedEntryVersions;
}

@Override
public EntryVersion getLookedUpRemoteVersion(Object key) {
return lookedUpRemoteVersions != null ? lookedUpRemoteVersions.get(key) : null;
}

@Override
public void putLookedUpRemoteVersion(Object key, EntryVersion version) {
if (lookedUpRemoteVersions == null) {
lookedUpRemoteVersions = new EntryVersionsMap();
}
lookedUpRemoteVersions.put(key, (IncrementableEntryVersion) version);
}

@Override
public void addReadKey(Object key) {
// No-op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ public interface CacheTransaction {

void setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions);

void putLookedUpRemoteVersion(Object key, EntryVersion version);
@Deprecated
default void putLookedUpRemoteVersion(Object key, EntryVersion version) {}

EntryVersion getLookedUpRemoteVersion(Object key);
@Deprecated
default EntryVersion getLookedUpRemoteVersion(Object key) { return null; }

boolean keyRead(Object key);

Expand Down