Skip to content

Conversation

DominicGBauer
Copy link
Contributor

@DominicGBauer DominicGBauer commented Feb 13, 2025

Description

The current watch query is prone to inconsistent issues. This issue arises because the SQLite commit hook transaction notifies listeners about a change before the transaction has been fully committed. Therefore a table update would fire and cause the watch query to re-run before the actual commit had taken place. This could result in timing issues as the query may not yet return with the new data as the transaction commit had not been completed.

This PR resolves this issue by accumulating table changes and only emitting a table update (which results in the watch query re-running) once a writeTransaction or execute has been completed.

The recommendation from this PR https://github.com/powersync-ja/powersync-kotlin/pull/121/files is also included.

There was an issue with the JDBC driver as it starts with index 1 as opposed to 0. A fix for this has also been included.

@DominicGBauer DominicGBauer changed the title WIP chore: improve watch query chore: improve watch query Feb 19, 2025
@DominicGBauer DominicGBauer self-assigned this Feb 19, 2025
@DominicGBauer DominicGBauer marked this pull request as ready for review February 19, 2025 07:47
stevensJourney
stevensJourney previously approved these changes Feb 19, 2025
@DominicGBauer DominicGBauer merged commit e15540a into main Feb 19, 2025
3 checks passed
@DominicGBauer DominicGBauer deleted the chore/improve-watch-query branch February 19, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants