Skip to content

fix: Wait for transaction to complete on commit - #4582

Merged
DanRibbens merged 2 commits into
payloadcms:mainfrom
joas8211:fix/postgres-transaction-promises
Dec 21, 2023
Merged

DanRibbens merged 2 commits into
payloadcms:mainfrom
joas8211:fix/postgres-transaction-promises

Conversation

@joas8211

@joas8211 joas8211 commented Dec 21, 2023 •

Copy link
Copy Markdown
Contributor

Description

Currently transactions are committed asynchronously and are not awaited. That causes problems at least with in-series local API calls that are supposed to commit transactions (do not provide transaction ID) but end up completing commit too late.

Fixes #4581

  • I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes
  • I have made corresponding changes to the documentation

@joas8211

joas8211 commented Dec 21, 2023 •

Copy link
Copy Markdown
Contributor Author

I feel like current tests cover the bug already quite well, so I didn't add any tests. Especially tests in test/database/int.spec.ts cover the bug.

For me running unit tests locally with Postgres, amount of failed tests dropped dramatically:

Branch Test result
main (at 8015e99) 35 failed, 8 todo, 500 passed, 543 total
fix/postgres-transaction-promises 1 failed, 8 todo, 534 passed, 543 total

The one test that still sometimes fail is Search Plugin › should sync published pages to the search collection (I believe it's related to #4498).

@DanRibbens

Copy link
Copy Markdown
Contributor

I think what you are saying and that your commit makes sense at first glance. I am going to re-run the postgres test suite to get more verification.

In the past it had been failing about 50% of the time, likely for this reason.

@DanRibbens
DanRibbens merged commit a71d37b into payloadcms:main Dec 21, 2023
@DanRibbens DanRibbens changed the title fix(db-postgres): Wait for transaction to complete on commit fix: Wait for transaction to complete on commit Dec 21, 2023
JessRynkar pushed a commit that referenced this pull request Jan 2, 2024
* fix(db-postgres): Wait for transaction to complete on commit
* fix session types
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.

db-postgres: Pagination shows incorrect totalDocs after deletion using local API with user set

2 participants