payloadcms / payloadcms/payload

Payload with getPayloadHMR don't close or spams db connections during Static Site Generation

Open
#7,312 60 comments 4 reactions 3 assignees View on GitHub

@denolfe is already working on this.

Since Jul 23, 2024.

keep status: cant-reproduce
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Link to reproduction

No response

Payload Version

3.0.0-beta.68

Node Version

v20.11.1

Next.js Version

next@15.0.0-rc.0

Describe the Bug

I'm using postgres 12, and static generation with getStatisProps combined with local api of getPayloadHMR
Having 32 statically generated pages I encounter a problem that the last few pages are not generated right away, worker for generation terminates and restarts, finishing page generation. On second screenshot you can see a peak of postgres connections - max 100 for my system - in idle state, after peak drops, that's when workers are terminated, restarted and finished. This works after some optimizations I've made, because before that, SSG were failing with too many clients from postgres.
Is this an intended behavior and I should scale connections as count of my pages growth or that's going something wrong with how connections are managed in local api?
image
image

Reproduction Steps

When I will have time maybe I will try to create an example repo, but rough reproduction:

  1. Get a postgress db - set max_connection to 100 or less.
  2. Create a bunch of pages
  3. Try generate with next build
Adapters and Plugins

db-postgres

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.