Skip to content

Commit 8d5397d

Browse files
committed
fix tests
1 parent 0bf6b05 commit 8d5397d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

br/cmd/br/cmd.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ func DefineCommonFlags(cmd *cobra.Command) {
125125
}
126126

127127
func calculateMemoryLimit(memleft uint64) uint64 {
128+
// Special case: if no memory left, return 0
129+
if memleft == 0 {
130+
return 0
131+
}
132+
128133
// memreserved = f(memleft) = 512MB * memleft / (memleft + 4GB)
129134
// * f(0) = 0
130135
// * f(4GB) = 256MB
@@ -134,10 +139,11 @@ func calculateMemoryLimit(memleft uint64) uint64 {
134139
// Prevent uint64 underflow when memreserved >= memleft
135140
// This can happen when available memory is very low (< 256MB)
136141
if memreserved >= memleft {
137-
log.Warn("insufficient memory left for BR, using minimum limit",
142+
log.Warn("insufficient memory left for BR, capping to available",
138143
zap.Uint64("memleft", memleft),
139144
zap.Uint64("memreserved", memreserved))
140-
return quarterGiB // Return minimum limit (256 MB)
145+
// Return available memory instead of forcing a minimum
146+
return memleft
141147
}
142148

143149
// 0 memused memtotal-memreserved memtotal

0 commit comments

Comments
 (0)