Comments (5)
Hey @lekterable — I just reproduced this with your exact code and I can't seem to reproduce.
In order to help here, we're going to need you to provide a minimal reproduction - but I'd be happy to help once we can understand how to reproduce!
from payload.
huh, okay that's very strange, because the only thing that helped me was changing the adapter to Mongo
so you're able to query twice in the same hooks execution from the Postgres db? @jmikrut
I'll prepare a repro when I have a moment
from payload.
Yep. I did two consecutive finds in the same beforeValidate
hook just as you did. And I logged the result for each find and both worked accordingly.
Are you setting max connections or anything like that? One thing you could try is to pass the req
through to your find
queries in your hook, so that the Payload operations are all running on the same transaction / connection.
Every time you do a payload.find
or any local API method, Payload will either:
- Start a new transaction
- Use the same transaction that already exists if you pass the
req
as an argument
So your code as-is will start 3 different transactions (one for the main create / update op, and one each for your find ops). If you pass the req
to your find
operations, the find
operations will re-use the existing transaction.
Try that?
from payload.
Are you setting max connections or anything like that?
Not explicitly, I'm using the default settings which Railway provides. I only copied the DB_URL
So your code as-is will start 3 different transactions (one for the main create / update op, and one each for your find ops). If you pass the req to your find operations, the find operations will re-use the existing transaction.
Try that?
Thanks for the tip! I think I'll just stick to Mongo as it seems to be more matured and doesn't cause any issues, but I'll try to provide a full repro when I have a minute.
from payload.
Of course.
It's worth noting that MongoDB would have this same issue if you use MongoDB with replica sets (you need replica sets in order to get MongoDB to work with transactions).
This would explain why in MongoDB, you do not see any issues (you probably don't have replica sets, so transactions are not enabled).
This whole transactions topic is a database-wide paradigm, in that transactions operate by reserving a connection for a specific transaction. Doesn't matter if it's Postgres or MongoDB - both work the same way when enabled.
I do think that for most use cases, Payload lends itself well to MongoDB though. So if you can switch, I wouldn't stop ya!
If you do get around to getting a repro put together, please post it here and I will re-open the issue.
Thank you!
from payload.
Related Issues (20)
- Admin filter for checkbox type is not translated. HOT 2
- Upload by URL in file upload dialog causes CORS error if file is not on the same domain HOT 3
- Custom label for field in lexical block crashes admin panel
- Preview broken for localization EN when creating from FR with Postgres HOT 1
- Cannot publish a single locale and keep other locales in draft HOT 1
- Lots of inlined Scripts for Lexical and other component contexts causing inflated Admin Panel Size HOT 11
- Toast shows generic message from list view in admin panel
- Several inlined translations from unused locals HOT 1
- ⨯ Failed to download `Merriweather` from Google Fonts. Using fallback font instead HOT 1
- SEO + Tenancy + Global + Postgres does not seem to save/update
- Changing the cookie prefix prevents login in Next.js standalone mode
- Build production Error HOT 2
- Safari, @payloadcms/richtext-lexical, Invalid regular expression: invalid group specifier name HOT 4
- Move segments to root instead of /admin HOT 2
- Collection throws ValidationError when using slug `pages` HOT 1
- Locale overwriting (critical bug) HOT 6
- Serverless & db connections on vercel HOT 3
- Next dev & mongo adapter HOT 2
- DefaultTemplate not rendering any menu items in sidebar HOT 1
- Payload breaks with custom Babel config HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from payload.