mapbox / mapbox/tilelive-bridge

Error: pool is draining and cannot accept work

Open
#80 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
63
Forks
40
PR merge metrics
No merged PRs in 30d

Description

Generic pool has one `throw` inside its code [here](https://github.com/coopernurse/node-pool/blob/b89166bd10eb3e28f7499c394cde8cace8b9fbb6/lib/generic-pool.js#L384-L386) where it does `throw new Error('pool is draining and cannot accept work')`.

This is unhandled in tilelive-bridge currently: we don't have a try/catch around `acquire` [here](https://github.com/mapbox/tilelive-bridge/blob/master/index.js#L146).

We either need to handle this with a try/catch or fix our usage of generic-pool to ensure this condition is never hit.

It looks like this condition started to be hit after https://github.com/mapbox/tilelive-bridge/commit/dd0c5ef09c66eb2a52dcb49253d20d1e633c65c8 at least in the case of Mapbox Studio Classic. What appears to be happening is that in the Studio Classic source editor a new data file is added and tile requests are made to `tilelive-bridge.getTile`. At the same time Studio Classic also calls `update()` which triggers re-creating the pool (in fact debugging indicates update is called twice when a file is saved for unknown reasons at https://github.com/mapbox/mapbox-studio-classic/blob/00c1a4e316a945d45732d8204e794168ea64720c/lib/source.js#L176-L177). The pool then gets drained and the in-flight tile requests then hit the unhandled `pool is draining and cannot accept work` and the whole process goes down.

TODO:
- [ ] spend more time confirming I'm understanding the above scenario right.
- [ ] ponder if this bug is related to the need to have https://github.com/mapbox/tilelive-bridge/commit/cbaa67d5582fa829cce90a39591e5945773f556c

/cc @BergWerkGIS @yhahn

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.

Research direction

Start in index.js at the acquire call around line 146, then inspect the generic-pool throw at lib/generic-pool.js lines 384-386 and the pool recreation triggered by update(). Reproduce or confirm the concurrent update and tile-request scenario described in the issue. Done means tile requests no longer crash the process when the pool is draining, either through handling or corrected pool usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.