Skip to content

Eviction doesn't happen when autostart=false #174

Closed
sequelize/sequelize
#8305

Description

@tauren

Is there a known reason that setting autostart: false would cause eviction to not happen?

    const factory = {
      create: () => { ... },
      destroy: (channel) => { ... }
    }
    const options = {
      autostart: false, 
      evictionRunIntervalMillis: 1000,
      max: 20,
      min: 5
    }
    const apiPool = genericPool.createPool(factory, options)

When I change autostart to true, the destroy factory gets executed. When it is set to false, the destroy method is never executed.

Activity

  1. sandfox commented on Jan 8, 2017

    @sandfox
    Collaborator

    Errmmm maybe :-) (the docs probably aren't at all clear here)
    The evictor itself only gets "started" when the pool is started, so if you create a pool with autostart: false the evictor will do nothing until you call pool.start()

    Just to clarify what you are seeing?

    • you creating the pool with autostart: false
    • then calling pool.start()
    • the evictor is never getting called despite the pool having been started?
  2. patriksimek commented on Apr 25, 2017

    @patriksimek

    This behavior confused me as well. Documentation for autostart states

    should the pool start creating resources etc once the constructor is called

    I have expected autostart to only affect the behavior of creating initial resources to satisfy the min option. There should be a mention that the pool must be started manually for eviction to work. Right now, there is no mention about the pool.start() method in the docs at all.

  3. self-assigned this
    on Apr 26, 2017
  4. sandfox commented on Apr 26, 2017

    @sandfox
    Collaborator

    @patriksimek Yeah, the docs could be clearer here, and the evictor start behaviour is definitely in the undefined/implicit category. What problems did this cause you, or how did you discover this? You probably have a use case I haven't considered and would be good to make sure I cover it properly.

  5. patriksimek commented on Apr 26, 2017

    @patriksimek

    @sandfox It started with a finding, that after updating to v3, idle connections was not closed automatically. So after a few minutes, I have discovered that the library no longer uses reapIntervalMillis (which was on by default) and uses evictionRunIntervalMillis instead (which is off by default). There is no mention about this change in migration guide by the way.

    But, even setting a positive value in evictionRunIntervalMillis did not helped. So, after another few minutes of looking to the node-pool source code, I have discovered that eviction requires start method to be called. And start method requires autostart to be turned on (I had it turned off).

    This is how I get there. My expectation was, that with autostart turned off, the pool opens up resources gradually as they're created and destroy them only when the number of open resources reaches min value.

    Anyway, great work, I'm using this lib in node-mssql for a years without any problems.

  6. sandfox commented on Apr 26, 2017

    @sandfox
    Collaborator

    thanks for the quick response! it now makes sense to me (at least without looking at the code), I'll see what I come up with and some documentation fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions