Skip to content

Commit 80696ee

Browse files
Zohaib Sibte Hassanclaude
andcommitted
Fix: Schema version not incremented on followers for CREATE/DROP DATABASE
When CREATE/DROP DATABASE transactions committed on follower nodes, the DDLSQL field in CommitResult was not set. This caused the replication handler to skip incrementing the schema version on follower nodes. Effect: After CREATE DATABASE, subsequent DDL (like CREATE TABLE) would fail with "schema version mismatch" because followers had version 0 while coordinator had version 1. Fix: Return DDLSQL in CommitResult for database operations so followers increment their schema version correctly. Verified: WordPress installs and runs correctly on 3-node cluster. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1cc8dc4 commit 80696ee

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

db/replication_engine.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,15 @@ func (re *ReplicationEngine) Commit(ctx context.Context, req *CommitRequest) *Co
338338
Uint64("node_id", re.nodeID).
339339
Msg("Database operation committed successfully")
340340

341-
return &CommitResult{Success: true}
341+
// Return DDLSQL so replication handler can increment schema version
342+
var ddlSQL string
343+
switch dbOp {
344+
case DatabaseOpCreate:
345+
ddlSQL = fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", dbName)
346+
case DatabaseOpDrop:
347+
ddlSQL = fmt.Sprintf("DROP DATABASE IF EXISTS %s", dbName)
348+
}
349+
return &CommitResult{Success: true, DDLSQL: ddlSQL}
342350
}
343351
}
344352
}

0 commit comments

Comments
 (0)