X Tutup
The Wayback Machine - https://web.archive.org/web/20260101125621/https://github.com/github/vscode-codeql/pull/679
Skip to content

Conversation

@alexet
Copy link

@alexet alexet commented Nov 13, 2020

This depends on a rebased copy of #639 and also on some unreleased cli features and shouldn't be merged until we know which version they will be released in.

This PR makes us use silent non-destructive upgrades. It also refactors the current upgrade mechanism in places so we have slightly fewer code paths.

There are a few identation changes so you may want to add ?w=1 to the url when reviewing to ignore those changes.

@alexet alexet requested a review from aeisenberg November 13, 2020 19:14
@alexet alexet marked this pull request as draft November 13, 2020 19:43
Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a partial review. Looks good. Just some small things. I'll finish this off on Monday.

@alexet alexet force-pushed the non-destructive-upgrades branch from 22770d2 to 5335a84 Compare December 7, 2020 17:45
@alexet alexet force-pushed the non-destructive-upgrades branch from 5335a84 to 3c81e06 Compare December 16, 2020 16:51
@alexet alexet force-pushed the non-destructive-upgrades branch from 3c81e06 to 2cc06d4 Compare January 8, 2021 15:57
@alexet
Copy link
Author

alexet commented Jan 11, 2021

You comment have made me realise that we can simplify the queryserver api, but it will mean that we need to wait for another codeql release to get this in.

@alexet alexet marked this pull request as ready for review January 25, 2021 16:49
@alexet alexet force-pushed the non-destructive-upgrades branch from c1d906c to bff5e2f Compare January 25, 2021 16:50
@alexet
Copy link
Author

alexet commented Jan 25, 2021

Ok this should be ready for re-review. Sorry I was so slow at coming back to this.

Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only major issue is the missing await clause. Everything else is just wording and naming changes.

/**
* Compile an upgrade script to upgrade a dataset.
*/
export const compileUpgradeSequence = new rpc.RequestType<WithProgressId<CompileUpgradeSequenceParams>, CompiledUpgradeSequence, void, void>('compilation/compileUpgradeSequence');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our naming convention is usually XxxParams and XxxResult. Here it's CompileUpgradeSequenceParams and CompiledUpgradeSequence. Can you follow the same convention here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...and I see below that EvaluateQueriesParams and EvaluationComplete does not follow the convention either. I still think it's useful to do so in order to know how these two interfaces are related.

I may fix that in a later PR.

}

function reportNoUpgradePath(query: QueryInfo) {
throw new Error(`Query ${query.program.queryPath} expects database scheme ${query.queryDbscheme}, but the current database has a different scheme, and no database upgrades are available. The current database scheme may be newer than the CodeQL query libraries in your workspace. Please try using a newer version of the query libraries.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Consider emphasizing the proposed solution so it's not hidden in a wall of text.

Suggested change
throw new Error(`Query ${query.program.queryPath} expects database scheme ${query.queryDbscheme}, but the current database has a different scheme, and no database upgrades are available. The current database scheme may be newer than the CodeQL query libraries in your workspace. Please try using a newer version of the query libraries.`);
throw new Error(`Query ${query.program.queryPath} expects database scheme ${query.queryDbscheme}, but the current database has a different scheme, and no database upgrades are available. The current database scheme may be newer than the CodeQL query libraries in your workspace.\n\nPlease try using a newer version of the query libraries.`);

await checkDbschemeCompatibility(cliServer, qs, query, progress, token);

let errors;
const upgradeDir = tmp.dirSync({ dir: upgradesTmpDir.name });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using sync functions in user code. You can use the tmp-promise package to make an async call to creating a tmp directory. After changing the import statement, all you need to do is this:

Suggested change
const upgradeDir = tmp.dirSync({ dir: upgradesTmpDir.name });
const upgradeDir = await tmp.dir({ dir: upgradesTmpDir.name });

if (result.resultType !== messages.QueryResultType.SUCCESS) {
const message = result.message || 'Failed to run query';
logger.log(message);
helpers.showAndLogErrorMessage(message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should already be imported directly.

Suggested change
helpers.showAndLogErrorMessage(message);
showAndLogErrorMessage(message);

}
finally {
qs.logger.log('Done checking database upgrade.');
if (!hasNondestructiveUpgradeCapabilities(qs)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice...code scanning worked here. This expression needs an await.

finally {
qs.logger.log('Done checking database upgrade.');
if (!hasNondestructiveUpgradeCapabilities(qs)) {
throw new Error('The version of codeql is to old to run non-destructive upgrades.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error('The version of codeql is to old to run non-destructive upgrades.');
throw new Error('The version of codeql is to old too run non-destructive upgrades.');

db: DatabaseItem,
resolvedSequence: string[],
currentUpgradeTmp: tmp.DirResult,
currentUpgradeTmp: tmp.DirectoryResult,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that the type names were slightly different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup