Skip to content

Commit a4a3f70

Browse files
committed
Avoid error after upgrading a database
The `runUpgrade` query server command is mistakenly caching the old dbscheme in memory after running the upgrade. The problem is in the CLI. The workaround is to restart the query server after running an upgrade. This is not a great solution, but considering that explicit upgrades are now very rare. I do not think it is worth putting in too much effort for a proper fix.
1 parent 29a43c7 commit a4a3f70

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

extensions/ql-vscode/src/upgrades.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,14 @@ export async function upgradeDatabaseExplicit(
194194
void qs.logger.log('Running the following database upgrade:');
195195

196196
getUpgradeDescriptions(compileUpgradeResult.compiledUpgrades).map(s => s.description).join('\n');
197-
return await runDatabaseUpgrade(qs, dbItem, compileUpgradeResult.compiledUpgrades, progress, token);
197+
const result = await runDatabaseUpgrade(qs, dbItem, compileUpgradeResult.compiledUpgrades, progress, token);
198+
199+
// TODO Can remove the next lines when https://github.com/github/codeql-team/issues/1241 is fixed
200+
// restart the query server to avoid a bug in the CLI where the upgrade is applied, but the old dbscheme
201+
// is still cached in memory.
202+
203+
await qs.restartQueryServer(progress, token);
204+
return result;
198205
}
199206
catch (e) {
200207
void showAndLogErrorMessage(`Database upgrade failed: ${e}`);

0 commit comments

Comments
 (0)