Merge pull request #1521 from ripienaar/unlimited_accounts

ensure unlimited account limits are calculated correctly
This commit is contained in:
Derek Collison
2020-07-20 07:50:17 -05:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -773,11 +773,11 @@ func (jsa *jsAccount) limitsExceeded(storeType StorageType) bool {
var exceeded bool
jsa.mu.Lock()
if storeType == MemoryStorage {
if jsa.memUsed > jsa.limits.MaxMemory {
if jsa.limits.MaxMemory > 0 && jsa.memUsed > jsa.limits.MaxMemory {
exceeded = true
}
} else {
if jsa.storeUsed > jsa.limits.MaxStore {
if jsa.limits.MaxStore > 0 && jsa.storeUsed > jsa.limits.MaxStore {
exceeded = true
}
}

View File

@@ -5223,6 +5223,17 @@ func TestJetStreamStreamStorageTrackingAndLimits(t *testing.T) {
if usage.Memory > uint64(al.MaxMemory) {
t.Fatalf("Expected memory to not exceed limit of %d, got %d", al.MaxMemory, usage.Memory)
}
// make sure that unlimited accounts work
al.MaxMemory = -1
if err := gacc.UpdateJetStreamLimits(al); err != nil {
t.Fatalf("Unexpected error updating jetstream account limits: %v", err)
}
for i := 0; i < toSend; i++ {
sendStreamMsg(t, nc, "LIMITS", "Hello World!")
}
}
func TestJetStreamStreamFileStorageTrackingAndLimits(t *testing.T) {