Skip to content

Conversation

@shawnhathaway
Copy link
Contributor

@shawnhathaway shawnhathaway commented Jul 23, 2020

What changed?
Converted all REPLACE INTO usages with INSERT ON DUPLICATE KEY UPDATE semantics.

Docs - https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html

Why?
Vitess does not support REPLACE INTO with fully sharded setups as REPLACE INTO deletes and reinserts the new row, which could possibly be in another shard depending on the VIndex. INSERT ON DUPLICATE KEY UPDATE forces you to specify which columns are being updated (cannot be VIndex column) and modifies the existing row.

How did you test it?
Existing Unit Tests, Buildkite, Manual BenchTest on EKS cluster.

Potential risks
Update behavior change of REPLACE vs INSERT could bring in subtle changes in behavior, but this should not be a major issue.

Todo
This needs to be validated for Postgres, but as Postgres does not support REPLACE INTO, this may not be an issue. In any case this is a backwards compatible change. Will do in a separate PR.

@shawnhathaway shawnhathaway changed the title Convert REPLACE INTO -> INSERT ON DUPLICATE KEY UPDATE Convert REPLACE INTO -> INSERT ON DUPLICATE KEY UPDATE (MySQL) Jul 23, 2020
return mdb.conn.Exec(q, args...)
}

func expandBatchInsertQuery(q string, rowCount int) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope you covered this with tests (at least existing ones).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this was covered by existing tests atleast and will fail without this :) It took way too long to make named batch inserts work given sqlx bug of inserting artifacts at the end of the query.

@shawnhathaway shawnhathaway merged commit 79269f9 into temporalio:master Jul 24, 2020
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