fix: отмена скана при исчерпании соединений Postgres

- Распознавание 53300/too many clients и др. в isStoreCapacityOrConnExhausted

- SaveHostResult/порты/SNMP: при фатальной ошибке БД — CancelScan; ctx отменяет дальнейший SNMP

- Воркеры при ctx.Done быстро скипают оставшиеся IP без SNMP (дренаж канала)

Made-with: Cursor
This commit is contained in:
PTah
2026-04-13 15:41:16 +10:00
parent 0086302605
commit 3292f77e5c
3 changed files with 97 additions and 18 deletions
+21
View File
@@ -0,0 +1,21 @@
package scans
import (
"errors"
"testing"
)
func TestIsStoreCapacityOrConnExhausted(t *testing.T) {
if !isStoreCapacityOrConnExhausted(errors.New(`FATAL: sorry, too many clients already (SQLSTATE 53300)`)) {
t.Fatal("expected too many clients")
}
if !isStoreCapacityOrConnExhausted(errors.New(`remaining connection slots are reserved for roles`)) {
t.Fatal("expected reserved slots")
}
if isStoreCapacityOrConnExhausted(errors.New("duplicate key value violates unique constraint")) {
t.Fatal("unexpected match for unrelated error")
}
if isStoreCapacityOrConnExhausted(nil) {
t.Fatal("nil should be false")
}
}