Skip to content

active-active: add failpoint to construct data loss, data redundant and lww violation scenarios#4215

Open
Leavrth wants to merge 2 commits intopingcap:feature/active-activefrom
Leavrth:active-active-failpoint
Open

active-active: add failpoint to construct data loss, data redundant and lww violation scenarios#4215
Leavrth wants to merge 2 commits intopingcap:feature/active-activefrom
Leavrth:active-active-failpoint

Conversation

@Leavrth
Copy link

@Leavrth Leavrth commented Feb 14, 2026

What problem does this PR solve?

Issue Number: close #xxx

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

None

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
@ti-chi-bot ti-chi-bot bot added first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. release-note-none Denotes a PR that doesn't merit a release note. labels Feb 14, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 14, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign flowbehappy for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Leavrth, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the testing capabilities for active-active replication scenarios by introducing several failpoints. These failpoints allow developers to deliberately inject data loss, data redundancy/mutation, and Last-Write-Wins (LWW) violations into the replication process. This is crucial for validating the robustness and consistency checking mechanisms of the system under various failure conditions, ensuring that the active-active setup behaves as expected when inconsistencies arise.

Highlights

  • Failpoint for Data Loss Simulation: Introduced a failpoint (cloudStorageSinkDropMessage) in the cloud storage sink writer to simulate data loss by conditionally dropping messages before they are written to data files. This allows testing scenarios where messages might be lost during replication.
  • Failpoint for Data Redundancy/Mutation Simulation: Added a failpoint (cloudStorageSinkMutateValue) and a helper function (mutateMessageValueForFailpoint) to the cloud storage sink writer. This failpoint mutates the last CSV field of a message's value, allowing the multi-cluster-consistency-checker to identify the original row as 'lost' and the mutated row as 'redundant', simulating data inconsistency.
  • Failpoint for LWW Violation Simulation: Implemented a failpoint (mysqlSinkBypassLWW) in the MySQL DML writer. This failpoint bypasses the Last-Write-Wins (LWW) UPSERT logic, forcing the system to use normal SQL (REPLACE INTO or plain INSERT). This creates a genuine LWW violation that can be observed flowing through the replication pipeline.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • downstreamadapter/sink/cloudstorage/writer.go
    • Added mutateMessageValueForFailpoint function to corrupt message values for testing.
    • Introduced cloudStorageSinkDropMessage failpoint to simulate data loss by dropping messages.
    • Added cloudStorageSinkMutateValue failpoint to simulate data inconsistency by mutating message values.
  • pkg/sink/mysql/mysql_writer_dml.go
    • Imported failpoint, log, and zap packages.
    • Added mysqlSinkBypassLWW failpoint to bypass LWW UPSERT logic and simulate LWW violations.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pingcap-cla-assistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 14, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several failpoints to simulate different failure scenarios in active-active replication, such as data loss, data redundancy, and LWW violations. The changes in pkg/sink/mysql/mysql_writer_dml.go correctly add a failpoint to bypass LWW logic. However, there's an issue in downstreamadapter/sink/cloudstorage/writer.go where the failpoint for dropping messages doesn't work as intended due to incorrect usage of failpoint.Continue(). I've left a specific comment with a suggestion for a fix.

Comment on lines +251 to +259
failpoint.Inject("cloudStorageSinkDropMessage", func() {
log.Warn("cloudStorageSinkDropMessage: dropping message to simulate data loss",
zap.Int("workerID", d.id),
zap.String("keyspace", d.changeFeedID.Keyspace()),
zap.Stringer("changefeed", d.changeFeedID.ID()),
zap.String("dataFilePath", dataFilePath))
callbacks = append(callbacks, msg.Callback)
failpoint.Continue()
})

Choose a reason for hiding this comment

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

high

failpoint.Continue() does not skip the current loop iteration as a continue statement would. Instead, it jumps to the statement immediately following the failpoint.Inject block. This means the message processing logic below will still execute, causing the message not to be dropped and its callback to be appended twice.

To correctly skip processing the current message, you should use failpoint.Goto("continueLoop") and add a continueLoop: label at the end of the for loop body.

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant