Skip to content

UPDATE in transaction is not applied sometimes #167

@Radiokot

Description

@Radiokot

Hi guys, I have this weird issue with 1.0.0-BETA28, and I would greatly appreciate any help in debugging it.

Scenario:

  • An expense logging screen of an Android app is opened via a desktop shortcut
  • User selects account and enters the amount
  • A writeTransaction is executed in viewModelScope which contains the following queries:
    • INSERT new row into the transfers table
    • SELECT current account balance from the accounts table (stored as TEXT and mapped into BigInteger)
    • UPDATE the accounts table, set corresponding account balance to current - transfer amount
  • Once writeTransaction is completed successfully, the screen closes and so the app goes to background

The issue: sometimes the balance UPDATE is not applied, although the new row gets inserted into the transfers table within the same transaction.

On the other hand, if the same expense logging is done from the main app screen, so the app doesn't go to background on transaction success, the UPDATE is always applied, and the user immediately sees the updated value in the UI (via database.watch())

Here is the log for the case when UPDATE has not been applied:

log.txt

There's a big time difference between 21:43:11.616 and 21:43:27.738 because I actually managed to suspend the SupabaseConnector by a breakpoint to confirm that table.update was indeed called with entry.opData having "balance=-4314082". Nevertheless, the balance in Supabase remained the same, and so it did in the app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions