Skip to content

fix: support RM delete undo log request#1023

Closed
everfid-ever wants to merge 9 commits intoapache:masterfrom
everfid-ever:fix/rm_undolog
Closed

fix: support RM delete undo log request#1023
everfid-ever wants to merge 9 commits intoapache:masterfrom
everfid-ever:fix/rm_undolog

Conversation

@everfid-ever
Copy link
Copy Markdown
Contributor

@everfid-ever everfid-ever commented Dec 6, 2025

Fixes #1016 Codec error when TC server sends UndoLogDeleteRequest (type 111)

What does this PR do?
This PR fixes a critical codec error that occurs when seata-go clients communicate with Seata TC server v1.8.0+. The TC server periodically sends UndoLogDeleteRequest messages (message type 111) to clean up old undo log records, but seata-go was missing the necessary codec and processor to handle these messages, causing the client to fail after 2-3 minutes of operation.

Problem: When seata-go clients run for approximately 2-3 minutes, they encounter codec errors because the TC server sends TYPE_RM_DELETE_UNDOLOG (type code 111) messages, but seata-go doesn't have a registered codec to decode this message type.

Impact: This causes seata-go clients to fail during normal operation with Seata TC server v1.8.0+, making the client unstable for production use.

What changes in this PR?

  1. Added UndoLogDeleteRequest message structure
  • File: pkg/protocol/message/request_message.go
  • Added UndoLogDeleteRequest struct with fields: ResourceId (string), SaveDays (int16), BranchType (BranchType)
  • Implemented GetTypeCode() method returning MessageTypeRmDeleteUndolog
  1. Implemented codec for UndoLogDeleteRequest
  • File: pkg/protocol/codec/undolog_delete_req_codec.go
  • Created UndoLogDeleteRequestCodec with Encode(), Decode(), and GetMessageType() methods
  • Properly handles serialization/deserialization of all fields including the int16 SaveDays field
  1. Registered codec in codec manager
  • File: pkg/protocol/codec/codec.go
  • Registered UndoLogDeleteRequestCodec in the Init() function
  1. Implemented message processor
  • File: pkg/remoting/processor/client/rm_delete_undolog_processor.go
  • Created rmDeleteUndoLogProcessor to handle incoming undo log delete requests
  • Added initDeleteUndoLog() function to register the processor
  • Currently logs the request (actual undo log deletion logic to be implemented later)
  1. Integrated processor registration
  • File: pkg/remoting/processor/client/init.go
  • Added initDeleteUndoLog() call to RegisterProcessor() function
  1. Comprehensive test coverage
  • Files: undolog_delete_req_codec_test.go, rm_delete_undolog_processor_test.go
  • Added unit tests for codec encode/decode functionality
  • Added integration tests for processor
  • Added edge case tests and benchmarks
  • Test coverage includes: normal cases, empty values, boundary values, and round-trip encoding/decoding

Copilot AI review requested due to automatic review settings December 6, 2025 12:17
@github-actions github-actions Bot added the bug Something isn't working label Dec 6, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.32%. Comparing base (b18bcb0) to head (237155f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1023      +/-   ##
==========================================
+ Coverage   56.49%   57.32%   +0.83%     
==========================================
  Files         266      268       +2     
  Lines       17484    17511      +27     
==========================================
+ Hits         9877    10038     +161     
+ Misses       6772     6637     -135     
- Partials      835      836       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for RM delete undo log requests, addressing issue #1016. The main fix corrects a type error in the UndoLogDeleteRequest structure where the SaveDays field was incorrectly defined as MessageType (an int type meant for message type codes) instead of int16 for representing the number of days.

Key changes:

  • Fixed SaveDays field type from MessageType to int16 in UndoLogDeleteRequest
  • Added processor implementation to handle undo log deletion requests from TC server
  • Added codec for encoding/decoding UndoLogDeleteRequest messages
  • Registered both processor and codec in initialization functions
  • Added comprehensive test coverage including edge cases, integration tests, and benchmarks

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/protocol/message/request_message.go Fixed SaveDays field type from MessageType to int16 in UndoLogDeleteRequest struct
pkg/protocol/codec/undolog_delete_req_codec.go Added codec for encoding/decoding undo log delete requests with proper serialization of ResourceId, SaveDays, and BranchType
pkg/protocol/codec/undolog_delete_req_codec_test.go Added comprehensive tests for codec including encoding/decoding, round-trip tests, edge cases, and benchmarks
pkg/protocol/codec/codec.go Registered UndoLogDeleteRequestCodec in the codec manager initialization
pkg/remoting/processor/client/rm_delete_undolog_processor.go Added processor to handle undo log delete requests with logging and placeholder for actual deletion logic
pkg/remoting/processor/client/rm_delete_undolog_processor_test.go Added comprehensive tests for processor including various branch types, edge cases, context handling, integration tests, and benchmarks
pkg/remoting/processor/client/init.go Added initDeleteUndoLog() call to register the delete undo log processor

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/protocol/codec/undolog_delete_req_codec.go Outdated
Comment thread pkg/protocol/codec/undolog_delete_req_codec.go Outdated
Comment thread pkg/remoting/processor/client/rm_delete_undolog_processor_test.go Outdated
Comment thread pkg/remoting/processor/client/rm_delete_undolog_processor_test.go Outdated
@everfid-ever everfid-ever reopened this Dec 7, 2025
Copy link
Copy Markdown
Contributor

@Code-Fight Code-Fight left a comment

Choose a reason for hiding this comment

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

Why is the issue link gone?

@everfid-ever
Copy link
Copy Markdown
Contributor Author

Why is the issue link gone?

The account that submitted the issue has been deleted.

@everfid-ever
Copy link
Copy Markdown
Contributor Author

Why is the issue link gone?

The account that submitted the issue has been deleted.

Could you please add an issue or explain in detail in the PR what functions have been implemented

already added

@everfid-ever
Copy link
Copy Markdown
Contributor Author

Plz fix the ci

Could you please help me check the integration test code? Thanks :)

@thunguo
Copy link
Copy Markdown
Contributor

thunguo commented Feb 28, 2026

Plz fix the CI problems.

@everfid-ever
Copy link
Copy Markdown
Contributor Author

Plz fix the CI problems.

I reopen a new PR, plz check the new one, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants