Steal MigrateU2fWebauthn background migration
What does this MR do?
This MR follows up on !42159 (merged) / #232670 (closed), draining the background migration for U2F registrations introduced in !42159 (merged) and migrating any leftover U2F devices to WebAuthn.
Migration Output
Stealing Migration
== 20201026185514 EnsureU2fRegistrationsMigrated: migrating ===================
== 20201026185514 EnsureU2fRegistrationsMigrated: migrated (0.0877s) ==========
== 20201026185514 EnsureU2fRegistrationsMigrated: reverting ===================
== 20201026185514 EnsureU2fRegistrationsMigrated: reverted (0.0000s) ==========
Migrating 1000 records takes approx. 16 seconds (on my machine):
== 20201026185514 EnsureU2fRegistrationsMigrated: migrating ===================
== 20201026185514 EnsureU2fRegistrationsMigrated: migrated (16.3710s) =========
Gitlab.com has 1591 u2f registrations left, so this should take something between 20 and 40 seconds, depending on the system environment.
Increase text limit
== 20201117075742 ChangeWebauthnXidLength: migrating ==========================
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0004s
-- execute("ALTER TABLE webauthn_registrations\nADD CONSTRAINT check_e54008d9ce\nCHECK ( char_length(credential_xid) <= 340 )\nNOT VALID;\n")
-> 0.0012s
-- current_schema()
-> 0.0004s
-- execute("SET statement_timeout TO 0")
-> 0.0003s
-- execute("ALTER TABLE webauthn_registrations VALIDATE CONSTRAINT check_e54008d9ce;")
-> 0.0050s
-- execute("RESET ALL")
-> 0.0005s
-- execute("ALTER TABLE webauthn_registrations\nDROP CONSTRAINT IF EXISTS check_242f0cc65c\n")
-> 0.0009s
== 20201117075742 ChangeWebauthnXidLength: migrated (0.0531s) =================
== 20201117075742 ChangeWebauthnXidLength: reverting ==========================
== 20201117075742 ChangeWebauthnXidLength: reverted (0.0000s) =================
SQL Queries
Find start id in batch:
SELECT
"u2f_registrations"."id"
FROM
"u2f_registrations"
LEFT JOIN webauthn_registrations ON webauthn_registrations.u2f_registration_id = u2f_registrations.id
WHERE (webauthn_registrations.u2f_registration_id IS NULL)
ORDER BY
"u2f_registrations"."id" ASC
LIMIT 1
https://postgres.ai/console/shared/0daca4e3-5fd5-4a53-8676-648932f237ca
Find end id in batch:
SELECT
"u2f_registrations"."id"
FROM
"u2f_registrations"
LEFT JOIN webauthn_registrations ON webauthn_registrations.u2f_registration_id = u2f_registrations.id
WHERE (webauthn_registrations.u2f_registration_id IS NULL)
AND "u2f_registrations"."id" >= 131404
ORDER BY
"u2f_registrations"."id" ASC
LIMIT 1 OFFSET 100
https://postgres.ai/console/shared/145aa6ee-dc1c-4bb1-a7ec-aae9fc9a099e
Load all records in the batch:
SELECT
"u2f_registrations".*
FROM
"u2f_registrations"
LEFT JOIN webauthn_registrations ON webauthn_registrations.u2f_registration_id = u2f_registrations.id
WHERE (webauthn_registrations.u2f_registration_id IS NULL)
AND "u2f_registrations"."id" >= 131404
AND "u2f_registrations"."id" < 131526
https://postghttps://postgres.ai/console/shared/b55cee23-3dbc-4b2a-87be-998036b65a8b
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides (I hope) - [-] Separation of EE specific content
Availability and Testing
- X ] Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Related to #232670 (closed)
Edited by Jan Beckmann