Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initiating a sync from an instance using postgres fails due to transactional issues #9524

Closed
bjester opened this issue Jun 21, 2022 · 1 comment
Assignees
Labels
DEV: backend Python, databases, networking, filesystem... P0 - critical Priority: Release blocker or regression TAG: regression Something that previously worked

Comments

@bjester
Copy link
Member

bjester commented Jun 21, 2022

Background

We recently made fixes to Morango that correct the database transaction handling, which was meant to perform certain operations within a transaction with higher transaction isolation when using postgres. Due to connection mismanagement, the operations weren't actually executing in a transaction.

Observed behavior

The sync command initiates a sync as a client instance, and wraps certain stages with a db_lock context manager. When Kolibri is configured to use postgres, the db_lock context manager opens a transaction and executes an advisory lock. Since the sync command is wrapping several stages (initialization, serializing, and queuing), it conflicts with morango's internal management in a way that causes unexpected behavior, such as being unable to read records written during the outer transaction.

Expected behavior

The motivation for wrapping parts of the sync with a transaction and advisory lock have likely been corrected and handled by the recent transactional fixes made within morango. In addition, if conflicting changes occur during a transaction within morango (one using isolation), then it's likely that a transaction rollback error will be raised from a serializable error, and morango will retry.

User-facing consequences

The effects of this issue can be very confusing, and were very difficult to debug.

Steps to reproduce

  1. Set up a kolibri instance with postgres
  2. Initiate a sync from the postgres instance
  3. Observe the majority of the sync appears to complete successfully, but errors in the final steps of the sync command
  4. Observe the morango_store has 0 records, but records exist in the buffer

Context

Kolibri 0.14.8-alpha, 0.15.x, 0.16.x
Morango 0.6.12+
Postgresql

@bjester bjester added P0 - critical Priority: Release blocker or regression TAG: regression Something that previously worked labels Jun 21, 2022
@bjester bjester self-assigned this Jun 21, 2022
@bjester bjester added the DEV: backend Python, databases, networking, filesystem... label Jun 21, 2022
@marcellamaki
Copy link
Member

Fixed with #9556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... P0 - critical Priority: Release blocker or regression TAG: regression Something that previously worked
Projects
None yet
Development

No branches or pull requests

2 participants