Page MenuHomePhabricator

[keyserver] Call setupDB from DB migration if meta table is missing
ClosedPublic

Authored by ashoat on May 30 2022, 1:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 1:52 PM
Unknown Object (File)
Mon, Oct 28, 2:49 AM
Unknown Object (File)
Thu, Oct 24, 9:24 PM
Unknown Object (File)
Thu, Oct 24, 9:24 PM
Unknown Object (File)
Thu, Oct 24, 9:24 PM
Unknown Object (File)
Wed, Oct 16, 7:25 PM
Unknown Object (File)
Oct 5 2024, 1:13 AM
Unknown Object (File)
Oct 5 2024, 1:13 AM

Details

Summary

Depends on D4150

Linear task: ENG-1208

Test Plan

Create a keyserver/.env file, eg.:

COMM_MYSQL_DATABASE=commdev
COMM_MYSQL_USER=commdev
COMM_MYSQL_PASSWORD=pass

And then run the Docker image: cd keyserver && docker-compose down -v && docker-compose up --build

It should successfully connect to MySQL and start all of its threads. At this point (for the first time) Node should stop crash looping.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek added inline comments.
keyserver/src/database/migrations.js
128

It might be a good idea to explain what this magic number means

This revision is now accepted and ready to land.May 31 2022, 5:11 AM
atul added inline comments.
keyserver/src/database/migrations.js
123–128

Yeah, agree. Based on a quick Google search it looks like 1146 ~= MySQL error code for table doesn't exist.

One option would be to leave a comment explaining that. Alternatively, might be good to define something like

const MYSQL_TABLE_DOESNT_EXIST_ERROR_CODE = 1466

somewhere in the file so the name is "self-documenting" and comments can be avoided.


Can name the constant anything, but would probably be good to name it in a way that it's clear the error code is "MySQL-specific" since "one day" it might change to MariaDB or Postgres or whatever?

keyserver/src/database/migrations.js
123–128

Makes sense. For context, the full reference of MySQL 5.7 error codes is here.

Since we have this pattern in a couple of other places in the codebase, I've addressed this in a follow-up diff: D4157