You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jira Link: DB-1355 Summary: In some cases, if a statement is prepared on one node, and a table used in the statement is altered from another node, the prepared statement will not be invalidated. This issue can happen even if enough time has passed for the t-server to heartbeat to the master and receive the updated catalog version number.
Test Case:
@TestpublicvoidtestConsistentPreparedStatements() throwsException {
try (Statementstatement1 = createConnection(0).createStatement();
Statementstatement2 = createConnection(1).createStatement()) {
// Create table from connection 1.statement1.execute("CREATE TABLE test_table(id int, PRIMARY KEY (id))");
// Wait for heartbeat.Thread.sleep(1000);
// Force a cache refresh on connection 2.statement2.execute("SELECT * FROM test_table");
// Prepare from connection 2.statement2.execute("PREPARE plan (int) AS SELECT * FROM test_table where id=$1");
// Alter table from connection 1.statement1.execute("ALTER TABLE test_table ADD COLUMN b int");
statement1.execute("INSERT INTO test_table(id, b) VALUES (1, 2), (2, 3)");
// Wait for heartbeat.Thread.sleep(1000);
// Only one column is returned.assertQuery(statement2, "EXECUTE plan(1)", newRow(1));
}
}
Expected Result: The final query in the test should fail with error "ERROR: cached plan must not change result type". This is the error produced if all queries are executed using the same statement (and connection).
Actual Result: The test passes.
Note: This problem also occurs if the statement is prepared after the alter table statement, but before the next t-server heartbeat.
The text was updated successfully, but these errors were encountered:
srhickma
changed the title
[YSQL] Prepared statements not invalidated after schema change.
[YSQL] Prepared statements not invalidated after schema change
Jun 8, 2019
Jira Link: DB-1355
Summary: In some cases, if a statement is prepared on one node, and a table used in the statement is altered from another node, the prepared statement will not be invalidated. This issue can happen even if enough time has passed for the t-server to heartbeat to the master and receive the updated catalog version number.
Test Case:
Expected Result: The final query in the test should fail with error "ERROR: cached plan must not change result type". This is the error produced if all queries are executed using the same statement (and connection).
Actual Result: The test passes.
Note: This problem also occurs if the statement is prepared after the alter table statement, but before the next t-server heartbeat.
The text was updated successfully, but these errors were encountered: