Skip to content

Added SetTableCache method to set new schema for a table without load… #719

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

Merged
merged 2 commits into from
Jul 19, 2022

Conversation

sergan99
Copy link
Contributor

@sergan99 sergan99 commented Jul 18, 2022

Problem

Canal lacks ability to set table schema cache bypassing the schema reload from the replicated source database. This makes it impossible to replay the binlog with several table schema changes in the sequence even when you have history of table schemas for every change at your hand.

Solution

This PR adds SetTableCache method for canal users to be able to directly set table schema whenever a user sees fit, for example, when detecting schema change (through a table rename statement e.x. RENAME _temp_migration_123 to my_table) while replaying binlog history.

@sergan99
Copy link
Contributor Author

@lance6716 this PR is minimal and straight forward I think. Also it is a bit of a blocker for us, of course unless we use a fork. Thanks for looking at it!

canal/canal.go Outdated
@@ -380,6 +380,18 @@ func (c *Canal) ClearTableCache(db []byte, table []byte) {
c.tableLock.Unlock()
}

// SetTableCache sets table cache value for the given key
Copy link
Collaborator

Choose a reason for hiding this comment

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

"for the given key" maybe not as straightforward as "for the given table"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to be "for the given table". Thanks!

@lance6716 lance6716 merged commit 2d359bf into go-mysql-org:master Jul 19, 2022
@sergan99 sergan99 deleted the set-schema-cache branch July 19, 2022 14:44
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