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

GEODE-9757: Ensure that tx cache ops always add CachedDeserializable entries #7022

Conversation

jdeppe-pivotal
Copy link
Contributor

@jdeppe-pivotal jdeppe-pivotal commented Oct 21, 2021

  • If you do a non-tx put directly on a member of a geode cluster (for
    example using a geode function), then the value is stored in the PR
    locally in a CachedDeserializable. But if you do the same op in a
    transaction it will store the object directly in the PR with no
    CachedDeserializable.
  • The reason for this is probably that the original tx implementation
    did not support partitioned regions and on a non-pr region the local
    region stored the value directly. So when support was added for
    transactions on partitioned regions this part of the code was not
    customized for partitions and just used the old code.
  • This can cause extra work to be done when fetching a value from the PR
    to send it back to a client. It can also cause bucket size exceptions
    if you directly change the value stored.

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

@jdeppe-pivotal jdeppe-pivotal marked this pull request as ready for review October 21, 2021 21:23
@jdeppe-pivotal jdeppe-pivotal added the redis Issues related to the geode-for-redis module label Oct 21, 2021
Comment on lines 2504 to 2535
@Override
public void txApplyPut(Operation putOp, Object key, Object newValue, boolean didDestroy,
TransactionId transactionId, TXRmtEvent event, EventID eventId, Object aCallbackArgument,
List<EntryEventImpl> pendingCallbacks, FilterRoutingInfo filterRoutingInfo,
ClientProxyMembershipID bridgeContext, TXEntryState txEntryState, VersionTag versionTag,
long tailKey) {

Object wrappedNewValue;
if (newValue instanceof CachedDeserializable || newValue instanceof byte[]
|| Token.isInvalidOrRemoved(newValue)) {
wrappedNewValue = newValue;
} else if (newValue instanceof Delta) {
int vSize = CachedDeserializableFactory.calcMemSize(newValue,
getPartitionedRegion().getObjectSizer(), false);
wrappedNewValue = CachedDeserializableFactory.create(newValue, vSize, cache);
} else {
byte[] serializedBytes = null;
if (txEntryState != null) {
serializedBytes = txEntryState.getSerializedPendingValue();
}

if (serializedBytes == null) {
serializedBytes = EntryEventImpl.serialize(newValue);
}

wrappedNewValue = CachedDeserializableFactory.create(serializedBytes, cache);
}

super.txApplyPut(putOp, key, wrappedNewValue, didDestroy, transactionId, event, eventId,
aCallbackArgument, pendingCallbacks, filterRoutingInfo, bridgeContext, txEntryState,
versionTag, tailKey);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should consider adding unit test and dunit coverage for BucketRegion.txApplyPut(...).

@jdeppe-pivotal jdeppe-pivotal merged commit e0c33cd into apache:develop Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
redis Issues related to the geode-for-redis module
Projects
None yet
4 participants