Skip to content

Conversation

maple525866
Copy link
Contributor

@maple525866 maple525866 commented Sep 27, 2025

Ⅰ. Describe what this PR did

1. Problem Background
When the database is PostgreSQL, the table contains an array type.
When using Seata AT mode, a JSON deserialization exception is thrown when a service failure triggers a global transaction rollback.

2. Problem Analysis

  • Seata Array Handling Mechanism:

    • PostgreSQL array fields are encapsulated as org.apache.seata.rm.datasource.sql.serial.SerialArray objects.
    • This object contains baseType, baseTypeName, and elements fields.
  • Jackson Serialization Configuration:

    • The JacksonUndoLogParser has enableDefaultTyping enabled for type information processing.
    • However, there are no dedicated serializers and deserializers for the SerialArray type.
  • Deserialization Conflict:

    • Jackson attempts to deserialize the JSON array directly into the java.lang.Long type.
    • This results in a type mismatch exception.

3. Solution:

  • Add dedicated SerialArray serializers and deserializers to JacksonUndoLogParser to ensure:
  • Correct JSON structure: Serialize SerialArrays into a clear object structure.
  • Type information compatibility: Support Jackson's enableDefaultTyping mechanism.
  • Null value handling: Correctly handle null elements in arrays.

Ⅱ. Does this pull request fix one issue?

fixes #7661

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

testSerializeAndDeserializeSerialArray()

  • Purpose: Verify serialization/deserialization of a valid array
  • Data: [1L, 2L, 3L, 4L, 5L]
  • Verify: All fields match exactly

testSerializeAndDeserializeSerialArrayWithNulls()

  • Purpose: Verify handling of arrays containing null elements
  • Data: [1L, null, 3L]
  • Verify: Null values ​​are correctly preserved

mvn clean test

Ⅴ. Special notes for reviews

ps: I also changed the access modifier of DmdbTimestampDeserializer to private.❤️

Copy link

codecov bot commented Sep 27, 2025

Codecov Report

❌ Patch coverage is 63.79310% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.25%. Comparing base (a977730) to head (5bbe847).
⚠️ Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...m/datasource/undo/parser/JacksonUndoLogParser.java 63.79% 16 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7669      +/-   ##
============================================
- Coverage     61.40%   61.25%   -0.15%     
  Complexity      666      666              
============================================
  Files          1314     1314              
  Lines         49760    49817      +57     
  Branches       5849     5858       +9     
============================================
- Hits          30553    30514      -39     
- Misses        16474    16561      +87     
- Partials       2733     2742       +9     
Files with missing lines Coverage Δ
...m/datasource/undo/parser/JacksonUndoLogParser.java 68.77% <63.79%> (-1.64%) ⬇️

... and 14 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@slievrly slievrly changed the title feature: add support for Jackson serialization and deserialization of PostgreSQL array types optimize: add support for Jackson serialization and deserialization of PostgreSQL array types Sep 29, 2025
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

LGTM

@slievrly slievrly merged commit 55bd893 into apache:2.x Sep 29, 2025
13 of 14 checks passed
@slievrly slievrly added this to the 2.6.0 milestone Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postgres with array type field can not rollback in seata AT mode, json deserialize exception
3 participants