fix(db_init.sh): resolve services id dynamically — fixes 503 "unable to get a node" on fresh deployments - #23
Open
tmiland-labs wants to merge 1 commit into
Open
Conversation
…rvice=1 syncstorage-rs >= 0.21.1 tokenserver resolves the node via services.id (get_service_id) and get_best_node matches nodes.service against it. Upstream migrations leave sync-1.5 at id 3 (populate_services seeds ids 1-2, remove_services clears rows, add_sync15_service re-inserts with the auto-increment counter unchanged), so the hardcoded service=1 never matches and logins fail with 503 'unable to get a node'. - look up the services id by name when inserting the node row - make the nodes upsert self-healing (also refreshes service) - replace INSERT IGNORE by name to avoid duplicate sync-1.5 rows - fix pre-existing SC2086/SC2006 shellcheck findings
tmiland
pushed a commit
to tmiland/firefox-sync
that referenced
this pull request
Sep 8, 2026
Documents the two fixes carried by this fork (upstream PRs porelli#23 and porelli#24) and points deployers at the production-tested MySQL images on ghcr.io/tmiland/firefox-sync.
tmiland
pushed a commit
to tmiland/firefox-sync
that referenced
this pull request
Sep 8, 2026
- Lead with what the fork carries: db_init fix (upstream porelli#23), 0.23 build-args (upstream porelli#24), production images on ghcr.io/tmiland - Add architecture table (embedded tokenserver since 0.23, dual MariaDB, one-shot init), images section, troubleshooting section - Keep upstream wording for disclaimer/security/background/browser setup, credit porelli, Mozilla and jeena; note GPL-3.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since syncstorage-rs 0.21.1 (tokenserver-mysql), the tokenserver resolves the sync service by name and then matches
nodes.serviceagainst that id:get_service_id:SELECT id FROM services WHERE service = 'sync-1.5'get_best_node:SELECT id, node FROM nodes WHERE service = ? ...(tokenserver-mysql/src/db/db_impl.rs)The upstream migration chain guarantees that
sync-1.5does not have id 1 on a fresh database:2021-08-03 populate_servicesinsertssync-1.1(id 1) andsync-1.5(id 2)2021-12-22 remove_servicesdeletes the rows (AUTO_INCREMENT counter is not reset)2026-02-26 add_sync15_servicere-insertssync-1.5— it lands on id 3db_init.shhardcodesnodes.service = '1', so the node row never matches and every login fails with 503 "Unexpected error: unable to get a node" on current images. Verified on a completely fresh stack (docker compose down -v && up):servicesshowssync-1.5at id 3 while the seedednodesrow points at service 1.Fix
nodesupsert self-healing:ON DUPLICATE KEY UPDATEalso refreshesservice, which repairs databases initialized by the old scriptINSERT IGNOREwith a name-based guard so duplicatesync-1.5rows can't be created$( ))Verification
services.id == nodes.serviceconsistent after init