Skip to content

Comments

Introduce support for liveness check for MySQL CDC listener#1428

Merged
gayaldassanayake merged 7 commits intoballerina-platform:masterfrom
ayeshLK:master
Feb 18, 2026
Merged

Introduce support for liveness check for MySQL CDC listener#1428
gayaldassanayake merged 7 commits intoballerina-platform:masterfrom
ayeshLK:master

Conversation

@ayeshLK
Copy link
Member

@ayeshLK ayeshLK commented Feb 14, 2026

Purpose

$subject

Part of: ballerina-platform/ballerina-library#8589

Checklist

  • Linked to an issue
  • Updated the specification
  • Updated the changelog
  • Added tests
  • Checked native-image compatibility

Summary

This pull request adds liveness-check support to the MySQL CDC listener to enable runtime health checks for CDC connections and improve listener reliability monitoring.

Key Changes

  • Listener configuration and behavior

    • Added liveness support by injecting a livenessInterval into the listener configuration and exposing it via the listener's readonly config.
    • Broadened the listener config type from map to map to accept livenessInterval and richer configuration values.
    • Refactored initialization to aggregate Debezium and MySQL settings into a shared config map (debeziumConfigs), build a listenerConfigs map that includes livenessInterval, and assign a cloned readonly config to the listener.
  • Tests

    • Added listener_liveness_test.bal with four tests covering liveness before start, after start, after graceful stop, and when no events are received within the configured liveness interval.
  • Dependency and packaging updates

    • Bumped package version to 1.16.2 and updated native artifact references (mysql-native and compiler plugin) to 1.16.2-SNAPSHOT.
    • Updated Dependencies.toml to add/refresh CDC-related ecosystem packages (including avro, confluent, kafka) and to update several stdlib and CDC package versions.
    • Updated gradle.properties to align stdlib and CDC version variables.

Impact

Applications and operators can now detect unresponsive MySQL CDC listeners via the liveness check. The configuration type change enables richer configuration values to be carried in the listener config. New tests validate the liveness behavior and dependency updates align native/tooling artifacts with these changes.

@coderabbitai
Copy link

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

Bumps package and native/plugin versions to 1.16.2, expands Dependencies.toml with new/updated packages (Avro, Confluent, Kafka, updated mysql and CDC entries), changes CdcListener config type from map to map and adds livenessInterval, and adds listener liveness tests.

Changes

Cohort / File(s) Summary
Version & build metadata
ballerina/Ballerina.toml, ballerina/CompilerPlugin.toml, gradle.properties
Package version bumped 1.16.1 → 1.16.2; native and compiler-plugin artifact paths updated to 1.16.2-SNAPSHOT; stdlibLogVersion and stdlibCdcVersion updated.
Dependency manifest
ballerina/Dependencies.toml
Added avro and several ballerinax packages (confluent.cavroserdes, confluent.cregistry, kafka, updated mysql to 1.16.2); many stdlib versions bumped; scope adjustments and CDC/Avro/Confluent dependency graph expanded.
CDC listener implementation
ballerina/cdc_listener.bal
Changed CdcListener.config from map<string> to map<anydata>; replaced configMap with debeziumConfigs, build listenerConfigs including livenessInterval, and assign self.config = listenerConfigs.cloneReadOnly().
Tests — listener liveness
ballerina/tests/listener_liveness_test.bal
Added four tests validating CDC listener liveness scenarios: before start, after start, after stop, and after idle timeout.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through manifests, jars in tow,
Swapped versions quick where snapshots grow,
I widened maps so liveness could play,
Wrote tests to watch the listener stay,
A happy rabbit — code's a-glow.

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (5 files):

⚔️ ballerina/Ballerina.toml (content)
⚔️ ballerina/CompilerPlugin.toml (content)
⚔️ ballerina/Dependencies.toml (content)
⚔️ ballerina/cdc_listener.bal (content)
⚔️ gradle.properties (content)

These conflicts must be resolved before merging into master.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: introducing liveness check support for the MySQL CDC listener, which aligns with the PR's core objective and file changes.
Description check ✅ Passed The description includes the required purpose section, links to the related issue, completes the checklist with appropriate items marked, and provides sufficient context for the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch master
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@ballerina/cdc_listener.bal`:
- Around line 22-24: The fields isStarted and hasAttachedService in the cdc
listener object are declared but never referenced; remove the unused boolean
fields isStarted and hasAttachedService from the object/record declaration in
cdc_listener.bal (the declarations "private boolean isStarted = false;" and
"private boolean hasAttachedService = false;") so the type no longer contains
dead fields, and run tests/compile to confirm no remaining references; no other
code changes are required if there are truly no usages.
🧹 Nitpick comments (2)
ballerina/tests/listener_liveness_test.bal (2)

85-103: Consider potential test flakiness due to timing dependency.

This test relies on runtime:sleep(10) exceeding the livenessInterval: 5.0 to trigger a liveness failure. In CI environments under load, timing-based tests can be flaky. Consider:

  1. Increasing the margin between sleep duration and interval (e.g., sleep 15s with 5s interval).
  2. Adding a retry mechanism or documenting the timing assumptions.

24-38: Consider adding cleanup in error scenarios.

If mysqlListener.attach fails, the test exits without cleanup. While this specific test doesn't call start(), establishing a pattern of using defer or try-finally for listener cleanup would improve robustness across all liveness tests.

Comment on lines +22 to 24
private final map<anydata> & readonly config;
private boolean isStarted = false;
private boolean hasAttachedService = false;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for usages of isStarted and hasAttachedService in .bal files
rg -n 'isStarted|hasAttachedService' --type-add 'bal:*.bal' --type bal

Repository: ballerina-platform/module-ballerinax-mysql

Length of output: 232


Remove unused fields isStarted and hasAttachedService.

These fields are declared at lines 23-24 but never used anywhere in the codebase. No assignments or references to these fields exist outside of their initial declarations, indicating they are dead code and should be removed.

🤖 Prompt for AI Agents
In `@ballerina/cdc_listener.bal` around lines 22 - 24, The fields isStarted and
hasAttachedService in the cdc listener object are declared but never referenced;
remove the unused boolean fields isStarted and hasAttachedService from the
object/record declaration in cdc_listener.bal (the declarations "private boolean
isStarted = false;" and "private boolean hasAttachedService = false;") so the
type no longer contains dead fields, and run tests/compile to confirm no
remaining references; no other code changes are required if there are truly no
usages.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@ballerina/Dependencies.toml`:
- Around line 52-56: Update gradle.properties so its stdlib module versions
exactly match Dependencies.toml: set crypto=2.10.1, data.jsondata=1.1.3,
http=2.14.9, jwt=2.15.1, mime=2.12.1, oauth2=2.14.1, os=1.10.1, time=2.8.0, and
url=2.6.1; also add the missing module entry present in Dependencies.toml that
uses version 1.5.1 (the module listed with 1.5.1 in Dependencies.toml) so every
module/version pair in Dependencies.toml has a corresponding entry in
gradle.properties (mysql can be left as-is at 1.16.2).

Comment on lines 52 to 56
[[package]]
org = "ballerina"
name = "crypto"
version = "2.9.0"
version = "2.10.1"
dependencies = [
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Compare stdlib versions between gradle.properties and Dependencies.toml.
echo "=== Searching for stdlib versions in gradle.properties ==="
rg -n 'stdlib(Crypto|DataJsonData|Http|Jwt|Mime|OAuth2|Observe|Os|Time|Url)Version' gradle.properties

echo ""
echo "=== Searching for stdlib module names and versions in Dependencies.toml ==="
rg -n -C1 'name = "(crypto|data.jsondata|http|jwt|mime|oauth2|observe|os|time|url)"' ballerina/Dependencies.toml

echo ""
echo "=== Checking mysql module version alignment ==="
rg -n 'name = "mysql"|version = "1\.16\.2"' ballerina/Dependencies.toml ballerina/Ballerina.toml

Repository: ballerina-platform/module-ballerinax-mysql

Length of output: 4933


Version misalignments detected between gradle.properties and Dependencies.toml.

All stdlib module versions in Dependencies.toml exceed those specified in gradle.properties:

  • crypto: 2.10.1 vs 2.9.0
  • data.jsondata: 1.1.3 vs 1.1.0
  • http: 2.14.9 vs 2.14.0
  • jwt: 2.15.1 vs 2.15.0
  • mime: 2.12.1 vs 2.12.0
  • oauth2: 2.14.1 vs 2.14.0
  • os: 1.10.1 vs 1.10.0
  • time: 2.8.0 vs 2.7.0
  • url: 2.6.1 vs 2.6.0

Additionally, observe (1.5.1) appears in Dependencies.toml but has no corresponding entry in gradle.properties. The mysql module is correctly aligned at 1.16.2 in both files. Update gradle.properties to match Dependencies.toml versions to prevent build conflicts.

🤖 Prompt for AI Agents
In `@ballerina/Dependencies.toml` around lines 52 - 56, Update gradle.properties
so its stdlib module versions exactly match Dependencies.toml: set
crypto=2.10.1, data.jsondata=1.1.3, http=2.14.9, jwt=2.15.1, mime=2.12.1,
oauth2=2.14.1, os=1.10.1, time=2.8.0, and url=2.6.1; also add the missing module
entry present in Dependencies.toml that uses version 1.5.1 (the module listed
with 1.5.1 in Dependencies.toml) so every module/version pair in
Dependencies.toml has a corresponding entry in gradle.properties (mysql can be
left as-is at 1.16.2).

@gayaldassanayake gayaldassanayake merged commit 439ed64 into ballerina-platform:master Feb 18, 2026
3 of 4 checks passed
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.

2 participants