org.apache.geode.pdx.PdxSerializationException: Failed reading a PdxInstance (PDX) int field in VMware Tanzu GemFire
search cancel

org.apache.geode.pdx.PdxSerializationException: Failed reading a PdxInstance (PDX) int field in VMware Tanzu GemFire

book

Article ID: 294042

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

The VMware Tanzu GemFire Application code threw the following exception during a get operation:
Caught exception while attempting get operation on region XXXXX with key -> Y

Exception Message:

remote server on aaa-xxxxxx-yyyyyyyyy-zzzzz(client:1:loner):11111:22222222: org.apache.geode.pdx.PdxSerializationException: Failed reading a PDX int field; nested exception is org.apache.geode.cache.client.ServerOperationException: remote server on aaa-xxxxxx-yyyyyyyyy-zzzzz(client:1:loner):11111:22222222: org.apache.geode.pdx.PdxSerializationException: Failed reading a PDX int field
Exception Root Cause:
```
java.lang.IndexOutOfBoundsException
at java.base/java.nio.Buffer.checkIndex(Buffer.java:692)
at java.base/java.nio.HeapByteBuffer.getInt(HeapByteBuffer.java:404)
at org.apache.geode.internal.tcp.ByteBufferInputStream$ByteBufferByteSource.getInt(ByteBufferInputStream.java:271)
at org.apache.geode.internal.tcp.ByteBufferInputStream.readInt(ByteBufferInputStream.java:974)
at org.apache.geode.pdx.internal.PdxInputStream.readInt(PdxInputStream.java:205)
at org.apache.geode.pdx.internal.PdxReaderImpl.readInt(PdxReaderImpl.java:225)
at org.apache.geode.pdx.internal.PdxReaderImpl.readField(PdxReaderImpl.java:709)


Resolution

The issue is related to two threads calling get operations simultaneously and retrieving the same PdxInstance, resulting in corruption and throwing the above exception.

Even if copy-on-read is set to true, two threads calling get on a partitioned region can end up with the same PdxInstance object. This is problematic because some PdxInstances methods are not thread safe. Although the underlying bytes are immutable, the PDXInstance has a ByteSource with a position field that changes. This means two threads doing serialization or calling toString on the PdxInstance could result in one or more threads getting a corrupt read.

This is a known GemFire product issue (GEODE-8671), which is resolved in VMware Tanzu GemFire versionĀ  9.10.7/Apache Geode1.12.2/Pivotal Cloud Cache (PCC) 1.12.3.