Fix poller crash: sync poller_sources on (type, name)#109
Merged
Conversation
The DB enforces UNIQUE(type, name) on poller_sources, but the sync logic deduplicated and matched on (type, url). When an existing source's URL changed (e.g. the meshcore pyMC-Repeater migration), the new (type, url) key was absent from the DB set, so the sync attempted an INSERT that collided with the existing row's (type, name), raising UniqueViolationError and crashing the poller on startup. Key the sync on (type, name) to match the constraint and treat url as a mutable property that is updated in place for existing config sources.
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
The poller container crashes on startup with:
Root cause
The
poller_sourcestable enforcesUNIQUE(type, name)(seedb/init/03_sources.sql), but_sync_poller_sourcesinpoller/config_sync.pydeduplicated and matched rows on(type, url)instead.After the recent "Replace RemoteTerm meshcore poller with pyMC-Repeater" change, the meshcore source's URL differed from what was already stored in the DB. Because the sync keyed on
(type, url), the new(meshcore, <new_url>)pair wasn't found in the DB set, so the code attempted anINSERT— which collided with the existing row's(meshcore, pyMC-Repeater)(type, name)pair, raisingUniqueViolationErrorand crashing the poller on every startup.Fix
Key the sync on
(type, name)to match the actual DB constraint, and treaturlas a mutable property that is updated in place for existingconfigsources. This resolves the crash and correctly handles URL changes for an existing source going forward.https://claude.ai/code/session_015f251CGMtsvJ5Vff4bEJCu
Generated by Claude Code