Skip to content

Permanent FF sessions + check_data_flow docs#5245

Merged
renecannao merged 2 commits intov3.0from
v3.0-issue5244
Dec 10, 2025
Merged

Permanent FF sessions + check_data_flow docs#5245
renecannao merged 2 commits intov3.0from
v3.0-issue5244

Conversation

@renecannao
Copy link
Contributor

@renecannao renecannao commented Dec 10, 2025

Features

  • Permanent fast-forward sessions: Skip bidirectional data check for permanent FF sessions (4044a40)
    • Allows uninterrupted operation for special session types
    • Maintains warning logging for monitoring

Documentation

  • Detailed Doxygen docs: Added for MySQL_Data_Stream::check_data_flow() (ec1247f)
    • Explains bidirectional data handling
    • Documents permanent fast-forward exception
    • Covers connection establishment logic

Closes #5244

Allow permanent fast-forward sessions (SESSION_FORWARD_TYPE_PERMANENT)
to continue processing when bidirectional data flow is detected,
instead of treating it as a fatal error. This prevents unnecessary
session termination in these specific cases while maintaining the
original strict validation for all other session types.
@gemini-code-assist
Copy link

Summary of Changes

Hello @renecannao, 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 introduces a crucial behavioral change for permanent fast-forward sessions, allowing them to maintain uninterrupted operation by gracefully handling bidirectional data flow with a warning instead of a fatal error. Concurrently, it significantly improves the clarity and maintainability of the codebase by adding detailed Doxygen documentation for the check_data_flow function, explaining its logic and various scenarios.

Highlights

  • Permanent Fast-Forward Sessions: Modified the check_data_flow() function to allow permanent fast-forward sessions to continue operation even when bidirectional data is detected. Instead of triggering a fatal error and shutdown, these sessions will now log a warning.
  • Enhanced Documentation: Added comprehensive Doxygen documentation to the MySQL_Data_Stream::check_data_flow() function. This new documentation details its functionality, explains bidirectional data handling, and clarifies the specific exception for permanent fast-forward sessions.
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.

@sonarqubecloud
Copy link

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 a special handling for permanent fast-forward sessions to allow bidirectional data flow, which is a useful feature for specific use cases. The implementation is correct, and it also fixes a pre-existing bug in the logging argument order. Additionally, the new Doxygen documentation for check_data_flow() is clear and greatly improves the code's understandability.

I have one suggestion to refactor the new logic slightly to improve readability and maintainability by extracting the condition into a boolean variable and deduplicating the log message format string.

Comment on lines 477 to 487
if ( (PSarrayIN->len || queue_data(queueIN) ) && ( PSarrayOUT->len || queue_data(queueOUT) ) ){
// there is data at both sides of the data stream: this is considered a fatal error
proxy_error("Session=%p, DataStream=%p -- Data at both ends of a MySQL data stream: IN <%d bytes %d packets> , OUT <%d bytes %d packets>\n", sess, this, PSarrayIN->len , queue_data(queueIN) , PSarrayOUT->len , queue_data(queueOUT));
shut_soft();
generate_coredump();
if (sess && sess->status == FAST_FORWARD && sess->session_fast_forward == SESSION_FORWARD_TYPE_PERMANENT) {
// Permanent fast-forward sessions: log warning but continue
proxy_warning("Session=%p, DataStream=%p -- Data at both ends of a MySQL data stream: IN <%d bytes %d packets> , OUT <%d bytes %d packets>\n", sess, this, queue_data(queueIN), PSarrayIN->len, queue_data(queueOUT), PSarrayOUT->len);
} else {
// All other sessions: treat as fatal error
proxy_error("Session=%p, DataStream=%p -- Data at both ends of a MySQL data stream: IN <%d bytes %d packets> , OUT <%d bytes %d packets>\n", sess, this, queue_data(queueIN), PSarrayIN->len, queue_data(queueOUT), PSarrayOUT->len);
shut_soft();
generate_coredump();
}
}

Choose a reason for hiding this comment

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

medium

The logic for handling permanent fast-forward sessions is correct. However, the implementation can be improved for better readability and maintainability.

  1. The condition to check for a permanent fast-forward session is a bit long and makes the if statement less readable. Extracting it into a boolean variable would clarify the intent.
  2. The format string for logging is duplicated in both the proxy_warning and proxy_error calls. This could lead to inconsistencies if one is updated and the other is not. It's better to define it as a constant.

Here is a suggested refactoring that addresses these points:

	if ( (PSarrayIN->len || queue_data(queueIN) ) && ( PSarrayOUT->len || queue_data(queueOUT) ) ){
		const bool is_permanent_ff = sess && sess->status == FAST_FORWARD && sess->session_fast_forward == SESSION_FORWARD_TYPE_PERMANENT;
		const char* BIDI_DATA_LOG_MSG = "Session=%p, DataStream=%p -- Data at both ends of a MySQL data stream: IN <%d bytes %d packets> , OUT <%d bytes %d packets>\n";

		if (is_permanent_ff) {
			// Permanent fast-forward sessions: log warning but continue
			proxy_warning(BIDI_DATA_LOG_MSG, sess, this, queue_data(queueIN), PSarrayIN->len, queue_data(queueOUT), PSarrayOUT->len);
		} else {
			// All other sessions: treat as fatal error
			proxy_error(BIDI_DATA_LOG_MSG, sess, this, queue_data(queueIN), PSarrayIN->len, queue_data(queueOUT), PSarrayOUT->len);
			shut_soft();
			generate_coredump();
		}
	}

@renecannao renecannao merged commit 87026c0 into v3.0 Dec 10, 2025
5 of 6 checks passed
@renecannao renecannao deleted the v3.0-issue5244 branch March 7, 2026 20:41
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.

Handle bidirectional data in permanent fast-forward sessions

1 participant