Skip to content

fix: evictor never runs when autostart:false - #201

Merged
sandfox merged 2 commits into
coopernurse:masterfrom
sushantdhiman:fix-evict
Sep 14, 2017
Merged

sandfox merged 2 commits into
coopernurse:masterfrom
sushantdhiman:fix-evict

Conversation

@sushantdhiman

Copy link
Copy Markdown
Contributor

@sandfox sandfox self-assigned this Aug 21, 2017
@sandfox

sandfox commented Aug 21, 2017

Copy link
Copy Markdown
Collaborator

Yay, thanks for hunting this down (and writing some tests). I'll try to test this locally and get it merged in the next day or two

@sandfox

sandfox commented Aug 21, 2017

Copy link
Copy Markdown
Collaborator

Ok, I've had a slightly deeper look and can see a couple of potential problems, mainly that _scheduleEvictorRun has no guards around it to prevent it being called multiple times and thus causing multiple concurrent 'evictor runs' to be scheduled. With the above change/pr every call to acquire would potentially trigger another (potentially) concurrent 'evictor run'. Whilst this will probably not cause the end of the world, it will definitely cause all kinds of very odd and very hard to pin down behaviour for users at some point.

I wonder if the solution to is for acquire to check if the pool has been started, and if not, "start" it?
(and also for me to properly document auto-start config flag!)

@sushantdhiman

sushantdhiman commented Aug 22, 2017 •

Copy link
Copy Markdown
Contributor Author

Thats why I checked for _scheduledEviction before calling _scheduleEvictorRun.

We can make this more safe by moving this check to _scheduleEvictorRun. That should prevent multiple evictors even if there are multiple calls to _scheduleEvictorRun.

I wonder if the solution to is for acquire to check if the pool has been started, and if not, "start" it?

I guess first acquire call can do that by calling start logic

@samcal

samcal commented Sep 7, 2017

Copy link
Copy Markdown

Hey @sushantdhiman @sandfox, is there an update on this issue? sequelize/sequelize#7884 is pretty brutal because of our users' requests timing out.

@sandfox

sandfox commented Sep 8, 2017

Copy link
Copy Markdown
Collaborator

sorry! had a million other things pile up.

@sushantdhiman somehow I completely missed 2 of those 3 lines! Couldn't see the wood for the trees. Yeah, your PR is actually totally fine in that respect, but after some thought I'd much prefer that acquire auto-started the pool. I think it'll be easier to explain/understand for users, and means all the other "startup" machinery gets spun up (min pool size enforcement etc). It should also mean that going forward there is less chance of any future "startup" logic not getting called when autostart is false.

Are you ok to make the changes? As soonas they are ready I'll try and get a release out.

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

We have enough safeguards to prevent multiple evictors, so this fix should be good to go @sandfox

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

Ah nvm @sandfox I misread your comment, I will think about it. If we just need to start the pool, we can do it ourselves without any changes to pool library

@sandfox

sandfox commented Sep 8, 2017

Copy link
Copy Markdown
Collaborator

If it's any further influence on your decision, I'm probably going to add it if you don't :-) (I'll put it behind a minor version bump).
It is too easy to turn off autostart off and then never call start before acquiring resources. (and the reason I added it was to make some testing easier!)

@maxsommer

Copy link
Copy Markdown

Would be great if this could be merged here so the sequelize ResourceRequest timed out TimeoutError gets fixed.

@axetroy

axetroy commented Sep 14, 2017

Copy link
Copy Markdown

waiting for merged!

@tylerjwatson

Copy link
Copy Markdown

Agreed. This is an absolutely massive issue that affects production hardware. Chucking another vote in for the merge.

@sandfox
sandfox merged commit 547ebd7 into coopernurse:master Sep 14, 2017
@sandfox

sandfox commented Sep 14, 2017

Copy link
Copy Markdown
Collaborator

ok, @sushantdhiman fixes along with my proposed changes have now been merged and released as v3.1.8 on npm.
This should mean existing code that didn't call pool.start and had autostart=false now begins to "just work".

@sushantdhiman
sushantdhiman deleted the fix-evict branch September 14, 2017 07:46
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.

6 participants