mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Avoid alignment of reapNetwork and tableEntries
Make sure that the network is garbage collected after the entries. Entries to be deleted requires that the network is present. Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
parent
053a534ab1
commit
a4e64d05c1
3 changed files with 19 additions and 13 deletions
|
@ -17,11 +17,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
reapInterval = 30 * time.Minute
|
// The garbage collection logic for entries leverage the presence of the network.
|
||||||
reapPeriod = 5 * time.Second
|
// For this reason the expiration time of the network is put slightly higher than the entry expiration so that
|
||||||
retryInterval = 1 * time.Second
|
// there is at least 5 extra cycle to make sure that all the entries are properly deleted before deleting the network.
|
||||||
nodeReapInterval = 24 * time.Hour
|
reapEntryInterval = 30 * time.Minute
|
||||||
nodeReapPeriod = 2 * time.Hour
|
reapNetworkInterval = reapEntryInterval + 5*reapPeriod
|
||||||
|
reapPeriod = 5 * time.Second
|
||||||
|
retryInterval = 1 * time.Second
|
||||||
|
nodeReapInterval = 24 * time.Hour
|
||||||
|
nodeReapPeriod = 2 * time.Hour
|
||||||
)
|
)
|
||||||
|
|
||||||
type logWriter struct{}
|
type logWriter struct{}
|
||||||
|
@ -300,8 +304,9 @@ func (nDB *NetworkDB) reconnectNode() {
|
||||||
// the reaper runs. NOTE nDB.reapTableEntries updates the reapTime with a readlock. This
|
// the reaper runs. NOTE nDB.reapTableEntries updates the reapTime with a readlock. This
|
||||||
// is safe as long as no other concurrent path touches the reapTime field.
|
// is safe as long as no other concurrent path touches the reapTime field.
|
||||||
func (nDB *NetworkDB) reapState() {
|
func (nDB *NetworkDB) reapState() {
|
||||||
nDB.reapNetworks()
|
// The reapTableEntries leverage the presence of the network so garbage collect entries first
|
||||||
nDB.reapTableEntries()
|
nDB.reapTableEntries()
|
||||||
|
nDB.reapNetworks()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nDB *NetworkDB) reapNetworks() {
|
func (nDB *NetworkDB) reapNetworks() {
|
||||||
|
@ -414,8 +419,8 @@ func (nDB *NetworkDB) gossip() {
|
||||||
// Collect stats and print the queue info, note this code is here also to have a view of the queues empty
|
// Collect stats and print the queue info, note this code is here also to have a view of the queues empty
|
||||||
network.qMessagesSent += len(msgs)
|
network.qMessagesSent += len(msgs)
|
||||||
if printStats {
|
if printStats {
|
||||||
logrus.Infof("NetworkDB stats - net:%s Entries:%d Queue qLen:%d netPeers:%d netMsg/s:%d",
|
logrus.Infof("NetworkDB stats - netID:%s leaving:%t netPeers:%d entries:%d Queue qLen:%d netMsg/s:%d",
|
||||||
nid, network.entriesNumber, broadcastQ.NumQueued(), broadcastQ.NumNodes(),
|
nid, network.leaving, broadcastQ.NumNodes(), network.entriesNumber, broadcastQ.NumQueued(),
|
||||||
network.qMessagesSent/int((nDB.config.StatsPrintPeriod/time.Second)))
|
network.qMessagesSent/int((nDB.config.StatsPrintPeriod/time.Second)))
|
||||||
network.qMessagesSent = 0
|
network.qMessagesSent = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ func (nDB *NetworkDB) handleNetworkEvent(nEvent *NetworkEvent) bool {
|
||||||
n.ltime = nEvent.LTime
|
n.ltime = nEvent.LTime
|
||||||
n.leaving = nEvent.Type == NetworkEventTypeLeave
|
n.leaving = nEvent.Type == NetworkEventTypeLeave
|
||||||
if n.leaving {
|
if n.leaving {
|
||||||
n.reapTime = reapInterval
|
n.reapTime = reapNetworkInterval
|
||||||
|
|
||||||
// The remote node is leaving the network, but not the gossip cluster.
|
// The remote node is leaving the network, but not the gossip cluster.
|
||||||
// Mark all its entries in deleted state, this will guarantee that
|
// Mark all its entries in deleted state, this will guarantee that
|
||||||
|
@ -242,7 +242,7 @@ func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent) bool {
|
||||||
// field. If that is not the case, this can be a BUG
|
// field. If that is not the case, this can be a BUG
|
||||||
if e.deleting && e.reapTime == 0 {
|
if e.deleting && e.reapTime == 0 {
|
||||||
logrus.Warnf("handleTableEvent object %+v has a 0 reapTime, is the cluster running the same docker engine version?", tEvent)
|
logrus.Warnf("handleTableEvent object %+v has a 0 reapTime, is the cluster running the same docker engine version?", tEvent)
|
||||||
e.reapTime = reapInterval
|
e.reapTime = reapEntryInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
nDB.Lock()
|
nDB.Lock()
|
||||||
|
|
|
@ -405,7 +405,7 @@ func (nDB *NetworkDB) DeleteEntry(tname, nid, key string) error {
|
||||||
node: nDB.config.NodeName,
|
node: nDB.config.NodeName,
|
||||||
value: value,
|
value: value,
|
||||||
deleting: true,
|
deleting: true,
|
||||||
reapTime: reapInterval,
|
reapTime: reapEntryInterval,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nDB.sendTableEvent(TableEventTypeDelete, nid, tname, key, entry); err != nil {
|
if err := nDB.sendTableEvent(TableEventTypeDelete, nid, tname, key, entry); err != nil {
|
||||||
|
@ -478,7 +478,7 @@ func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) {
|
||||||
node: oldEntry.node,
|
node: oldEntry.node,
|
||||||
value: oldEntry.value,
|
value: oldEntry.value,
|
||||||
deleting: true,
|
deleting: true,
|
||||||
reapTime: reapInterval,
|
reapTime: reapEntryInterval,
|
||||||
}
|
}
|
||||||
|
|
||||||
// we arrived at this point in 2 cases:
|
// we arrived at this point in 2 cases:
|
||||||
|
@ -619,8 +619,9 @@ func (nDB *NetworkDB) LeaveNetwork(nid string) error {
|
||||||
return fmt.Errorf("could not find network %s while trying to leave", nid)
|
return fmt.Errorf("could not find network %s while trying to leave", nid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logrus.Debugf("%s: leaving network %s", nDB.config.NodeName, nid)
|
||||||
n.ltime = ltime
|
n.ltime = ltime
|
||||||
n.reapTime = reapInterval
|
n.reapTime = reapNetworkInterval
|
||||||
n.leaving = true
|
n.leaving = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue