prevent excessive ring fragmentation due to repeated space requests

Merging a ring now indicates whether the ring has been updated. This
prevents excessive allocation retries, which in turn can result in
repeated space requests - i.e. if an allocation cannot proceed due to
lack of space - which in turn can result in excessive ring
fragmentation since many of the requests will result in the creation
of a new ring entries, due to the need to split ranges.

Fixes #2181.
This commit is contained in:
Matthias Radestock committed 2016-04-17 12:40:18 +01:00
1 parent 0e54de63cc
commit 27632b118f
4 files changed
+72 -47

No files matched your search

+15
View File
@@ -325,6 +325,21 @@ func TestGossipShutdown(t *testing.T) {
CheckAllExpectedMessagesSent(alloc)
}
func TestNoFrag(t *testing.T) {
const cidr = "10.0.1.7/22"
resultChan := make(chan int)
for i := 0; i < 100; i++ {
allocs, router, subnet := makeNetworkOfAllocators(3, cidr)
allocs[1].Allocate("foo", subnet, returnFalse)
allocs[2].Allocate("bar", subnet, returnFalse)
allocs[2].actionChan <- func() {
resultChan <- len(allocs[2].ring.Entries)
}
require.True(t, <-resultChan < 5, "excessive ring fragmentation")
stopNetworkOfAllocators(allocs, router)
}
}
func TestTransfer(t *testing.T) {
const cidr = "10.0.1.7/22"
allocs, router, subnet := makeNetworkOfAllocators(3, cidr)