From 89e3cd7864feff094e70f4c5ea672c06b053cef7 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sat, 20 Jul 2024 15:55:53 +0100 Subject: [PATCH 01/18] added hash/complete counts --- conn_stats.go | 8 ++++++++ mmap_span/mmap_span.go | 16 ++++++++++++---- piece.go | 4 ++-- storage/interface.go | 2 +- storage/mmap.go | 4 ++-- torrent.go | 26 ++++++++++++++++++++++++-- 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/conn_stats.go b/conn_stats.go index a288d4d39f..da7f19f756 100644 --- a/conn_stats.go +++ b/conn_stats.go @@ -87,6 +87,14 @@ func (cs *ConnStats) receivedChunk(size int64) { cs.BytesReadData.Add(size) } +func (cs *ConnStats) pieceHashed(size int64) { + cs.BytesHashed.Add(size) +} + +func (cs *ConnStats) pieceCompleted(size int64) { + cs.BytesCompleted.Add(size) +} + func (cs *ConnStats) incrementPiecesDirtiedGood() { cs.PiecesDirtiedGood.Add(1) } diff --git a/mmap_span/mmap_span.go b/mmap_span/mmap_span.go index a343c1670b..0b9d3a1851 100644 --- a/mmap_span/mmap_span.go +++ b/mmap_span/mmap_span.go @@ -23,6 +23,7 @@ type MMapSpan struct { mu sync.RWMutex mMaps []Mmap dirtyPieces roaring.Bitmap + dirtySize int64 segmentLocater segments.Index Created bool InfoHash infohash.T @@ -35,22 +36,23 @@ func (ms *MMapSpan) Append(mMap Mmap) { ms.mMaps = append(ms.mMaps, mMap) } -func (ms *MMapSpan) Flush() (errs []error) { +func (ms *MMapSpan) Flush(onFlush func(size int64)) (errs []error) { ms.mu.Lock() defer ms.mu.Unlock() if ms.flushTimer == nil { ms.flushTimer = time.AfterFunc(ms.FlushTime, func() { // TODO deal with logging errors - ms.flushMaps(true) + ms.flushMaps(onFlush, true) }) } return } -func (ms *MMapSpan) flushMaps(lock bool) (errs []error) { +func (ms *MMapSpan) flushMaps(onFlush func(size int64), lock bool) (errs []error) { var flushedCallback FlushedCallback var dirtyPieces *roaring.Bitmap + var dirtySize int64 errs = func() (errs []error) { if lock { @@ -59,6 +61,7 @@ func (ms *MMapSpan) flushMaps(lock bool) (errs []error) { } dirtyPieces = ms.dirtyPieces.Clone() + dirtySize = ms.dirtySize if ms.flushTimer != nil { ms.flushTimer = nil @@ -73,6 +76,7 @@ func (ms *MMapSpan) flushMaps(lock bool) (errs []error) { if len(errs) == 0 { flushedCallback = ms.FlushedCallback ms.dirtyPieces = roaring.Bitmap{} + ms.dirtySize = 0 } } @@ -81,6 +85,9 @@ func (ms *MMapSpan) flushMaps(lock bool) (errs []error) { if flushedCallback != nil { flushedCallback(ms.InfoHash, dirtyPieces) + if onFlush != nil { + onFlush(dirtySize) + } } return @@ -92,7 +99,7 @@ func (ms *MMapSpan) Close() (errs []error) { if ms.flushTimer != nil { ms.flushTimer.Stop() - errs = ms.flushMaps(false) + errs = ms.flushMaps(nil, false) ms.flushTimer = nil } @@ -171,6 +178,7 @@ func (ms *MMapSpan) WriteAt(index int, p []byte, off int64) (n int, err error) { ms.mu.Lock() ms.dirtyPieces.Add(uint32(index)) + ms.dirtySize += int64(len(p)) ms.mu.Unlock() return diff --git a/piece.go b/piece.go index 4be0975b13..80c5f8791d 100644 --- a/piece.go +++ b/piece.go @@ -56,9 +56,9 @@ func (p *Piece) Storage() storage.Piece { return p.t.storage.Piece(p.Info()) } -func (p *Piece) Flush() { +func (p *Piece) Flush(onFlushed func(size int64)) { if p.t.storage.Flush != nil { - _ = p.t.storage.Flush() + _ = p.t.storage.Flush(onFlushed) } } diff --git a/storage/interface.go b/storage/interface.go index cb7b24b3fd..324289842b 100644 --- a/storage/interface.go +++ b/storage/interface.go @@ -22,7 +22,7 @@ type TorrentCapacity *func() (cap int64, capped bool) type TorrentImpl struct { Piece func(p metainfo.Piece) PieceImpl Close func() error - Flush func() error + Flush func(onFlushed func(size int64)) error // Storages that share the same space, will provide equal pointers. The function is called once // to determine the storage for torrents sharing the same function pointer, and mutated in // place. diff --git a/storage/mmap.go b/storage/mmap.go index 640b428f78..4d4eda1b43 100644 --- a/storage/mmap.go +++ b/storage/mmap.go @@ -90,8 +90,8 @@ func (ts *mmapTorrentStorage) Close() error { return nil } -func (ts *mmapTorrentStorage) Flush() error { - errs := ts.span.Flush() +func (ts *mmapTorrentStorage) Flush(onFlush func(size int64)) error { + errs := ts.span.Flush(nil) if len(errs) > 0 { return errs[0] } diff --git a/torrent.go b/torrent.go index ccd12b2b2c..b229f1cf78 100644 --- a/torrent.go +++ b/torrent.go @@ -2633,11 +2633,26 @@ func (t *Torrent) pieceHashed(piece pieceIndex, passed bool, hashIoErr error) { t.clearPieceTouchers(piece, true) hasDirtyChunks := p.hasDirtyChunks(true) + + var err error + if hasDirtyChunks { - p.Flush() + p.Flush(func(size int64) { + t.allStats(func(cs *ConnStats) { + cs.pieceCompleted(size) + }) + }) + + err = p.Storage().MarkComplete(true) + } else { + err = p.Storage().MarkComplete(!hasDirtyChunks) + if err == nil { + t.allStats(func(cs *ConnStats) { + cs.pieceCompleted(int64(p.length(true))) + }) + } } - err := p.Storage().MarkComplete(!hasDirtyChunks) if err != nil { t.logger.Levelf(log.Warning, "%T: error marking piece complete %d: %s", t.storage, piece, err) } @@ -2810,9 +2825,12 @@ func (t *Torrent) tryCreatePieceHasher(lock bool) bool { break } + var length int64 + func() { t.mu.Lock() defer t.mu.Unlock() + length = int64(p.length(false)) t.piecesQueuedForHash.Remove(bitmap.BitIndex(p.index)) p.mu.Lock() p.hashing = true @@ -2839,6 +2857,10 @@ func (t *Torrent) tryCreatePieceHasher(lock bool) bool { p.mu.Unlock() hashing.Add(-1) + t.allStats(func(cs *ConnStats) { + cs.pieceHashed(length) + }) + t.hashResults <- hashResult{p.index, correct, failedPeers, copyErr} } }() From 760777308777e6a2eab7b6d31aa8c323cd9efa36 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sat, 20 Jul 2024 16:22:29 +0100 Subject: [PATCH 02/18] added hash/complete counts --- t.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/t.go b/t.go index 4a7de069e5..3add0ae9d8 100644 --- a/t.go +++ b/t.go @@ -251,7 +251,14 @@ func (t *Torrent) DownloadPieces(begin, end pieceIndex) { if checkCompletion && !storage.IsNew() { if sum, _, err := t.hashPiece(piece); err == nil && sum == *piece.hash { + size := int64(piece.length(true)) + t.allStats(func(cs *ConnStats) { + cs.pieceHashed(size) + }) storage.MarkComplete(false) + t.allStats(func(cs *ConnStats) { + cs.pieceCompleted(size) + }) t.updatePieceCompletion(piece.index, true) return nil } From b9cfe1051673944070f8ef9d9992ddeb9faba6f7 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sun, 21 Jul 2024 13:53:45 +0100 Subject: [PATCH 03/18] ds printer --- mmap_span/mmap_span.go | 1 + 1 file changed, 1 insertion(+) diff --git a/mmap_span/mmap_span.go b/mmap_span/mmap_span.go index 0b9d3a1851..d421b94327 100644 --- a/mmap_span/mmap_span.go +++ b/mmap_span/mmap_span.go @@ -179,6 +179,7 @@ func (ms *MMapSpan) WriteAt(index int, p []byte, off int64) (n int, err error) { ms.mu.Lock() ms.dirtyPieces.Add(uint32(index)) ms.dirtySize += int64(len(p)) + fmt.Println("DS", index, int64(len(p)), ms.dirtySize) ms.mu.Unlock() return From 116eca1c3721d0d3d79a56322bd38137132fd2de Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sun, 21 Jul 2024 13:54:28 +0100 Subject: [PATCH 04/18] ds printer --- mmap_span/mmap_span.go | 1 + 1 file changed, 1 insertion(+) diff --git a/mmap_span/mmap_span.go b/mmap_span/mmap_span.go index d421b94327..1747b339b7 100644 --- a/mmap_span/mmap_span.go +++ b/mmap_span/mmap_span.go @@ -86,6 +86,7 @@ func (ms *MMapSpan) flushMaps(onFlush func(size int64), lock bool) (errs []error if flushedCallback != nil { flushedCallback(ms.InfoHash, dirtyPieces) if onFlush != nil { + fmt.Println("FDS", dirtySize) onFlush(dirtySize) } } From 77cfed7c2e446d30248c7c35214e71336fe1ea4d Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sun, 21 Jul 2024 14:10:08 +0100 Subject: [PATCH 05/18] ds printer --- mmap_span/mmap_span.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mmap_span/mmap_span.go b/mmap_span/mmap_span.go index 1747b339b7..1fe63a023c 100644 --- a/mmap_span/mmap_span.go +++ b/mmap_span/mmap_span.go @@ -85,8 +85,8 @@ func (ms *MMapSpan) flushMaps(onFlush func(size int64), lock bool) (errs []error if flushedCallback != nil { flushedCallback(ms.InfoHash, dirtyPieces) + fmt.Println("FDS", onFlush, dirtySize) if onFlush != nil { - fmt.Println("FDS", dirtySize) onFlush(dirtySize) } } @@ -180,7 +180,6 @@ func (ms *MMapSpan) WriteAt(index int, p []byte, off int64) (n int, err error) { ms.mu.Lock() ms.dirtyPieces.Add(uint32(index)) ms.dirtySize += int64(len(p)) - fmt.Println("DS", index, int64(len(p)), ms.dirtySize) ms.mu.Unlock() return From aa4502c556a004f6700ef721f1d3456829352ecc Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sun, 21 Jul 2024 14:17:54 +0100 Subject: [PATCH 06/18] ds printer --- mmap_span/mmap_span.go | 9 +++++---- storage/mmap.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mmap_span/mmap_span.go b/mmap_span/mmap_span.go index 1fe63a023c..be07440bf5 100644 --- a/mmap_span/mmap_span.go +++ b/mmap_span/mmap_span.go @@ -85,10 +85,11 @@ func (ms *MMapSpan) flushMaps(onFlush func(size int64), lock bool) (errs []error if flushedCallback != nil { flushedCallback(ms.InfoHash, dirtyPieces) - fmt.Println("FDS", onFlush, dirtySize) - if onFlush != nil { - onFlush(dirtySize) - } + } + + fmt.Println("FDS", onFlush, dirtySize) + if onFlush != nil { + onFlush(dirtySize) } return diff --git a/storage/mmap.go b/storage/mmap.go index 4d4eda1b43..875a34da89 100644 --- a/storage/mmap.go +++ b/storage/mmap.go @@ -91,7 +91,7 @@ func (ts *mmapTorrentStorage) Close() error { } func (ts *mmapTorrentStorage) Flush(onFlush func(size int64)) error { - errs := ts.span.Flush(nil) + errs := ts.span.Flush(onFlush) if len(errs) > 0 { return errs[0] } From 4838a83ce1172b37d1b8d96ed63220e575e7d7b1 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sun, 21 Jul 2024 14:25:12 +0100 Subject: [PATCH 07/18] remove ds printer --- mmap_span/mmap_span.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mmap_span/mmap_span.go b/mmap_span/mmap_span.go index be07440bf5..a8fb518dfa 100644 --- a/mmap_span/mmap_span.go +++ b/mmap_span/mmap_span.go @@ -87,8 +87,7 @@ func (ms *MMapSpan) flushMaps(onFlush func(size int64), lock bool) (errs []error flushedCallback(ms.InfoHash, dirtyPieces) } - fmt.Println("FDS", onFlush, dirtySize) - if onFlush != nil { + if onFlush != nil && dirtySize > 0 { onFlush(dirtySize) } From db0b955b61352a16d2a31e39ef947ac871804b25 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sun, 21 Jul 2024 20:19:08 +0100 Subject: [PATCH 08/18] added bytes flushed --- conn_stats.go | 5 +++++ torrent.go | 21 ++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/conn_stats.go b/conn_stats.go index da7f19f756..a7493c9681 100644 --- a/conn_stats.go +++ b/conn_stats.go @@ -26,6 +26,7 @@ type ConnStats struct { BytesReadUsefulIntendedData Count BytesHashed Count + BytesFlushed Count BytesCompleted Count ChunksWritten Count @@ -95,6 +96,10 @@ func (cs *ConnStats) pieceCompleted(size int64) { cs.BytesCompleted.Add(size) } +func (cs *ConnStats) pieceFlushed(size int64) { + cs.BytesFlushed.Add(size) +} + func (cs *ConnStats) incrementPiecesDirtiedGood() { cs.PiecesDirtiedGood.Add(1) } diff --git a/torrent.go b/torrent.go index b229f1cf78..995219f194 100644 --- a/torrent.go +++ b/torrent.go @@ -2634,26 +2634,21 @@ func (t *Torrent) pieceHashed(piece pieceIndex, passed bool, hashIoErr error) { hasDirtyChunks := p.hasDirtyChunks(true) - var err error - if hasDirtyChunks { p.Flush(func(size int64) { t.allStats(func(cs *ConnStats) { - cs.pieceCompleted(size) + cs.pieceFlushed(size) }) }) - - err = p.Storage().MarkComplete(true) - } else { - err = p.Storage().MarkComplete(!hasDirtyChunks) - if err == nil { - t.allStats(func(cs *ConnStats) { - cs.pieceCompleted(int64(p.length(true))) - }) - } } - if err != nil { + err := p.Storage().MarkComplete(!hasDirtyChunks) + + if err == nil { + t.allStats(func(cs *ConnStats) { + cs.pieceCompleted(int64(p.length(true))) + }) + } else { t.logger.Levelf(log.Warning, "%T: error marking piece complete %d: %s", t.storage, piece, err) } From e00524bed2365f84e0ea72135c811806ce570245 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 10:21:52 +0100 Subject: [PATCH 09/18] update const per host --- client.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 5996593414..c885d69a1f 100644 --- a/client.go +++ b/client.go @@ -217,7 +217,10 @@ func (cl *Client) init(cfg *ClientConfig) { DialContext: cfg.HTTPDialContext, // I think this value was observed from some webseeds. It seems reasonable to extend it // to other uses of HTTP from the client. - MaxConnsPerHost: 10, + // This has been updated as under heavy load the golang http lib seems to panic, MaxIdleConnsPerHost + // is set to stop the http runtime recycling sockets + MaxConnsPerHost: 50, + MaxIdleConnsPerHost: 25, } } } @@ -1249,7 +1252,7 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *PeerCon if !c.requestedMetadataPiece(piece) { return fmt.Errorf("got unexpected piece %d", piece) } - + c.mu.Lock() c.metadataRequests[piece] = false c.lastUsefulChunkReceived = time.Now() @@ -1260,7 +1263,7 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *PeerCon return fmt.Errorf("data has bad offset in payload: %d", begin) } t.saveMetadataPiece(piece, payload[begin:]) - + err = t.maybeCompleteMetadata() if err != nil { // Log this at the Torrent-level, as we don't partition metadata by Peer yet, so we From 9f65af93ecccecea3af70acdbce160c7ec1b30fc Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 11:57:07 +0100 Subject: [PATCH 10/18] don't request for completed torrent --- webseed-peer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webseed-peer.go b/webseed-peer.go index a4a8c2e451..262a1e15d8 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -184,7 +184,7 @@ func (ws *webseedPeer) requester(i int) { ws.requesterCond.L.Lock() defer ws.requesterCond.L.Unlock() - for !ws.peer.closed.IsSet() && i < ws.maxRequesters { + for !(ws.peer.closed.IsSet() || ws.peer.t.Complete.Bool()) && i < ws.maxRequesters { // Restart is set if we don't need to wait for the requestCond before trying again. restart := false From 9f8d4055852378f87d71a347e177173dec49cf38 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 14:56:32 +0100 Subject: [PATCH 11/18] zero desired requests on close --- peer.go | 4 ++++ webseed-peer.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index e2de52bcd4..dddb3ed3c6 100644 --- a/peer.go +++ b/peer.go @@ -395,6 +395,9 @@ func (p *Peer) close(lockTorrent bool) { if p.t != nil { p.t.decPeerPieceAvailability(p, false, false) } + + p.desiredRequestLen = 0 + for _, f := range p.callbacks.PeerClosed { f(p) } @@ -1138,6 +1141,7 @@ func (p *Peer) desiredRequests(lock bool) int { p.mu.RLock() defer p.mu.RUnlock() } + return p.desiredRequestLen } diff --git a/webseed-peer.go b/webseed-peer.go index 262a1e15d8..32c196f544 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -448,7 +448,7 @@ func requestUpdate(ws *webseedPeer) { if p == &ws.peer { this = "*" } - flags := p.connectionFlags() + flags := p.StatusFlags() peerInfo = append(peerInfo, fmt.Sprintf("%s%s:p=%d,d=%d: %f", this, flags, pieces, desired, rate)) }, false) From c802be4205c7c2773f0a82f64271249fceefe143 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 18:42:37 +0100 Subject: [PATCH 12/18] update cons per host --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index c885d69a1f..45e946e667 100644 --- a/client.go +++ b/client.go @@ -219,8 +219,8 @@ func (cl *Client) init(cfg *ClientConfig) { // to other uses of HTTP from the client. // This has been updated as under heavy load the golang http lib seems to panic, MaxIdleConnsPerHost // is set to stop the http runtime recycling sockets - MaxConnsPerHost: 50, - MaxIdleConnsPerHost: 25, + MaxConnsPerHost: 500, + MaxIdleConnsPerHost: 500, } } } From e5388ddeeb6803f356c3abf5a8715fe9d7f52779 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 21:02:57 +0100 Subject: [PATCH 13/18] ban after 5 drops --- webseed-peer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webseed-peer.go b/webseed-peer.go index 32c196f544..f23f8b0179 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -498,7 +498,7 @@ func (cn *webseedPeer) ban() { banCount := cn.peer.banCount cn.peer.mu.Unlock() - if banCount > 16 && !cn.peer.closed.IsSet() { + if banCount > 5 && !cn.peer.closed.IsSet() { cn.peer.close(true) } } From 6eb9a839240754e3ea3228792f83fe91782818e6 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 22:23:12 +0100 Subject: [PATCH 14/18] remove max conns --- client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 45e946e667..e7fc922459 100644 --- a/client.go +++ b/client.go @@ -219,8 +219,10 @@ func (cl *Client) init(cfg *ClientConfig) { // to other uses of HTTP from the client. // This has been updated as under heavy load the golang http lib seems to panic, MaxIdleConnsPerHost // is set to stop the http runtime recycling sockets - MaxConnsPerHost: 500, - MaxIdleConnsPerHost: 500, + + // attempt to avoid panic: net/http: internal error: connCount underflow + //MaxConnsPerHost: 500, + MaxIdleConnsPerHost: 50, } } } From 5a41be49d7c0766426e68c6aa96f2701165787b8 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 22:33:58 +0100 Subject: [PATCH 15/18] remove max conns --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index e7fc922459..28804fd67b 100644 --- a/client.go +++ b/client.go @@ -221,8 +221,8 @@ func (cl *Client) init(cfg *ClientConfig) { // is set to stop the http runtime recycling sockets // attempt to avoid panic: net/http: internal error: connCount underflow - //MaxConnsPerHost: 500, - MaxIdleConnsPerHost: 50, + MaxConnsPerHost: 0, + MaxIdleConnsPerHost: 100, } } } From 5278e37f74f267482c13d821d8e8253f99931a96 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Mon, 22 Jul 2024 22:35:36 +0100 Subject: [PATCH 16/18] remove max conns --- client.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/client.go b/client.go index 28804fd67b..0cabe8a44a 100644 --- a/client.go +++ b/client.go @@ -215,12 +215,7 @@ func (cl *Client) init(cfg *ClientConfig) { cl.httpClient.Transport = &http.Transport{ Proxy: cfg.HTTPProxy, DialContext: cfg.HTTPDialContext, - // I think this value was observed from some webseeds. It seems reasonable to extend it - // to other uses of HTTP from the client. - // This has been updated as under heavy load the golang http lib seems to panic, MaxIdleConnsPerHost - // is set to stop the http runtime recycling sockets - - // attempt to avoid panic: net/http: internal error: connCount underflow + // Don't set maxconns - attempt to avoid panic: net/http: internal error: connCount underflow MaxConnsPerHost: 0, MaxIdleConnsPerHost: 100, } From fcadd3ad53a5cddd0b92ee665d87dd395e7f3400 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Tue, 23 Jul 2024 07:56:00 +0100 Subject: [PATCH 17/18] remove max conns --- client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client.go b/client.go index 0cabe8a44a..cfec6d7b01 100644 --- a/client.go +++ b/client.go @@ -216,8 +216,7 @@ func (cl *Client) init(cfg *ClientConfig) { Proxy: cfg.HTTPProxy, DialContext: cfg.HTTPDialContext, // Don't set maxconns - attempt to avoid panic: net/http: internal error: connCount underflow - MaxConnsPerHost: 0, - MaxIdleConnsPerHost: 100, + MaxConnsPerHost: 0, } } } From 31175cf1eac4c915cdbc9f89539915b4a0a08e25 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Tue, 23 Jul 2024 08:06:48 +0100 Subject: [PATCH 18/18] remove max conns --- client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index cfec6d7b01..83828bb070 100644 --- a/client.go +++ b/client.go @@ -215,7 +215,8 @@ func (cl *Client) init(cfg *ClientConfig) { cl.httpClient.Transport = &http.Transport{ Proxy: cfg.HTTPProxy, DialContext: cfg.HTTPDialContext, - // Don't set maxconns - attempt to avoid panic: net/http: internal error: connCount underflow + // Don't set maxconns - to avoid panic: net/http: internal error: connCount underflow + // which is caused under load due to an ongoing issue in the go http transport code MaxConnsPerHost: 0, } }