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

Update MSSQL test Docker image #2120

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Update MSSQL test Docker image #2120

merged 2 commits into from
Sep 25, 2024

Conversation

evansd
Copy link
Contributor

@evansd evansd commented Sep 24, 2024

The previous version was incompatible with the updated kernel now used by Github Actions runners. See:
microsoft/mssql-docker#868

The fix has been backported as far as the 2019 image, but not to the 2017 image. Seeing that the 2017 image didn't match what was being run in production in any case we might as well upgrade.

This requires a few small changes:

  • The sqlcmd tool has moved from /opt/mssql-tools/bin to /opt/mssql-tools18/bin. This is due to the newer image using the mssql-tools18 apt package. Note that references to the old path are still present in the codebase because our Docker image still installs the mssql-tools package.

  • The sqlcmd invocation now requires the -C option to automatically trust the server certificate.

  • The precise sequence in which IO statistics are returned has changed and so we update the code which parses these to be insensitive to changes in order.

The previous version was incompatible with the updated kernel now used
by Github Actions runners. See:
microsoft/mssql-docker#868

The fix has been backported as far as the 2019 image, but not to the
2017 image. Seeing that the 2017 image didn't match what was being run
in production in any case we might as well upgrade.

This requires a few small changes:

 * The `sqlcmd` tool has moved from `/opt/mssql-tools/bin` to
   `/opt/mssql-tools18/bin`. This is due to the newer image using the
   `mssql-tools18` apt package. Note that references to the old path
   are still present in the codebase because _our_ Docker image still
   installs the `mssql-tools` package.

 * The `sqlcmd` invocation now requires the `-C` option to automatically
   trust the server certificate.
Copy link

cloudflare-workers-and-pages bot commented Sep 24, 2024

Deploying databuilder-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3995a65
Status: ✅  Deploy successful!
Preview URL: https://5f43b915.databuilder.pages.dev
Branch Preview URL: https://evansd-fix-mssql-in-ci.databuilder.pages.dev

View logs

The previous code used a single big regex and relied on a precise
sequence of IO statistics being returned in a fixed order. In SQL Server
2019 new items were added and the order slightly changed. We rewrite the
parsing code to be robust to such changes.
Copy link
Contributor

@rebkwok rebkwok left a comment

Choose a reason for hiding this comment

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

Question about the log tests which might just be my misunderstanding things

(
b"Table '#tmp_1______________________________________________________________________________________________________________0000000014D9'."
b" Scan count 1, logical reads 4, physical reads 0, read-ahead reads 0,"
b" lob logical reads 0, lob physical reads 0, lob read-ahead reads 0."
b" Scan count 1, logical reads 4, physical reads 0, page server reads 0,"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the new page server items also show up in the #tmp_1 entry in the table_io assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way I've got it working at the moment is that it discards any stats it isn't expecting, because it only iterates the keys already in cumulative_stats:

table_io = defaultdict(
lambda: {
"scans": 0,
"logical": 0,
"physical": 0,
"read_ahead": 0,
"lob_logical": 0,
"lob_physical": 0,
"lob_read_ahead": 0,
}

for key in cumulative_stats.keys():
cumulative_stats[key] += stats.get(key, 0)

I wanted to try to keep the output consistent between dev and prod in this respect.

I agree the tests here aren't as comprehensible as they could be, but they do cover everything and I didn't think it was worth the time making them better for a fairly small feature.

@evansd evansd merged commit be03fb2 into main Sep 25, 2024
8 checks passed
@evansd evansd deleted the evansd/fix-mssql-in-ci branch September 25, 2024 10:04
rebkwok added a commit to opensafely-core/sqlrunner that referenced this pull request Oct 8, 2024
Copying the commit message from the equivalent PR on ehrql:
opensafely-core/ehrql#2120

The previous version was incompatible with the updated kernel now used
by Github Actions runners. See:
microsoft/mssql-docker#868

The fix has been backported as far as the 2019 image, but not to the
2017 image. Seeing that the 2017 image didn't match what was being run
in production in any case we might as well upgrade.
rebkwok added a commit to opensafely-core/sqlrunner that referenced this pull request Oct 8, 2024
Copying the commit message from the equivalent PR on ehrql:
opensafely-core/ehrql#2120

The previous version was incompatible with the updated kernel now used
by Github Actions runners. See:
microsoft/mssql-docker#868

The fix has been backported as far as the 2019 image, but not to the
2017 image. Seeing that the 2017 image didn't match what was being run
in production in any case we might as well upgrade.

This requires a few small changes:

 * The `sqlcmd` tool has moved from `/opt/mssql-tools/bin` to
   `/opt/mssql-tools18/bin`. This is due to the newer image using the
   `mssql-tools18` apt package.

 * The `sqlcmd` invocation now requires the `-C` option to automatically
   trust the server certificate.
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