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

Add basic script to tombstone offset and reset connector #43

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

m-dwyer
Copy link
Contributor

@m-dwyer m-dwyer commented Aug 29, 2024

Context

Given engineers are likely to run debezium server against a long living local kafka cluster and may wish to republish outbox table data, it is desirable to provide a means to reset the connector so a topic can be repopulated.

Changes

Add a basic script to the debezium-server plugin that does the following:

  1. stop debezium server
  2. sends a tombstone to the offsets topic keyed on the internal topic prefix, effectively resetting the connector
  3. restart debezium server

Copy link
Contributor

@cultureamp-brucew cultureamp-brucew left a comment

Choose a reason for hiding this comment

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

LGTM and test it locally and it works.

Comment on lines +65 to +72
"devbox services stop debezium_server && \\",
"PID=$(ps aux | grep '[i]o.debezium.server.Main' | awk '{print $2}' | head -n 1) && \\",
"[ -n \"$PID\" ] && timeout=0; while ps -p $PID > /dev/null && [ $timeout -lt 10 ]; do echo 'Waiting for debezium server to stop..'; sleep 1; ((timeout++)); done && \\",
"echo \"Tombstoning connector offset\"",
"echo \"[\\\"kafka\\\",{\\\"server\\\":\\\"${FARM}.${INTERNAL_TOPIC_PREFIX}\\\"}]|\" | \\",
"kcat -P -Z -b ${KAFKA_BROKERS_SASL} -X sasl.mechanism=PLAIN -X sasl.username=${KAFKA_SASL_USER} -X sasl.password=${KAFKA_SASL_PASSWORD} -t ${OFFSET_TOPIC} -K \\| -p 0 && \\",
"echo \"Restarting debezium server\" && \\",
"devbox services start debezium_server"
Copy link
Contributor

Choose a reason for hiding this comment

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

Put all these inside a script like bin/reset_offset.sh might make it easier to read and edit. Also less error-prone since it doesn't need so many escapes

@m-dwyer m-dwyer marked this pull request as ready for review August 30, 2024 00:57
@m-dwyer m-dwyer merged commit 7da0ca3 into main Aug 30, 2024
8 checks passed
@m-dwyer m-dwyer deleted the reset-offset branch August 30, 2024 00:57
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