lionsoul2014/ip2region · error

v6 searcher pool already closed

Error message

v6 searcher pool already closed

What it means

Go service lifecycle error: v6Search could not borrow a searcher because the v6 pool has been closed; identical mechanism to the v4 twin — BorrowSearcher returns nil once Close has run.

Source

Thrown at binding/golang/service/ip2region.go:175

		return "", fmt.Errorf("v4 searcher pool already closed")
	}
	defer ip2r.v4Pool.ReturnSearcher(v4Searcher)
	return v4Searcher.Search(ipBytes)
}

func (ip2r *Ip2Region) v6Search(ipBytes []byte) (string, error) {
	if ip2r.v6InMemSearcher != nil {
		return ip2r.v6InMemSearcher.Search(ipBytes)
	}

	// v6 search is disabled
	if ip2r.v6Pool == nil {
		return "", nil
	}

	v6Searcher := ip2r.v6Pool.BorrowSearcher()
	if v6Searcher == nil {
		return "", fmt.Errorf("v6 searcher pool already closed")
	}
	defer ip2r.v6Pool.ReturnSearcher(v6Searcher)
	return v6Searcher.Search(ipBytes)
}

func (ip2r *Ip2Region) Close() {
	ip2r.CloseTimeout(time.Second * 10)
}

func (ip2r *Ip2Region) CloseTimeout(d time.Duration) {
	if ip2r.v4Pool != nil {
		ip2r.v4Pool.CloseTimeout(d)
	}

	if ip2r.v6Pool != nil {
		ip2r.v6Pool.CloseTimeout(d)
	}
}

View on GitHub (pinned to c1a1fc7d59)

Solutions

  1. Recreate the Ip2Region service if you need to search again after Close
  2. Coordinate shutdown so no search races with Close
  3. Treat this sentinel as a signal to rebuild the service
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at binding/golang/service/ip2region.go:175 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of lionsoul2014/ip2region@c1a1fc7d59 (2026-09-02). Data as JSON: /api/errors/eaf7c634a9171cea. Report an issue: GitHub.