Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL Source Support CDC heartbeats #23376

Closed
wants to merge 19 commits into from

Conversation

VitaliiMaltsev
Copy link
Contributor

@VitaliiMaltsev VitaliiMaltsev commented Feb 23, 2023

What

Issue https://app.zenhub.com/workspaces/db--dw-source-connectors-6333360e0a41155061efbcbd/issues/gh/airbytehq/airbyte/23257

🚨 User Impact 🚨

Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

@subodh1810 subodh1810 changed the base branch from master to debezium-version-upgrade-2-1 February 23, 2023 12:29
subodh1810 and others added 6 commits February 23, 2023 18:01
# Conflicts:
#	airbyte-integrations/connectors/source-postgres/src/main/resources/spec.json
#	airbyte-integrations/connectors/source-postgres/src/test-integration/resources/expected_spec.json
#	airbyte-integrations/connectors/source-postgres/src/test-integration/resources/expected_strict_encrypt_spec.json
# Conflicts:
#	airbyte-integrations/bases/debezium/src/main/java/io/airbyte/integrations/debezium/internals/PostgresReplicationConnection.java
#	airbyte-integrations/connectors/source-postgres/src/test/java/io/airbyte/integrations/source/postgres/CdcPostgresSourceTest.java
@VitaliiMaltsev VitaliiMaltsev marked this pull request as ready for review February 24, 2023 14:14
@VitaliiMaltsev VitaliiMaltsev requested a review from a team as a code owner February 24, 2023 14:14
@github-actions
Copy link
Contributor

Affected Connector Report

NOTE ⚠️ Changes in this PR affect the following connectors. Make sure to do the following as needed:

  • Run integration tests
  • Bump connector or module version
  • Add changelog
  • Publish the new version

✅ Sources (8)

Connector Version Changelog Publish
source-alloydb 1.0.47
source-alloydb-strict-encrypt 1.0.47 🔵
(ignored)
🔵
(ignored)
source-mssql 0.4.28
source-mssql-strict-encrypt 0.4.28 🔵
(ignored)
🔵
(ignored)
source-mysql 1.0.21
source-mysql-strict-encrypt 1.0.21 🔵
(ignored)
🔵
(ignored)
source-postgres 1.0.48
source-postgres-strict-encrypt 1.0.48 🔵
(ignored)
🔵
(ignored)
  • See "Actionable Items" below for how to resolve warnings and errors.

✅ Destinations (0)

Connector Version Changelog Publish
  • See "Actionable Items" below for how to resolve warnings and errors.

✅ Other Modules (0)

Actionable Items

(click to expand)

Category Status Actionable Item
Version
mismatch
The version of the connector is different from its normal variant. Please bump the version of the connector.

doc not found
The connector does not seem to have a documentation file. This can be normal (e.g. basic connector like source-jdbc is not published or documented). Please double-check to make sure that it is not a bug.
Changelog
doc not found
The connector does not seem to have a documentation file. This can be normal (e.g. basic connector like source-jdbc is not published or documented). Please double-check to make sure that it is not a bug.

changelog missing
There is no chnagelog for the current version of the connector. If you are the author of the current version, please add a changelog.
Publish
not in seed
The connector is not in the seed file (e.g. source_definitions.yaml), so its publication status cannot be checked. This can be normal (e.g. some connectors are cloud-specific, and only listed in the cloud seed file). Please double-check to make sure that it is not a bug.

diff seed version
The connector exists in the seed file, but the latest version is not listed there. This usually means that the latest version is not published. Please use the /publish command to publish the latest version.

@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Feb 24, 2023

/test connector=connectors/source-mysql

🕑 connectors/source-mysql https://github.com/airbytehq/airbyte/actions/runs/4263269150
✅ connectors/source-mysql https://github.com/airbytehq/airbyte/actions/runs/4263269150
No Python unittests run

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/plugin.py:63: Skipping TestConnection.test_check: not found in the config.
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/plugin.py:63: Skipping TestDiscovery.test_discover: not found in the config.
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/plugin.py:63: Skipping TestBasicRead.test_read: not found in the config.
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/plugin.py:63: Skipping TestFullRefresh.test_sequential_reads: not found in the config.
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/plugin.py:63: Skipping TestIncremental.test_two_sequential_reads: not found in the config.
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:98: The previous and actual specifications are identical.
================= 19 passed, 6 skipped, 27 warnings in 16.57s ==================

@VitaliiMaltsev VitaliiMaltsev linked an issue Mar 1, 2023 that may be closed by this pull request
Copy link
Contributor

@subodh1810 subodh1810 left a comment

Choose a reason for hiding this comment

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

@VitaliiMaltsev please wait for my review as well. I want to carry out some tests on this PR

Base automatically changed from debezium-version-upgrade-2-1 to master March 7, 2023 12:42
@subodh1810 subodh1810 self-requested a review March 9, 2023 06:09
Copy link
Contributor

@subodh1810 subodh1810 left a comment

Choose a reason for hiding this comment

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

So there is a bug in the PR. A MySQL heartbeat event contains binlog filename and position in the file. We need to compare both in order to determine have we reached the target or not. But you are not extracting the filename and only extracting the position and using it for comparison.
Here is a sample heartbeat event

SourceRecord{sourcePartition={server=models_schema}, sourceOffset={transaction_id=null, ts_sec=1678344508, file=binlog.000002, pos=11149}} ConnectRecord{topic='__debezium-heartbeat.models_schema', kafkaPartition=0, key=Struct{serverName=models_schema}, keySchema=Schema{io.debezium.connector.common.ServerNameKey:STRUCT}, value=Struct{ts_ms=1678344508923}, valueSchema=Schema{io.debezium.connector.common.Heartbeat:STRUCT}, timestamp=null, headers=ConnectHeaders(headers=)}

As you can see the SourceRecord contains file=binlog.000002, pos=11149 . Both should be used for comparison.

Refer the method reachedTargetPosition in MySqlCdcTargetPosition on how we compare the filename and pos both to determine if we have reached target position or not. Similar thing would needed to be done

@subodh1810 subodh1810 requested a review from rodireich March 9, 2023 07:01
@VitaliiMaltsev
Copy link
Contributor Author

https://app.zenhub.com/workspaces/db--dw-source-connectors-6333360e0a41155061efbcbd/issues/gh/airbytehq/airbyte/23257

So there is a bug in the PR. A MySQL heartbeat event contains binlog filename and position in the file. We need to compare both in order to determine have we reached the target or not. But you are not extracting the filename and only extracting the position and using it for comparison. Here is a sample heartbeat event

SourceRecord{sourcePartition={server=models_schema}, sourceOffset={transaction_id=null, ts_sec=1678344508, file=binlog.000002, pos=11149}} ConnectRecord{topic='__debezium-heartbeat.models_schema', kafkaPartition=0, key=Struct{serverName=models_schema}, keySchema=Schema{io.debezium.connector.common.ServerNameKey:STRUCT}, value=Struct{ts_ms=1678344508923}, valueSchema=Schema{io.debezium.connector.common.Heartbeat:STRUCT}, timestamp=null, headers=ConnectHeaders(headers=)}

As you can see the SourceRecord contains file=binlog.000002, pos=11149 . Both should be used for comparison.

Refer the method reachedTargetPosition in MySqlCdcTargetPosition on how we compare the filename and pos both to determine if we have reached target position or not. Similar thing would needed to be done

@subodh1810 closing this PR in favor of #23984 due to numerous merge conflicts

@VitaliiMaltsev
Copy link
Contributor Author

See #23984

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CDC heartbeat to MySQL
5 participants