Skip to content

Comments

Introduce support for liveness check for MSSQL CDC listener#1169

Closed
gayaldassanayake wants to merge 4 commits intoballerina-platform:mainfrom
gayaldassanayake:cdc-islive
Closed

Introduce support for liveness check for MSSQL CDC listener#1169
gayaldassanayake wants to merge 4 commits intoballerina-platform:mainfrom
gayaldassanayake:cdc-islive

Conversation

@gayaldassanayake
Copy link
Contributor

@gayaldassanayake gayaldassanayake commented Feb 17, 2026

Purpose

$ subject

Examples

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 MSSQL CDC listener and updates related dependencies and configuration so the listener can surface and use a liveness interval.

Changes

  • Implementation

    • CdcListener now stores a broader configuration map (map) and includes a livenessInterval entry in the listener configuration used at start time.
    • Internal Debezium configuration population was refactored to build a listenerConfigs map that is cloned read-only and passed to external lifecycle operations (attach/start/detach/gracefulStop/immediateStop). Public method signatures are unchanged.
  • Tests

    • Added ballerina/tests/listener_liveness_test.bal with four tests covering liveness behavior: before start, after start, after stop, and when no events arrive within the configured liveness interval.
  • Dependency and build updates

    • Bumped mssql module version from 1.16.2 → 1.16.3 and CDC stdlib from 1.0.2 → 1.2.0.
    • Updated native JAR references (mssql-native and mssql-compiler-plugin) to 1.16.3-SNAPSHOT artifacts.
    • Introduced avro and Confluent/Kafka-related package entries (confluent.cavroserdes, confluent.cregistry, kafka) and added corresponding Gradle public dependencies.
    • Bumped supporting library versions: crypto (2.9.3), data.jsondata (1.1.3), observe (1.5.1), time (2.8.0).
  • Configuration/manifest updates

    • Updated Ballerina.toml, CompilerPlugin.toml, Dependencies.toml, gradle.properties, and build.gradle to reflect the new versions and added packages.

Notes / Checklist

  • Public API signatures remain the same.
  • New unit tests added for liveness behavior.
  • Checklist items in the PR description remain unchecked: linked issue, spec update, changelog, native-image compatibility, and tests verification in CI.

@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

Bumped mssql from 1.16.2 → 1.16.3 and updated compiler plugin/JAR paths; expanded dependency graph by adding avro, confluent.cavroserdes, confluent.cregistry, kafka and upgrading multiple stdlib versions; relaxed several package scopes; changed internal CdcListener config typing and population; added liveness tests and Gradle dependency entries.

Changes

Cohort / File(s) Summary
MSSQL Version & Plugin
ballerina/Ballerina.toml, ballerina/CompilerPlugin.toml
Bumped mssql package from 1.16.21.16.3; updated platform/compiler plugin JAR paths to SNAPSHOT names.
Public Dependency Manifest
ballerina/Dependencies.toml, gradle.properties, build.gradle
Added packages: avro (1.2.0), ballerinax/confluent.cavroserdes (1.0.2), confluent.cregistry (0.4.3), kafka (4.6.3); upgraded crypto, data.jsondata, observe, time, cdc, and mssql; removed scope = "testOnly" from several packages; added new Gradle public dependencies and version properties.
CdcListener internal config change
ballerina/cdc_listener.bal
Broadened CdcListener config field type from map<string>map<anydata> & readonly; replaced internal configMap with debeziumConfigs and listenerConfigs, added livenessInterval into final exposed config.
New tests — liveness
ballerina/tests/listener_liveness_test.bal
Added four tests verifying listener liveness behavior (before start, while started, after stop, and no events within liveness interval).
Build config
build.gradle, gradle.properties
Added Kafka/Avro/Confluent-related dependencies to subprojects and introduced new version properties; bumped several existing dependency versions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I nibble versions, hop from old to new, 🐇
Avro crumbs and Kafka dew,
A listen grows more mean and keen,
Liveness checks — a tidy scene,
SNAPSHOT jars sparkle in my view ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete with a placeholder '$subject' in the Purpose section, missing examples, and all checklist items unchecked, indicating the PR description was not properly filled out. Replace '$subject' with a meaningful purpose statement, add concrete examples of the liveness check usage, and fill in the checklist items to document what was completed in this PR.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (6 files):

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

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main objective of the changeset: adding liveness check support for the MSSQL CDC listener.
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 cdc-islive
  • Post resolved changes as copyable diffs in a comment

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

🧹 Nitpick comments (1)
ballerina/Ballerina.toml (1)

15-19: Version declaration vs. SNAPSHOT path mismatch.

The declared version is 1.16.3 but the path references mssql-native-1.16.3-SNAPSHOT.jar. While this is a common pattern during development, ensure the path is updated to the release artifact (removing -SNAPSHOT) before merging to main or creating a release.

🔧 Path to update before release
 [[platform.java21.dependency]]
 groupId = "io.ballerina.stdlib"
 artifactId = "mssql-native"
 version = "1.16.3"
-path = "../native/build/libs/mssql-native-1.16.3-SNAPSHOT.jar"
+path = "../native/build/libs/mssql-native-1.16.3.jar"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ballerina/Ballerina.toml` around lines 15 - 19, The dependency block for
[[platform.java21.dependency]] declares version "1.16.3" but the local path
points to "mssql-native-1.16.3-SNAPSHOT.jar"; update the path in Ballerina.toml
to the release artifact (remove "-SNAPSHOT") so it matches the declared version
(e.g., change path to .../mssql-native-1.16.3.jar) before merging or releasing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ballerina/Ballerina.toml`:
- Line 4: The PR title references "MySQL CDC listener" but the change is in the
MSSQL (Microsoft SQL Server) module (see version = "1.16.3" in Ballerina.toml
and module context), so verify and correct the PR title and any related metadata
to reflect MSSQL if this is not a MySQL change; if the change truly targets
MySQL, update the module files to match or adjust the bumped file to the correct
module. Also check and update any changelog/commit messages and PR description
to consistently say "MSSQL CDC listener" (or the correct DB) so the title,
description, and files align.

---

Nitpick comments:
In `@ballerina/Ballerina.toml`:
- Around line 15-19: The dependency block for [[platform.java21.dependency]]
declares version "1.16.3" but the local path points to
"mssql-native-1.16.3-SNAPSHOT.jar"; update the path in Ballerina.toml to the
release artifact (remove "-SNAPSHOT") so it matches the declared version (e.g.,
change path to .../mssql-native-1.16.3.jar) before merging or releasing.

org = "ballerinax"
name = "mssql"
version = "1.16.2"
version = "1.16.3"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Version bump looks good, but verify PR title accuracy.

The version bump to 1.16.3 is consistent across all configuration files. However, the PR title mentions "MySQL CDC listener" while this is the MSSQL (Microsoft SQL Server) module. Please verify if the PR title is accurate or if it's a copy-paste error.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ballerina/Ballerina.toml` at line 4, The PR title references "MySQL CDC
listener" but the change is in the MSSQL (Microsoft SQL Server) module (see
version = "1.16.3" in Ballerina.toml and module context), so verify and correct
the PR title and any related metadata to reflect MSSQL if this is not a MySQL
change; if the change truly targets MySQL, update the module files to match or
adjust the bumped file to the correct module. Also check and update any
changelog/commit messages and PR description to consistently say "MSSQL CDC
listener" (or the correct DB) so the title, description, and files align.

@gayaldassanayake gayaldassanayake changed the title Introduce support for liveness check for MySQL CDC listener Introduce support for liveness check for MSSQL CDC listener Feb 17, 2026
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

🧹 Nitpick comments (2)
ballerina/tests/listener_liveness_test.bal (2)

88-107: Test may be flaky depending on CDC event timing.

This test relies on runtime:sleep(10) being sufficient for the liveness interval (5.0 seconds) to expire without receiving events. If the test database generates CDC events (e.g., from other tests or background processes), this test could intermittently fail. Consider:

  1. Using a dedicated isolated database/table for this test
  2. Adding a test dependency to ensure it runs after other CDC tests complete
  3. Documenting the environmental requirements for this test
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ballerina/tests/listener_liveness_test.bal` around lines 88 - 107, The test
testLivenessWithoutReceivingEvents is flaky because runtime:sleep(10) may not
guarantee no CDC events arrive within livenessInterval (5.0); fix by isolating
the test's CDC input and adding a deterministic setup/teardown: create and use a
dedicated temporary database/table (or unique cdcDatabase) before constructing
the CdcListener (refer to CdcListener, livenessInterval, mssqlListener) and
ensure the table is empty/disabled for writers, or add a test
dependency/ordering to run after other CDC tests; alternatively increase the
sleep to livenessInterval + safety margin and/or explicitly purge/verify no
pending CDC events before calling cdc:isLive to make the assertion stable.

24-39: Consider adding cleanup for consistency.

Unlike other test functions that call gracefulStop(), this test doesn't clean up the listener. While the listener wasn't started, for consistency and to avoid potential resource leaks (e.g., if attach allocates resources), consider adding a cleanup step.

🔧 Suggested fix
     check mssqlListener.attach(testService);
     boolean liveness = check cdc:isLive(mssqlListener);
     test:assertFalse(liveness, "Liveness check passes even before listener starts");
+    check mssqlListener.gracefulStop();
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ballerina/tests/listener_liveness_test.bal` around lines 24 - 39, The test
testLivenessBeforeListenerStart creates a CdcListener instance (mssqlListener)
and calls attach but never performs cleanup; add a cleanup step that calls the
listener's gracefulStop (e.g., invoke gracefulStop on mssqlListener) after the
liveness assertion so resources from attach are released—ensure the call is
awaited/checked (use check or handle the returned error) to match other tests'
cleanup behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@gradle.properties`:
- Line 33: The gradle property stdlibCdcVersion is set to a timestamped snapshot
value (`1.2.0-20260213-180200-2268a4d`); change the value of stdlibCdcVersion to
the corresponding stable release (e.g., `1.2.0`) in gradle.properties before
merging so the build uses a released artifact instead of a timestamped/dev
snapshot.

---

Nitpick comments:
In `@ballerina/tests/listener_liveness_test.bal`:
- Around line 88-107: The test testLivenessWithoutReceivingEvents is flaky
because runtime:sleep(10) may not guarantee no CDC events arrive within
livenessInterval (5.0); fix by isolating the test's CDC input and adding a
deterministic setup/teardown: create and use a dedicated temporary
database/table (or unique cdcDatabase) before constructing the CdcListener
(refer to CdcListener, livenessInterval, mssqlListener) and ensure the table is
empty/disabled for writers, or add a test dependency/ordering to run after other
CDC tests; alternatively increase the sleep to livenessInterval + safety margin
and/or explicitly purge/verify no pending CDC events before calling cdc:isLive
to make the assertion stable.
- Around line 24-39: The test testLivenessBeforeListenerStart creates a
CdcListener instance (mssqlListener) and calls attach but never performs
cleanup; add a cleanup step that calls the listener's gracefulStop (e.g., invoke
gracefulStop on mssqlListener) after the liveness assertion so resources from
attach are released—ensure the call is awaited/checked (use check or handle the
returned error) to match other tests' cleanup behavior.

observeInternalVersion=1.5.0

stdlibCdcVersion=1.0.2
stdlibCdcVersion=1.2.0-20260213-180200-2268a4d
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Snapshot/timestamped version detected.

stdlibCdcVersion=1.2.0-20260213-180200-2268a4d appears to be a timestamped development build rather than a stable release version. This is acceptable during development but should be updated to a stable release version (e.g., 1.2.0) before merging to main.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@gradle.properties` at line 33, The gradle property stdlibCdcVersion is set to
a timestamped snapshot value (`1.2.0-20260213-180200-2268a4d`); change the value
of stdlibCdcVersion to the corresponding stable release (e.g., `1.2.0`) in
gradle.properties before merging so the build uses a released artifact instead
of a timestamped/dev snapshot.

@gayaldassanayake
Copy link
Contributor Author

Closing because duplicate

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