Skip to content

Add optional GTID tracking from OK packets - #6035

Open
renecannao wants to merge 20 commits into
v3.0from
feature/gtid-from-ok-packets
Open

Add optional GTID tracking from OK packets#6035
renecannao wants to merge 20 commits into
v3.0from
feature/gtid-from-ok-packets

Conversation

@renecannao

@renecannao renecannao commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the opt-in mysql-update_gtid_from_ok variable, disabled by default and synchronized through ProxySQL Cluster
  • update an endpoint's GTID state only when a successful MySQL OK packet actually contains a tracked GTID
  • share endpoint GTID state across hostgroups and allow gtid_exists() to consult records whose binlog reader is inactive
  • synchronize concurrent GTID updates and stats snapshots, and close failed binlog-reader sockets before retrying

Motivation

A MySQL endpoint can appear in both writer and reader hostgroups. Writes may reach it through the writer hostgroup while min_gtid routing evaluates the same endpoint in the reader hostgroup. GTIDs learned from OK packets therefore need endpoint-wide visibility rather than hostgroup-local visibility.

This implements the behavior discussed in #5983.

Behavioral contract

  • ProxySQL never enables session_track_gtids=OWN_GTID for this feature.
  • GTID state is updated only when the client/backend session already returns a GTID in an OK packet.
  • OK packets without a GTID do not change state.
  • Binlog-reader and OK-packet updates converge on the same exact hostname/MySQL-port record.
  • Existing binlog-reader semantics remain the authoritative active update path; no freshness window or GTID inference is introduced.

Validation

  • release and debug builds
  • GTID unit suites: 109/109, 67/67, and 48/48
  • test_gtid_from_ok-t on MySQL 5.7 binlog infrastructure: 14/14
  • test_gtid_from_ok-t on MySQL 8.4 infrastructure: 14/14
  • neighboring binlog-reader test: 3/3
  • GTID forwarding regression: 3000/3000
  • ProxySQL Cluster synchronization regression: 399/399
  • concurrent snapshot and failed-reader file-descriptor regression coverage
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added optional tracking of GTIDs received in MySQL OK responses, disabled by default.
    • GTID state is shared across hostgroup endpoint copies, including inactive readers.
    • Improved consistency of GTID statistics and causal-read behavior.
  • Bug Fixes

    • Improved connection cleanup and concurrent GTID state handling.
    • Strengthened validation and synchronization of GTID updates.
  • Tests

    • Added coverage for OK-response GTIDs, validation, synchronization, inactive readers, and concurrent snapshots.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds configurable, validated GTID ingestion from MySQL OK responses. It propagates the setting through sessions and hostgroup management. Read-write locking and snapshots protect GTID state. Unit and integration tests cover propagation, inactive endpoints, cleanup, concurrency, and causal reads.

Changes

GTID OK-response ingestion

Layer / File(s) Summary
Thread-safe GTID state
include/GTID_Server_Data.h, lib/GTID_Server_Data.cpp
GTID_Server_Data validates and merges OK-response GTIDs. Read-write locking protects updates and snapshots. Connection failure paths close sockets.
Manager and configuration wiring
include/MySQL_HostGroups_Manager.h, include/MySQL_Thread.h, include/proxysql_structs.h, lib/MySQL_HostGroups_Manager.cpp, lib/MySQL_Thread.cpp, lib/MySQL_Session.cpp
The update_gtid_from_ok setting reaches worker sessions. Hostgroup management updates inactive endpoints, controls reader startup, and uses snapshots for metrics and statistics.
GTID state and concurrency validation
test/tap/tests/unit/gtid_server_data_unit-t.cpp
Unit tests cover direct updates, inactive endpoints, invalid input, merging, manager lookup, socket cleanup, and concurrent snapshots.
OK-response integration coverage
test/tap/tests/test_gtid_from_ok-t.cpp, test/tap/tests/Makefile, test/tap/groups/groups.json, test/tap/tests/proxysql_reference_select_config_file.cnf, test/tap/tests/test_cluster_sync-t.cpp
Integration coverage verifies configuration, tracked and untracked sessions, endpoint statistics, and causal reads through an inactive reader.
GTID cleanup design documentation
docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md, docs/superpowers/specs/2026-08-11-gtid-sonar-cleanup-design.md
The documents describe planned GTID cleanup work, ownership handling, test decomposition, behavior constraints, and verification steps.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MySQL_Session
  participant MySQL_HostGroups_Manager
  participant GTID_Server_Data
  participant Reader_Endpoint
  MySQL_Session->>MySQL_HostGroups_Manager: update_gtid_from_ok(mysrvc, gtid)
  MySQL_HostGroups_Manager->>GTID_Server_Data: add_gtid_from_ok(gtid)
  GTID_Server_Data-->>MySQL_HostGroups_Manager: return update status
  MySQL_HostGroups_Manager->>Reader_Endpoint: expose updated GTID state
  Reader_Endpoint-->>MySQL_Session: process causal read
Loading

Possibly related issues

  • Issue 5983: The change adds configurable GTID updates from MySQL OK packets.

Possibly related PRs

  • sysown/proxysql#5427: Both changes modify GTID parsing and state management in GTID_Server_Data.
  • sysown/proxysql#5557: Both changes modify GTID merging and executed-state serialization in GTID_Server_Data.

Poem

A rabbit merges GTIDs bright,
With locks that keep each snapshot right.
OK packets mark the trail,
Readers follow without fail.
Tests check each hop and turn,
While tidy sockets safely return.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.16% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: optional GTID tracking from MySQL OK packets.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/gtid-from-ok-packets

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.

Comment thread lib/GTID_Server_Data.cpp
Comment thread lib/GTID_Server_Data.cpp
Comment thread lib/MySQL_HostGroups_Manager.cpp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/tap/tests/unit/gtid_server_data_unit-t.cpp`:
- Around line 506-515: Update the reader thread in the concurrent snapshot test
to capture and count one initial snapshot before calling start.store(). Reuse
the existing snapshot coherence check for this initial capture, then retain the
current sampling loop afterward so the reader always records more than one
snapshot.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5e3e04b8-4ce6-4d77-9361-24b8fcbe9c40

📥 Commits

Reviewing files that changed from the base of the PR and between 7b0d92f and bb7ae79.

📒 Files selected for processing (14)
  • include/GTID_Server_Data.h
  • include/MySQL_HostGroups_Manager.h
  • include/MySQL_Thread.h
  • include/proxysql_structs.h
  • lib/GTID_Server_Data.cpp
  • lib/MySQL_HostGroups_Manager.cpp
  • lib/MySQL_Session.cpp
  • lib/MySQL_Thread.cpp
  • test/tap/groups/groups.json
  • test/tap/tests/Makefile
  • test/tap/tests/proxysql_reference_select_config_file.cnf
  • test/tap/tests/test_cluster_sync-t.cpp
  • test/tap/tests/test_gtid_from_ok-t.cpp
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Gitar
🧰 Additional context used
📓 Path-based instructions (4)
include/**/*.h

📄 CodeRabbit inference engine (CLAUDE.md)

Header include guards use the #ifndef __CLASS_*_H convention.

Files:

  • include/MySQL_Thread.h
  • include/MySQL_HostGroups_Manager.h
  • include/proxysql_structs.h
  • include/GTID_Server_Data.h
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names must use PascalCase with protocol prefixes such as MySQL_, PgSQL_, and ProxySQL_.
Member variables must use snake_case.
Constants and macros must use UPPER_SNAKE_CASE.
Use C++17, and gate conditional code with #ifdef PROXYSQL31, #ifdef PROXYSQL40, #ifdef PROXYSQLFFTO, #ifdef PROXYSQLTSDB, and #ifdef PROXYSQLCLICKHOUSE; PROXYSQLGENAI must not guard core code outside plugins/genai/.
Consider performance implications when changing hot paths or other performance-critical code.
Use RAII for resource management and jemalloc for allocation.
Use pthread mutexes for synchronization and std::atomic<> for counters.

Files:

  • include/MySQL_Thread.h
  • lib/MySQL_Thread.cpp
  • test/tap/tests/test_cluster_sync-t.cpp
  • include/MySQL_HostGroups_Manager.h
  • include/proxysql_structs.h
  • test/tap/tests/test_gtid_from_ok-t.cpp
  • lib/MySQL_Session.cpp
  • include/GTID_Server_Data.h
  • lib/MySQL_HostGroups_Manager.cpp
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
  • lib/GTID_Server_Data.cpp
test/tap/tests/**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

test/tap/tests/**/*.cpp: Test files in test/tap/tests/ must follow the naming pattern test_*.cpp or *-t.cpp.
To add a new TAP test, add the <testname>-t.cpp file and register it in test/tap/tests/Makefile/groups.json; no special Makefile target is needed because make <testname>-t is generated by pattern rule.

Files:

  • test/tap/tests/test_cluster_sync-t.cpp
  • test/tap/tests/test_gtid_from_ok-t.cpp
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
test/tap/tests/unit/**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in test/tap/tests/unit/ must use test_globals.h and test_init.h with the custom unit-test harness.

Files:

  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
🧠 Learnings (2)
📚 Learning: 2026-01-20T09:34:19.124Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:19.124Z
Learning: In ProxySQL's TAP test suite, resource leaks (e.g., not calling mysql_close() on early return paths) are commonly tolerated because test processes are short-lived and OS frees resources on exit. This pattern applies to all C++ test files under test/tap/tests. When reviewing, recognize this as a project-wide test convention and focus on test correctness and isolation rather than insisting on fixing such leaks in these test files.

Applied to files:

  • test/tap/tests/test_cluster_sync-t.cpp
  • test/tap/tests/test_gtid_from_ok-t.cpp
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
📚 Learning: 2026-04-01T21:27:00.297Z
Learnt from: wazir-ahmed
Repo: sysown/proxysql PR: 5557
File: test/tap/tests/unit/gtid_set_unit-t.cpp:14-17
Timestamp: 2026-04-01T21:27:00.297Z
Learning: In ProxySQL unit tests under test/tap/tests/unit/, include test_globals.h and test_init.h only for tests that depend on ProxySQL runtime globals/initialization (i.e., tests that exercise components linked against libproxysql.a). For “pure” data-structure/utility tests (e.g., ezoption_parser_unit-t.cpp, gtid_set_unit-t.cpp, gtid_trxid_interval_unit-t.cpp) that do not require runtime globals/initialization, it is correct to omit test_globals.h and test_init.h and instead include only tap.h plus the relevant project header(s).

Applied to files:

  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
🪛 ast-grep (0.45.1)
lib/MySQL_HostGroups_Manager.cpp

[error] 5814-5814: Use of an unbounded buffer function that can overflow the destination; use a size-bounded equivalent (fgets, strncpy/strlcpy, strncat/strlcat, snprintf).
Context: sprintf(buf,"%llu", snapshot.events_read)
Note: [CWE-120] Buffer Copy without Checking Size of Input ('Classic Buffer Overflow').

(dangerous-buffer-functions-cpp)

🔇 Additional comments (18)
include/GTID_Server_Data.h (1)

6-13: LGTM!

Also applies to: 38-45

lib/GTID_Server_Data.cpp (1)

4-8: LGTM!

Also applies to: 180-184, 202-202, 218-218, 230-230, 283-329, 377-385, 446-446, 516-521

include/MySQL_HostGroups_Manager.h (1)

1240-1240: LGTM!

test/tap/tests/unit/gtid_server_data_unit-t.cpp (1)

17-28: LGTM!

Also applies to: 348-460, 462-504, 517-554

test/tap/tests/Makefile (1)

311-312: LGTM!

test/tap/tests/proxysql_reference_select_config_file.cnf (1)

85-85: LGTM!

test/tap/tests/test_cluster_sync-t.cpp (1)

2476-2476: LGTM!

include/MySQL_Thread.h (1)

655-655: LGTM!

include/proxysql_structs.h (1)

1392-1392: LGTM!

Also applies to: 1748-1748

lib/MySQL_Thread.cpp (1)

508-508: LGTM!

Also applies to: 1443-1443, 2650-2650, 4936-4936

lib/MySQL_HostGroups_Manager.cpp (3)

5784-5786: LGTM!

Also applies to: 5813-5815


1689-1726: 🩺 Stability & Availability

No locking issue in GTID_Server_Data. gtid_exists acquires executed_rwlock in read mode, and add_gtid_from_ok acquires it in write mode.

			> Likely an incorrect or invalid review comment.

1783-1800: 🩺 Stability & Availability

No watcher leak occurs on reactivation. Failure paths stop, close, free, and clear sd->w before the inactive entry can be retried.

			> Likely an incorrect or invalid review comment.
lib/MySQL_Session.cpp (1)

5776-5786: LGTM!

test/tap/tests/test_gtid_from_ok-t.cpp (3)

34-334: LGTM!


336-663: LGTM!


1-5: 📐 Maintainability & Code Quality

No Makefile change is required. test/tap/tests/Makefile registers test_gtid_from_ok-t, and test/tap/groups/groups.json also includes it.

			> Likely an incorrect or invalid review comment.
test/tap/groups/groups.json (1)

389-389: LGTM!

Comment thread test/tap/tests/unit/gtid_server_data_unit-t.cpp Outdated
@renecannao
renecannao marked this pull request as ready for review August 11, 2026 16:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb7ae79425

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread test/tap/tests/unit/gtid_server_data_unit-t.cpp

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 14 files

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread lib/MySQL_HostGroups_Manager.cpp
Comment thread lib/MySQL_HostGroups_Manager.cpp
Comment thread test/tap/tests/unit/gtid_server_data_unit-t.cpp Outdated
Comment thread test/tap/tests/test_gtid_from_ok-t.cpp Outdated
Comment thread test/tap/tests/unit/gtid_server_data_unit-t.cpp Outdated
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/GTID_Server_Data.cpp (1)

377-386: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Replace the manual unlock sites with an RAII write-lock guard.

The write lock is released at seven separate return points inside read_next_gtid(). The current paths are all correct, but the lock is held across malloc, strtok_r, free, and the whole message parse. Any future early return inside those branches deadlocks every gtid_exists() reader.

Use a scope guard so the unlock cannot be missed. The repository guidelines require RAII for resource management.

♻️ Proposed guard

Add a small helper near the top of the file:

namespace {
class RWLock_WrGuard {
public:
	explicit RWLock_WrGuard(pthread_rwlock_t& lock) : lock_(lock) { pthread_rwlock_wrlock(&lock_); }
	~RWLock_WrGuard() { pthread_rwlock_unlock(&lock_); }
	RWLock_WrGuard(const RWLock_WrGuard&) = delete;
	RWLock_WrGuard& operator=(const RWLock_WrGuard&) = delete;
private:
	pthread_rwlock_t& lock_;
};
} // namespace

Then simplify the entry and every exit:

 bool GTID_Server_Data::read_next_gtid() {
-	pthread_rwlock_wrlock(&executed_rwlock);
+	RWLock_WrGuard guard(executed_rwlock);
 	if (len==0) {
-		pthread_rwlock_unlock(&executed_rwlock);
 		return false;
 	}

Remove the remaining six pthread_rwlock_unlock(&executed_rwlock); calls in this function.

Also applies to: 454-454, 467-475, 536-540

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/GTID_Server_Data.cpp` around lines 377 - 386, Replace the manual lock
management in GTID_Server_Data::read_next_gtid() with a non-copyable RAII
write-lock guard defined near the top of the file. Have the guard acquire
executed_rwlock on construction and release it on destruction, then remove the
explicit pthread_rwlock_unlock calls and simplify the function entry while
preserving all existing return behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/GTID_Server_Data.cpp`:
- Around line 298-317: Normalize the UUID string in add_gtid_from_ok before
inserting it into gtid_executed: after removing hyphens and validating
hexadecimal content, fold every character to lowercase using std::tolower and
include the required cctype header. Keep validation and numeric GTID parsing
unchanged so both ingestion paths use the same lowercase key.

In `@test/tap/tests/test_gtid_from_ok-t.cpp`:
- Around line 7-24: Add the POSIX <strings.h> header to the include list in
test_gtid_from_ok-t.cpp so strcasecmp is declared before use; leave the existing
test logic unchanged.

---

Nitpick comments:
In `@lib/GTID_Server_Data.cpp`:
- Around line 377-386: Replace the manual lock management in
GTID_Server_Data::read_next_gtid() with a non-copyable RAII write-lock guard
defined near the top of the file. Have the guard acquire executed_rwlock on
construction and release it on destruction, then remove the explicit
pthread_rwlock_unlock calls and simplify the function entry while preserving all
existing return behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 458e5374-a765-4d1a-98a8-34769e582f99

📥 Commits

Reviewing files that changed from the base of the PR and between 7b0d92f and c854049.

📒 Files selected for processing (14)
  • include/GTID_Server_Data.h
  • include/MySQL_HostGroups_Manager.h
  • include/MySQL_Thread.h
  • include/proxysql_structs.h
  • lib/GTID_Server_Data.cpp
  • lib/MySQL_HostGroups_Manager.cpp
  • lib/MySQL_Session.cpp
  • lib/MySQL_Thread.cpp
  • test/tap/groups/groups.json
  • test/tap/tests/Makefile
  • test/tap/tests/proxysql_reference_select_config_file.cnf
  • test/tap/tests/test_cluster_sync-t.cpp
  • test/tap/tests/test_gtid_from_ok-t.cpp
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
🚧 Files skipped from review as they are similar to previous changes (11)
  • test/tap/tests/test_cluster_sync-t.cpp
  • include/MySQL_HostGroups_Manager.h
  • test/tap/groups/groups.json
  • test/tap/tests/Makefile
  • include/proxysql_structs.h
  • test/tap/tests/proxysql_reference_select_config_file.cnf
  • include/MySQL_Thread.h
  • lib/MySQL_Thread.cpp
  • include/GTID_Server_Data.h
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
  • lib/MySQL_HostGroups_Manager.cpp
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names must use PascalCase with protocol prefixes such as MySQL_, PgSQL_, and ProxySQL_.
Member variables must use snake_case.
Constants and macros must use UPPER_SNAKE_CASE.
Use C++17, and gate conditional code with #ifdef PROXYSQL31, #ifdef PROXYSQL40, #ifdef PROXYSQLFFTO, #ifdef PROXYSQLTSDB, and #ifdef PROXYSQLCLICKHOUSE; PROXYSQLGENAI must not guard core code outside plugins/genai/.
Consider performance implications when changing hot paths or other performance-critical code.
Use RAII for resource management and jemalloc for allocation.
Use pthread mutexes for synchronization and std::atomic<> for counters.

Files:

  • lib/MySQL_Session.cpp
  • test/tap/tests/test_gtid_from_ok-t.cpp
  • lib/GTID_Server_Data.cpp
test/tap/tests/**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

test/tap/tests/**/*.cpp: Test files in test/tap/tests/ must follow the naming pattern test_*.cpp or *-t.cpp.
To add a new TAP test, add the <testname>-t.cpp file and register it in test/tap/tests/Makefile/groups.json; no special Makefile target is needed because make <testname>-t is generated by pattern rule.

Files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
🧠 Learnings (1)
📚 Learning: 2026-01-20T09:34:19.124Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:19.124Z
Learning: In ProxySQL's TAP test suite, resource leaks (e.g., not calling mysql_close() on early return paths) are commonly tolerated because test processes are short-lived and OS frees resources on exit. This pattern applies to all C++ test files under test/tap/tests. When reviewing, recognize this as a project-wide test convention and focus on test correctness and isolation rather than insisting on fixing such leaks in these test files.

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
🔇 Additional comments (12)
lib/GTID_Server_Data.cpp (4)

4-7: LGTM!


179-201: LGTM!


217-217: LGTM!

Also applies to: 229-229


281-286: LGTM!

Also applies to: 322-331

lib/MySQL_Session.cpp (2)

5776-5778: LGTM!


8403-8410: LGTM!

test/tap/tests/test_gtid_from_ok-t.cpp (6)

35-105: LGTM!


107-221: LGTM!


223-353: LGTM!


355-651: LGTM!


655-682: LGTM!


1-5: 📐 Maintainability & Code Quality

No registration change is required. test_gtid_from_ok-t is listed in test/tap/tests/Makefile and test/tap/groups/groups.json.

Comment thread lib/GTID_Server_Data.cpp
Comment thread test/tap/tests/test_gtid_from_ok-t.cpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md`:
- Around line 330-335: Update the test sequence using the existing debug-build
flow so test/infra/control/start-proxysql-isolated.bash runs after the rebuilt
binary and before run-tests-isolated.bash; keep ensure-infras.bash as currently
ordered and recreate only the ProxySQL container without substituting docker
restart.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fee31d49-4e83-4e59-bc21-35b2ff60af69

📥 Commits

Reviewing files that changed from the base of the PR and between 1942519 and 122dd0d.

📒 Files selected for processing (8)
  • docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md
  • docs/superpowers/specs/2026-08-11-gtid-sonar-cleanup-design.md
  • include/MySQL_HostGroups_Manager.h
  • lib/GTID_Server_Data.cpp
  • lib/MySQL_HostGroups_Manager.cpp
  • lib/MySQL_Thread.cpp
  • test/tap/tests/test_gtid_from_ok-t.cpp
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
  • include/MySQL_HostGroups_Manager.h
  • lib/MySQL_Thread.cpp
  • test/tap/tests/unit/gtid_server_data_unit-t.cpp
  • lib/GTID_Server_Data.cpp
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Gitar
🧰 Additional context used
📓 Path-based instructions (2)
test/tap/tests/**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

test/tap/tests/**/*.cpp: Test files in test/tap/tests/ must follow the naming pattern test_*.cpp or *-t.cpp.
To add a new TAP test, add the <testname>-t.cpp file and register it in test/tap/tests/Makefile/groups.json; no special Makefile target is needed because make <testname>-t is generated by pattern rule.

Files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names must use PascalCase with protocol prefixes such as MySQL_, PgSQL_, and ProxySQL_.
Member variables must use snake_case.
Constants and macros must use UPPER_SNAKE_CASE.
Use C++17, and gate conditional code with #ifdef PROXYSQL31, #ifdef PROXYSQL40, #ifdef PROXYSQLFFTO, #ifdef PROXYSQLTSDB, and #ifdef PROXYSQLCLICKHOUSE; PROXYSQLGENAI must not guard core code outside plugins/genai/.
Consider performance implications when changing hot paths or other performance-critical code.
Use RAII for resource management and jemalloc for allocation.
Use pthread mutexes for synchronization and std::atomic<> for counters.

Files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
  • lib/MySQL_HostGroups_Manager.cpp
🧠 Learnings (18)
📓 Common learnings
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5548
File: lib/mysql_connection.cpp:1837-1843
Timestamp: 2026-03-26T16:39:02.446Z
Learning: In ProxySQL's lib/mysql_connection.cpp, `SHOW WARNINGS` detection for both `update_warning_count_from_connection()` and the `add_eof()` call in `ASYNC_USE_RESULT_CONT` intentionally uses `myds->sess->CurrentQuery.QueryParserArgs.digest_text` (comment-stripped digest text). This means the fix/feature does not work when `mysql-query_digests_keep_comment=1` (digest_text contains comments) or `mysql-query_digests=0` (digest_text is unavailable) — these configurations are explicitly excluded from the regression test for `reg_test_5306-show_warnings_with_comment-t`. This design is consistent across the codebase and is an accepted, documented limitation.
Learnt from: wazir-ahmed
Repo: sysown/proxysql PR: 5861
File: lib/ProxySQL_Cluster.cpp:2251-2255
Timestamp: 2026-07-13T08:29:05.757Z
Learning: In ProxySQL (lib/ProxySQL_Cluster.cpp and related cluster sync code), the MySQL server status value `SHUNNED_AWS_BGD` is runtime-only. Both `SHUNNED` and `SHUNNED_AWS_BGD` are normalized to `ONLINE` before being exposed/checksummed for cluster synchronization, so case-mismatched or unexpected status strings for these states are not expected to reach the `mysql_servers_v2` insert path (e.g., in `pull_mysql_servers_v2_from_peer`) during normal cluster sync operation.
Learnt from: peterlyoo
Repo: sysown/proxysql PR: 5925
File: lib/MySQL_Session.cpp:0-0
Timestamp: 2026-07-10T02:12:40.310Z
Learning: In lib/MySQL_Session.cpp, MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_qpo() has an early-return path for query cache hits (GloMyQC->get(...) keyed on client_myds->myconn->userinfo->hash) that occurs before the `__exit_set_destination_hostgroup` label. Any per-query session state mutation driven by qpo (e.g. qpo->destination_schema) that is placed after that label will be skipped entirely on a cache hit. The destination_schema switch (client_myds->myconn->userinfo->set_schemaname) is therefore applied right after the qpo->OK_msg/qpo->error_msg early-return checks (before the __exit_set_destination_hostgroup label and before the locked_on_hostgroup rejection check), not after the hostgroup-lock validation, specifically to avoid this cache-hit bypass. This placement was decided in PR `#5925` (commit 652ffa124) after discussion.
Learnt from: peterlyoo
Repo: sysown/proxysql PR: 5925
File: lib/MySQL_Session.cpp:0-0
Timestamp: 2026-07-10T02:12:40.310Z
Learning: In lib/MySQL_Session.cpp, mysql_query_rules.attributes.destination_schema (query-rule-driven session schema switching) is applied unconditionally, without the `transaction_persistent_hostgroup == -1` guard used for `destination_hostgroup`. This is intentional: switching a session's default schema mid-transaction via COM_INIT_DB has the same semantics as a client issuing `USE <schema>` mid-transaction through ProxySQL — it does not commit or invalidate the transaction and the sticky backend connection is preserved. Guarding on `transaction_persistent_hostgroup` was considered but rejected because it would make the destination_schema rule silently inert during an active transaction, which was judged more surprising than the current behavior.
📚 Learning: 2026-08-11T12:56:09.846Z
Learnt from: renecannao
Repo: sysown/proxysql PR: 6033
File: docs/superpowers/plans/2026-08-11-ed25519-authentication.md:469-469
Timestamp: 2026-08-11T12:56:09.846Z
Learning: In `docs/superpowers/plans/2026-08-11-ed25519-authentication.md`, the historical-artifact notice states that embedded expected outputs are plan-time values. Review-driven changes can modify the MariaDB Ed25519 implementation and TAP assertion counts after the plan is written. The shipped implementation and tests are authoritative, so reviewers must not require retroactive synchronization of plan-time expected outputs.

Applied to files:

  • docs/superpowers/specs/2026-08-11-gtid-sonar-cleanup-design.md
  • docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md
📚 Learning: 2026-04-11T13:17:55.508Z
Learnt from: renecannao
Repo: sysown/proxysql PR: 5607
File: doc/GH-Actions/README.md:13-18
Timestamp: 2026-04-11T13:17:55.508Z
Learning: When using GitHub-flavored Markdown headings, be aware that an em-dash surrounded by spaces (written as ` — `) affects the generated anchor/slug: GitHub replaces spaces with hyphens and removes non-alphanumeric punctuation, which can produce double hyphens (e.g., `## Foo — bar` → anchor `#foo--bar`, not `#foo-bar`). If you reference these anchors (e.g., internal links), ensure the expected slug matches this behavior.

Applied to files:

  • docs/superpowers/specs/2026-08-11-gtid-sonar-cleanup-design.md
  • docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md
📚 Learning: 2026-04-11T13:17:55.509Z
Learnt from: renecannao
Repo: sysown/proxysql PR: 5607
File: doc/GH-Actions/README.md:13-18
Timestamp: 2026-04-11T13:17:55.509Z
Learning: When reviewing GitHub-flavored Markdown links/anchors, remember that heading-to-anchor slug generation treats spaces as hyphens and removes punctuation. If a heading contains an em-dash surrounded by spaces (e.g. ` — `), the slugs can legitimately include a double hyphen where the two surrounding space-runs become `-` on either side of the removed em-dash (e.g. `...vocabulary--read...`). Do not flag double-hyphens in anchor links for em-dash-containing headings as errors; they reflect GitHub’s correct slug behavior.

Applied to files:

  • docs/superpowers/specs/2026-08-11-gtid-sonar-cleanup-design.md
  • docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md
📚 Learning: 2026-04-01T21:27:03.216Z
Learnt from: wazir-ahmed
Repo: sysown/proxysql PR: 5557
File: test/tap/tests/unit/gtid_set_unit-t.cpp:14-17
Timestamp: 2026-04-01T21:27:03.216Z
Learning: In ProxySQL's unit test directory (test/tap/tests/unit/), test_globals.h and test_init.h are only required for tests that depend on the ProxySQL runtime globals/initialization (i.e., tests that exercise components linked against libproxysql.a). Pure data-structure or utility tests (e.g., ezoption_parser_unit-t.cpp, gtid_set_unit-t.cpp, gtid_trxid_interval_unit-t.cpp) only need tap.h and the relevant project header — omitting test_globals.h and test_init.h is correct and intentional in these cases.

Applied to files:

  • docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md
  • test/tap/tests/test_gtid_from_ok-t.cpp
📚 Learning: 2026-07-08T13:19:04.649Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-07-08T13:19:04.649Z
Learning: When swapping in a rebuilt proxysql binary, rerun `test/infra/control/start-proxysql-isolated.bash` to recreate only the ProxySQL container; do not rely on `ensure-infras.bash` or `docker restart` to pick up the new binary.

Applied to files:

  • docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md
📚 Learning: 2026-01-20T09:34:19.124Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:19.124Z
Learning: In ProxySQL's TAP test suite, resource leaks (e.g., not calling mysql_close() on early return paths) are commonly tolerated because test processes are short-lived and OS frees resources on exit. This pattern applies to all C++ test files under test/tap/tests. When reviewing, recognize this as a project-wide test convention and focus on test correctness and isolation rather than insisting on fixing such leaks in these test files.

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
📚 Learning: 2026-07-08T13:19:04.649Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-07-08T13:19:04.649Z
Learning: Applies to test/tap/tests/**/*.cpp : To add a new TAP test, add the `<testname>-t.cpp` file and register it in `test/tap/tests/Makefile`/`groups.json`; no special Makefile target is needed because `make <testname>-t` is generated by pattern rule.

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
📚 Learning: 2026-07-08T13:19:04.649Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-07-08T13:19:04.649Z
Learning: The proxysql binary under test must be a DEBUG build when running the isolated TAP harness.

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
📚 Learning: 2026-02-13T09:29:39.713Z
Learnt from: wazir-ahmed
Repo: sysown/proxysql PR: 5372
File: test/tap/tap/mcp_client.cpp:355-385
Timestamp: 2026-02-13T09:29:39.713Z
Learning: In ProxySQL MCP implementation (test/tap/tap/mcp_client.cpp), the `check_server()` method uses the ping endpoint which is designed to work without authentication. The `ping` method at the `config` endpoint should not require the `Authorization: Bearer` header, unlike tool invocation endpoints which do require authentication when `auth_token_` is set.

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
📚 Learning: 2026-01-20T07:40:34.938Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:24-28
Timestamp: 2026-01-20T07:40:34.938Z
Learning: In ProxySQL test files, calling `mysql_error(NULL)` after `mysql_init()` failure is safe because the MariaDB client library implementation returns an empty string for NULL handles (not undefined behavior).

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
📚 Learning: 2026-03-26T16:39:02.446Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5548
File: lib/mysql_connection.cpp:1837-1843
Timestamp: 2026-03-26T16:39:02.446Z
Learning: In ProxySQL's lib/mysql_connection.cpp, `SHOW WARNINGS` detection for both `update_warning_count_from_connection()` and the `add_eof()` call in `ASYNC_USE_RESULT_CONT` intentionally uses `myds->sess->CurrentQuery.QueryParserArgs.digest_text` (comment-stripped digest text). This means the fix/feature does not work when `mysql-query_digests_keep_comment=1` (digest_text contains comments) or `mysql-query_digests=0` (digest_text is unavailable) — these configurations are explicitly excluded from the regression test for `reg_test_5306-show_warnings_with_comment-t`. This design is consistent across the codebase and is an accepted, documented limitation.

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
  • lib/MySQL_HostGroups_Manager.cpp
📚 Learning: 2026-07-08T13:19:04.649Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-07-08T13:19:04.649Z
Learning: Applies to **/*.{cpp,h,hpp} : Use C++17, and gate conditional code with `#ifdef PROXYSQL31`, `#ifdef PROXYSQL40`, `#ifdef PROXYSQLFFTO`, `#ifdef PROXYSQLTSDB`, and `#ifdef PROXYSQLCLICKHOUSE`; `PROXYSQLGENAI` must not guard core code outside `plugins/genai/`.

Applied to files:

  • test/tap/tests/test_gtid_from_ok-t.cpp
📚 Learning: 2026-07-22T14:10:08.098Z
Learnt from: burnison
Repo: sysown/proxysql PR: 5946
File: lib/MySQL_Thread.cpp:4483-4485
Timestamp: 2026-07-22T14:10:08.098Z
Learning: In `lib/MySQL_Thread.cpp`, `MySQL_Thread::ProcessAllSessions_Healthy0()` intentionally logs the live backend MySQL thread ID when `sess->mybe->server_myds->myconn` is attached; it logs `connection 0` when no backend is attached at unhealthy client-session close time. Do not require preserving a historical backend ID for that case.

Applied to files:

  • lib/MySQL_HostGroups_Manager.cpp
📚 Learning: 2026-07-13T08:29:05.757Z
Learnt from: wazir-ahmed
Repo: sysown/proxysql PR: 5861
File: lib/ProxySQL_Cluster.cpp:2251-2255
Timestamp: 2026-07-13T08:29:05.757Z
Learning: In ProxySQL (lib/ProxySQL_Cluster.cpp and related cluster sync code), the MySQL server status value `SHUNNED_AWS_BGD` is runtime-only. Both `SHUNNED` and `SHUNNED_AWS_BGD` are normalized to `ONLINE` before being exposed/checksummed for cluster synchronization, so case-mismatched or unexpected status strings for these states are not expected to reach the `mysql_servers_v2` insert path (e.g., in `pull_mysql_servers_v2_from_peer`) during normal cluster sync operation.

Applied to files:

  • lib/MySQL_HostGroups_Manager.cpp
📚 Learning: 2026-07-10T02:12:40.310Z
Learnt from: peterlyoo
Repo: sysown/proxysql PR: 5925
File: lib/MySQL_Session.cpp:0-0
Timestamp: 2026-07-10T02:12:40.310Z
Learning: In lib/MySQL_Session.cpp, MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_qpo() has an early-return path for query cache hits (GloMyQC->get(...) keyed on client_myds->myconn->userinfo->hash) that occurs before the `__exit_set_destination_hostgroup` label. Any per-query session state mutation driven by qpo (e.g. qpo->destination_schema) that is placed after that label will be skipped entirely on a cache hit. The destination_schema switch (client_myds->myconn->userinfo->set_schemaname) is therefore applied right after the qpo->OK_msg/qpo->error_msg early-return checks (before the __exit_set_destination_hostgroup label and before the locked_on_hostgroup rejection check), not after the hostgroup-lock validation, specifically to avoid this cache-hit bypass. This placement was decided in PR `#5925` (commit 652ffa124) after discussion.

Applied to files:

  • lib/MySQL_HostGroups_Manager.cpp
📚 Learning: 2026-07-22T21:24:52.599Z
Learnt from: burnison
Repo: sysown/proxysql PR: 5948
File: lib/MySQL_Session.cpp:6850-6850
Timestamp: 2026-07-22T21:24:52.599Z
Learning: In `include/MySQL_Thread.h`, `MySQL_Thread::status_variables.stvar` is intentionally per-worker-thread storage. Writers use non-atomic direct updates for hot-path counters, while `MySQL_Threads_Handler::get_status_variable()` in `lib/MySQL_Thread.cpp` aggregates values using `__sync_fetch_and_add(..., 0)`. New `stvar` counters should follow this established contract unless their ownership becomes cross-thread.

Applied to files:

  • lib/MySQL_HostGroups_Manager.cpp
📚 Learning: 2026-07-10T02:12:40.310Z
Learnt from: peterlyoo
Repo: sysown/proxysql PR: 5925
File: lib/MySQL_Session.cpp:0-0
Timestamp: 2026-07-10T02:12:40.310Z
Learning: In lib/MySQL_Session.cpp, mysql_query_rules.attributes.destination_schema (query-rule-driven session schema switching) is applied unconditionally, without the `transaction_persistent_hostgroup == -1` guard used for `destination_hostgroup`. This is intentional: switching a session's default schema mid-transaction via COM_INIT_DB has the same semantics as a client issuing `USE <schema>` mid-transaction through ProxySQL — it does not commit or invalidate the transaction and the sticky backend connection is preserved. Guarding on `transaction_persistent_hostgroup` was considered but rejected because it would make the destination_schema rule silently inert during an active transaction, which was judged more surprising than the current behavior.

Applied to files:

  • lib/MySQL_HostGroups_Manager.cpp
🔇 Additional comments (7)
lib/MySQL_HostGroups_Manager.cpp (1)

1727-1744: LGTM!

Also applies to: 1746-1760, 1806-1814

test/tap/tests/test_gtid_from_ok-t.cpp (3)

18-18: LGTM!

Also applies to: 368-380, 382-416, 418-434, 436-461


463-511: LGTM!

Also applies to: 513-555


557-601: LGTM!

Also applies to: 603-650, 652-708, 710-724

docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md (2)

359-363: 📐 Maintainability & Code Quality

Stage the reviewed documents or state that they are already committed.

The commit command stages only source and test files. This review also contains docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md and docs/superpowers/specs/2026-08-11-gtid-sonar-cleanup-design.md. If these documents are part of the final change and are uncommitted, the command omits them.


1-329: LGTM!

Also applies to: 336-358, 364-401

docs/superpowers/specs/2026-08-11-gtid-sonar-cleanup-design.md (1)

1-37: LGTM!

Comment thread docs/superpowers/plans/2026-08-11-gtid-sonar-cleanup.md
@sonarqubecloud

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown
CI failed: Downstream CI-builds workflow runs failed, one encountering a TLS certificate verification error while communicating with the GitHub API and another failing during execution.

Overview

A total of 2 log failures were analyzed across jobs. The failures stem from a downstream CI-builds workflow run failing or encountering connectivity issues (TLS certificate verification failure for api.github.com), causing the parent workflow waiting via gh run watch to exit with status 1.

Failures

Downstream CI-Builds Workflow Failure and TLS Certificate Error (confidence: high)

  • Type: build
  • Affected jobs: 93863598422, 94027679107
  • Related to change: yes
  • Root cause: The triggered downstream workflow run failed during execution or experienced infrastructure-level TLS certificate verification errors when interacting with api.github.com via the GitHub CLI.
  • Suggested fix: Re-trigger the CI checks or inspect the specific failure logs of the downstream CI-builds workflow run in GitHub Actions to address any underlying build or network/runner issues.

Summary

  • Change-related failures: 2 failures related to downstream CI-builds workflow execution and API communication issues.
  • Infrastructure/flaky failures: 0 infrastructure-specific flaky test failures, though TLS certificate verification on api.github.com indicates a potential runner networking/environment glitch.
  • Recommended action: Re-run the failed workflows or check the downstream CI-builds run logs for compilation and test errors.
Code Review ✅ Approved 3 resolved / 3 findings

Adds optional GTID tracking from MySQL OK packets with cross-hostgroup endpoint sharing and cluster synchronization, addressing the hot-path string build, lock reentrancy, and UUID parsing findings.

✅ 3 resolved
Bug: to_string() called under read lock may not be reentrant

📄 lib/GTID_Server_Data.cpp:283-286 📄 lib/GTID_Server_Data.cpp:325-330
get_gtid_executed_snapshot()/gtid_exists() call GTID_Set::to_string() and has_gtid() while holding only a read lock (executed_rwlock), allowing concurrent execution across threads. These methods are declared non-const in proxysql_gtid.h; if either mutates internal state (e.g. a cached buffer), concurrent readers race. Verify these methods are truly read-only, or take a write lock in get_gtid_executed_snapshot().

Edge Case: add_gtid_from_ok only accepts a single uuid:trxid GTID

📄 lib/GTID_Server_Data.cpp:289-303
add_gtid_from_ok uses strrchr(':') and rejects anything that is not exactly ':'. A session_track GTID value containing multiple GTIDs (comma-separated) or a range (uuid:1-5) is silently dropped, so those endpoints never learn the GTID. This is acceptable for OWN_GTID single values but should be documented or handled if multi-GTID OK payloads are possible.

Performance: Per-OK-packet string build + lock in hot path

📄 lib/MySQL_HostGroups_Manager.cpp:1709-1723 📄 lib/MySQL_Session.cpp:5778-5780
When mysql-update_gtid_from_ok is enabled, every successful backend OK packet carrying a GTID builds an 'address:port' std::string and takes gtid_rwlock (read) plus executed_rwlock (write) for a map lookup. On high write throughput this adds allocation and lock contention to the query hot path. It is opt-in and default-off, so low severity, but consider caching the resolved GTID_Server_Data pointer on the connection/backend to avoid the repeated lookup.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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.

1 participant