[Bug] Fastjson2 concurrent JSONB deserialization still drops reference fields after reader warmup

Author: slievrlyCreated Sep 26, 2026Updated Sep 26, 2026

Check Ahead

  • Searched existing issues. This is a follow-up to #8159 / #8160: the reader warmup fix is present, but the regression tests still fail intermittently.
  • I am willing to submit a fix.

Issue Description

The fastjson2 concurrent reference-deserialization regression tests intermittently fail on 2.x with Concurrent deserialization dropped $ref fields: 1. This is an actual assertion failure after decoding a reference-heavy JSONB payload, not just an SLF4J warning. Both RPC messages and UndoLog images are affected.

The failing PRs change unrelated tests; none change fastjson2. Current 2.x (96e84e52f1013c484ef524afefdc81a2fb981d18) uses fastjson2 2.0.52 and pre-creates field-based ObjectReaders, but still parses JSONB concurrently.

CI evidence and stack traces

Java 8 / RPC: PR #8265

Failed CI job

Exception in thread "main" java.lang.AssertionError: Concurrent deserialization dropped $ref fields: 1
at org.apache.seata.serializer.fastjson2.Fastjson2ConcurrentRefDeserializationTest.main(Fastjson2ConcurrentRefDeserializationTest.java:55)

at org.apache.seata.serializer.fastjson2.Fastjson2ConcurrentRefDeserializationTest.assertChildProcessSucceeds(Fastjson2ConcurrentRefDeserializationTest.java:141)
at org.apache.seata.serializer.fastjson2.Fastjson2ConcurrentRefDeserializationTest.concurrentDeserializeReferenceHeavyProtocolMessageDoesNotDropRefFields(Fastjson2ConcurrentRefDeserializationTest.java:43)

[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.025 s - in org.apache.seata.saga.statelang.domain.StateTypeTest

Java 17 / UndoLog: PR #8239

Failed CI job

Exception in thread "main" java.lang.AssertionError: Concurrent deserialization dropped $ref fields: 1
at org.apache.seata.rm.datasource.undo.parser.Fastjson2ConcurrentRefDeserializationTest.main(Fastjson2ConcurrentRefDeserializationTest.java:60)

at org.apache.seata.rm.datasource.undo.parser.Fastjson2ConcurrentRefDeserializationTest.assertChildProcessSucceeds(Fastjson2ConcurrentRefDeserializationTest.java:163)
at org.apache.seata.rm.datasource.undo.parser.Fastjson2ConcurrentRefDeserializationTest.concurrentDeserializeReferenceHeavyUndoLogDoesNotDropRefFields(Fastjson2ConcurrentRefDeserializationTest.java:48)

[INFO] Running org.apache.seata.rm.datasource.undo.BaseUndoExecutorTest

Java 21 / RPC: PR #8235

Failed CI job

Exception in thread "main" java.lang.AssertionError: Concurrent deserialization dropped $ref fields: 1
at org.apache.seata.serializer.fastjson2.Fastjson2ConcurrentRefDeserializationTest.main(Fastjson2ConcurrentRefDeserializationTest.java:55)

at org.apache.seata.serializer.fastjson2.Fastjson2ConcurrentRefDeserializationTest.assertChildProcessSucceeds(Fastjson2ConcurrentRefDeserializationTest.java:141)
at org.apache.seata.serializer.fastjson2.Fastjson2ConcurrentRefDeserializationTest.concurrentDeserializeReferenceHeavyProtocolMessageDoesNotDropRefFields(Fastjson2ConcurrentRefDeserializationTest.java:43)

[INFO] 

Reproduction

Run the existing Fastjson2ConcurrentRefDeserializationTest in serializer/seata-serializer-fastjson2 and rm-datasource. Each test starts fresh JVMs, synchronizes 200 deserializing threads and checks for missing referenced fields. Increase -Dseata.fastjson2.concurrentRef.rounds=20 to exercise more cold starts.

Expected behavior

All references and shared-object identity must be preserved under concurrent decoding, including after reader warmup. Keep the regression tests strict; do not suppress the exception, skip the test or retry failed assertions until they pass.

Environment

Seata 2.8.0-SNAPSHOT / 2.x, fastjson2 2.0.52, GitHub Actions on JDK 8, 17 and 21.

Investigation update

FieldReader in fastjson2 2.0.52 caches JSONPath reference objects, and JSONReader.handleResolveTasks assigns reader/writer contexts before evaluating them. Pre-creating ObjectReaders does not serialize this runtime work. The proposed conservative mitigation is a shared lock covering complete Seata RPC/UndoLog JSONB parses, including deferred reference resolution; it does not change the wire format or loosen assertions.

Local Java 17 baseline validation (20 cold child JVMs per path, 200 threads per child, two parser instances) passed without reproducing the intermittent failure. The failing CI stacks above are the observed reproduction evidence. This distinction will be retained in the PR validation report.