Fix poll_db crash when notifications payload indeces is None #537
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.
Every time
poll_db()
tries to process a notification payload that has indices set toNone
it crashes.This can happen for several reasons, outdated triggers for instance, or due to other non-tracked changes in the DB pgsync listens to. For example a TRUNCATE in a table of the same DB that pgsync monitors but does not sync.
This PR fixes this by adding a simple check for a
None
value before trying to search the payload indices list.Adding a test is challenging because the current code does not provide a way to control/exit the db_poll thread loop, hence you cannot exit the loop from a test once started. This requires a refactor that I think is out of the scope of this fix.
BTW, you should really think about having a stable branch with the latest release,
main
is currently broken and tests do not pass. This makes contributions much harder for other devs because there is no simple way to verify the fixes do not introduce secondary effects. You have to checkout the tag, cherry pick the fix commit, run the tests, and then make a PR againstmain
.Thanks for all your hard work and dedication to this project @toluaina, it's very useful and very much appreciated.