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

Extract post-transaction hook for Task callback #834

Open
svevang opened this issue Sep 15, 2023 · 1 comment
Open

Extract post-transaction hook for Task callback #834

svevang opened this issue Sep 15, 2023 · 1 comment
Labels

Comments

@svevang
Copy link
Member

svevang commented Sep 15, 2023

The Task model can trigger async work before the wrapping transaction is committed. Sometimes this can cause dirty reads from the async worker's read-committed view of table state.

#788 was a workaround for this problem in the case of publishing lock state (and can be backed out of when this is solved).

Instead of using Rails model hooks and other callbacks to schedule work, look at ways to trigger the work after the transaction commits -- ensuring that each reader to database state is at the same PostgreSQL MVCC isolation level.

  • Create something like a "task epilogue" that the task subclasses can leverage
  • Examine each task to find where async work is fired off and move that
@svevang svevang added the high label Sep 18, 2023
@svevang
Copy link
Member Author

svevang commented Sep 18, 2023

Maybe call it a Task#on_success hook

@cavis cavis assigned farski and unassigned farski Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants