fix(deploy): delete Kafka outbox topics during full-reset

Old messages in Kafka topics were corrupting the sync because they contained
outdated data from previous resets. Now we delete the outbox topics during
full-reset to ensure clean re-sync.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-12 22:38:31 -08:00
parent 44f235b185
commit 5af39193e4
1 changed files with 13 additions and 1 deletions

View File

@ -927,7 +927,7 @@ full_reset() {
fi fi
done done
log_step "Step 4/18: Deleting Debezium outbox connectors..." log_step "Step 4/18: Deleting Debezium outbox connectors and Kafka topics..."
# Delete connectors BEFORE dropping databases to release replication slots # Delete connectors BEFORE dropping databases to release replication slots
local connectors=("auth-outbox-connector" "contribution-outbox-connector" "mining-outbox-connector" "trading-outbox-connector" "mining-wallet-outbox-connector") local connectors=("auth-outbox-connector" "contribution-outbox-connector" "mining-outbox-connector" "trading-outbox-connector" "mining-wallet-outbox-connector")
for connector in "${connectors[@]}"; do for connector in "${connectors[@]}"; do
@ -937,6 +937,18 @@ full_reset() {
log_info "Waiting 5 seconds for connectors to be fully removed..." log_info "Waiting 5 seconds for connectors to be fully removed..."
sleep 5 sleep 5
# Delete Kafka outbox topics to clear old messages
# This is critical: old messages in Kafka will corrupt the sync if not cleared
log_info "Deleting Kafka outbox topics to clear old messages..."
local outbox_topics=("cdc.auth.outbox" "cdc.contribution.outbox" "cdc.mining.outbox" "cdc.trading.outbox" "cdc.mining-wallet.outbox")
for topic in "${outbox_topics[@]}"; do
if docker exec "$KAFKA_CONTAINER" kafka-topics --bootstrap-server localhost:9092 --delete --topic "$topic" 2>/dev/null; then
log_success "Deleted Kafka topic: $topic"
else
log_warn "Could not delete Kafka topic: $topic (may not exist)"
fi
done
log_step "Step 5/18: Dropping 2.0 databases..." log_step "Step 5/18: Dropping 2.0 databases..."
db_drop db_drop