Project

General

Profile

Feature #1821

Errors in a schema upgrade script that contains multiple SQL statements are not detected

Added by jjakob about 3 years ago. Updated 7 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
06/12/2022
Due date:
% Done:

0%

Estimated time:
OS:
Any

Description

I created a schema upgrade script with multiple statements in one file. When the upgrade started, one of the statements failed with an error visible in the PostgreSQL log, but quasselcore didn't show any errors and just finished the upgrade and increased the schemaversion number in the database anyway.

I believe this is due to the use of watchQuery https://github.com/quassel/quassel/blob/4251006ea8f4433e1c139d380cd6c748b0dfcc84/src/core/abstractsqlstorage.cpp#L272
which calls 'query.lastError().isValid()' just once, which may return the status of one of the successfully-executed statements inside the entire multi-statement query while it has not yet finished executing.
I believe it is not written to work with multi-statement upgrade scripts, each statement must be broken out into a separate file.

History

#1 Updated by khtmhai5 about 3 years ago

I have same issue..

#2 Updated by John217Ross 7 days ago

You're correct — Quassel's watchQuery() doesn't properly handle multi-statement SQL upgrade scripts. It checks for errors only once using query.lastError().isValid(), which can miss failures if multiple statements are run in one file. As a result, even if one statement fails (as seen in your PostgreSQL logs), the upgrade may appear successful and incorrectly increment the schema version. To avoid this, each SQL statement should be placed in a separate file, or the upgrade logic should be modified to execute and check each statement individually. https://www.mymilestonecard.onl

Also available in: Atom PDF