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

Fix leaky test: #54578

Merged
merged 1 commit into from
Feb 20, 2025
Merged

Fix leaky test: #54578

merged 1 commit into from
Feb 20, 2025

Conversation

Edouard-chin
Copy link
Member

@Edouard-chin Edouard-chin commented Feb 20, 2025

  • Fix PessimisticLockingTest#test_no_locks_no_wait gets ERROR: cached plan must not change result type #51347

  • The tests in this suite are leaky which results in other tests from other suite from sometimes failing.

    The problem is due to modifying some database tables while a prepared statement on Postgreql already exists. This causes Postgres to report an error "cached plan must not change result type".

    The order of reproduction is as follow:

    • We have more than one connection in the pool (Let's say Conn1 and Conn2 for the sake of the example)
    • A first test runs a query, Conn1 is used, we prepare a statement.
    • The leaky test modify some table on Conn2.
    • A third test runs a query in a transaction, Conn1 is used, the query was prepared. Postgresql reports the "cached plan must not change result type".

    This commis fixes that by clearing the statement cache on each
    connection.

cc/ @yahonda

- Fix rails#51347
- The tests in this suite are leaky which results in other tests
  from other suite from sometimes failing.

  The problem is due to modifying some database tables while
  a prepared statement on Postgreql already exists. This causes
  Postgres to report an error
  "cached plan must not change result type".

  The order of reproduction is as follow:

  - We have more than one connection in the pool (Let's say Conn1 and
   Conn2 for the sake of the example)
  - A first test runs a query, Conn1 is used, we prepare a statement.
  - The leaky test modify some table on Conn2.
  - A third test runs a query, Conn1 is used, the query was prepared.
    Postgresql reports the  "cached plan must not change result type".

  This commis fixes that by clearing the statement cache on each
  connection.
@byroot byroot merged commit 9a94ff4 into rails:main Feb 20, 2025
3 checks passed
@zzak
Copy link
Member

zzak commented Feb 20, 2025

Backport please? 🙇

byroot added a commit that referenced this pull request Feb 21, 2025
Fix leaky test:
byroot added a commit that referenced this pull request Feb 21, 2025
Fix leaky test:
byroot added a commit that referenced this pull request Feb 21, 2025
Fix leaky test:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PessimisticLockingTest#test_no_locks_no_wait gets ERROR: cached plan must not change result type
3 participants