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

Feature request: Ability to disable reaping #56

Open
EmilIvanov opened this issue Sep 25, 2020 · 5 comments
Open

Feature request: Ability to disable reaping #56

EmilIvanov opened this issue Sep 25, 2020 · 5 comments

Comments

@EmilIvanov
Copy link

EmilIvanov commented Sep 25, 2020

pool.check()-ing on an interval / timeout, in the context of AWS Lambda, doesn't work as the run time gets frozen, leading to issues like knex/knex#3636.

A possible solution to the above may be having the ability to disable reaping (e.g. reapIntervalMillis: false, or disableReaping: true) and do manual pool.check()-ing.

@elhigu
Copy link
Collaborator

elhigu commented Sep 25, 2020

pool.check()-ing on an interval / timeout, in the context of AWS Lambda, doesn't work as the run time gets frozen, leading to issues like

Could you point to the docs, which describes that AWZ Lambda timefreeze functionality? I don't understand how Lambda could know that it can freeze an app which has timers running and how that affects to the app when it gets unfreezed (are all the timers triggering in the same moment or what) 🤔

Also I don't thing that issue knex/knex#3636 can be caused from that, because reaping has nothing to do with the fact that connections are broken behind the scenes without socket noticing it.

Maybe you are really looking for a manual API to allow emptying all connections from pool which are not leased at the moment?

Please try to explain your issue exactly and how this feature would actually solve it?

@EmilIvanov
Copy link
Author

Thank you for the quick response.

Here's some context regarding Lambda:
https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/

I didn't mean that the knex issue was caused by the reaping, sorry if it "sounded" that way.

The issue is (not specific to this package, but this package can solve it):

  1. Execute Lambda - a connection is created (and an interval is set)
  2. Lambda exists and gets frozen (so is the interval)
  3. Wait for the "close idle client connections timeout" configured on the server - the connection is closed, Lambda is frozen, so on its end is kept open
  4. Run Lambda again - Lambda is unfrozen (so is the interval, but it never got to do a check)
  5. Then this happens - Connection terminated unexpectedly (Postgresql / AWS Lambda) knex/knex#3636

A simple solution is to call pool.check() manually every time Lambda gets unfrozen (which can be done with the current state of this package).

What I want out of this feature request is to be able to opt-out of automatic checking on an interval.

@elhigu
Copy link
Collaborator

elhigu commented Nov 12, 2020

I think allowing user to explicitly call an extra reaping cycle would be a good idea. Otherwise it really might not happen soon enough that those broken connections would be discarded (if there are too many other timers, that needs to be ran just after unfreeze).

Though I don't see any advantage of disabling the reaping interval completely.

@kibertoad
Copy link
Contributor

@EmilIvanov Would you like to send a PR that would add support for invoking reaping cycle manually?

@elhigu
Copy link
Collaborator

elhigu commented Jan 17, 2021

I'm actually working on partial rewrite and might fix this at the same time.

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

No branches or pull requests

3 participants