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

Issue with Preload(...) and Prepared Statements After Schema Migration #7255

Open
jared-mackey opened this issue Oct 24, 2024 · 0 comments
Open
Assignees
Labels
type:question general questions

Comments

@jared-mackey
Copy link

jared-mackey commented Oct 24, 2024

Description

Hi,

First, thank you for all the hard work you do on GORM!

I’m encountering an issue when using Preload("Blah.Blah") in combination with prepared statements. In our setup, we deploy multiple instances of our application and perform rolling deployments. When deploying a new version that includes a migration, the migration is applied before starting the new pods, which function as expected.

However, this causes issues for the old pods that are still running and handling traffic. Specifically, if the migration adds a new column to a table, it invalidates the prepared statement caches in the old pods that use SELECT * generated from the Preload() calls on the affected tables. As a result, the old pods break with the error cached plan must not change result type (SQLSTATE 0A000), while the new ones are fine.

Proposal/Question: Would it be possible for Preload(...) to inspect the struct’s fields and generate a query that selects only those fields, instead of using SELECT *? This way, the old pods would continue to have valid query caches while the new pods begin selecting the additional fields introduced by the migration / changes to the structs.

Thanks again!

@github-actions github-actions bot added the type:question general questions label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question general questions
Projects
None yet
Development

No branches or pull requests

2 participants