mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-24 23:05:01 +03:00
* fix(node-sync): do not latch node disable when master allows (#6870) nodeDisableIsStale trusted any node-reported enable=false whose limits matched the master's, treating it as a genuine verdict and latching it on the master. But matching limits no longer prove the verdict: a single stray false (a depleted snapshot the master later re-enabled, a stale disableInvalidClients hit, or a push that lagged a quota reset) leaves the client stuck disabled on the node, and every master tick flips the client's state again. This is the loop reported in #6870. Make nodeDisableIsStale a single rule: stale iff the master's own deadline and quota still permit the client. A genuine combined-quota or expiry disable (masterLimitsAllowClient == false) still latches, preserving #4917. Mirror the same rule in ClientTrafficEnableMergeExpr so the SQL UPDATE and the Go in-memory replay cannot drift. * fix(node-sync): keep node usage over quota latching a node disable Dropping the matching-limits latch (#6870) let the master re-enable a client the node had genuinely counted past its quota whenever the master's own counters lagged, e.g. after a seeded-at-zero adoption, reopening #4917. A node's enable=false now stays latched when the node's own usage already spends the master's quota; otherwise the master's limits decide, so a stray disable no longer loops. Restores TestNodeQuotaDisable_SameExpiryStillLatches as it was on main. --------- Co-authored-by: Alireza Ahmadi <alireza7@gmail.com>
This commit is contained in:
@@ -37,23 +37,23 @@ func GreatestExpr(a, b string) string {
|
||||
return fmt.Sprintf("MAX(%s, %s)", a, b)
|
||||
}
|
||||
|
||||
// ClientTrafficEnableMergeExpr: placeholders nodeEnable, nodeExpiry, nodeTotal,
|
||||
// now, deltaUp, deltaDown. Mirrors nodeDisableIsStale (#6228 / #4917).
|
||||
// ClientTrafficEnableMergeExpr: placeholders nodeEnable, now, deltaUp, deltaDown,
|
||||
// nodeUp, nodeDown. Mirrors nodeDisableIsStale (#6228 / #4917 / #6870).
|
||||
func ClientTrafficEnableMergeExpr() string {
|
||||
if IsPostgres() {
|
||||
return `CASE
|
||||
WHEN ?::boolean THEN enable::boolean
|
||||
WHEN (expiry_time <> CAST(? AS BIGINT) OR total <> CAST(? AS BIGINT))
|
||||
AND (expiry_time <= 0 OR expiry_time > CAST(? AS BIGINT))
|
||||
AND (total <= 0 OR up + ? + down + ? < total) THEN enable::boolean
|
||||
WHEN (expiry_time <= 0 OR expiry_time > CAST(? AS BIGINT))
|
||||
AND (total <= 0 OR up + ? + down + ? < total)
|
||||
AND (total <= 0 OR CAST(? AS BIGINT) + CAST(? AS BIGINT) < total) THEN enable::boolean
|
||||
ELSE false
|
||||
END`
|
||||
}
|
||||
return `CASE
|
||||
WHEN ? THEN enable
|
||||
WHEN (expiry_time <> CAST(? AS BIGINT) OR total <> CAST(? AS BIGINT))
|
||||
AND (expiry_time <= 0 OR expiry_time > CAST(? AS BIGINT))
|
||||
AND (total <= 0 OR up + ? + down + ? < total) THEN enable
|
||||
WHEN (expiry_time <= 0 OR expiry_time > CAST(? AS BIGINT))
|
||||
AND (total <= 0 OR up + ? + down + ? < total)
|
||||
AND (total <= 0 OR CAST(? AS BIGINT) + CAST(? AS BIGINT) < total) THEN enable
|
||||
ELSE 0
|
||||
END`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user