You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2019/07/10 18:20:16 UTC
[trafficcontrol] branch master updated: Fix TO-Go's internal shared
riak cluster finalizer (#3706)
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new c753414 Fix TO-Go's internal shared riak cluster finalizer (#3706)
c753414 is described below
commit c75341440ca25beeebf37242229f4aa687c70cd5
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Jul 10 12:20:10 2019 -0600
Fix TO-Go's internal shared riak cluster finalizer (#3706)
Stop the old riak cluster at garbage-collection time instead of
immediately after creating a new riak cluster. Requests might be
currently in flight using the old cluster, and stopping the old cluster
with requests in flight can cause those requests to fail. Instead, all
in-flight requests using the old cluster will be handled normally, and
once there are no in-flight requests to reference the old riak cluster,
it will be stopped and garbage-collected. Once the new riak cluster is
started, any new requests that arrive will be handled by the new riak
cluster, so the old riak cluster should be stopped and garbage-collected
shortly after that point.
---
traffic_ops/traffic_ops_golang/riaksvc/riak_services.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/traffic_ops/traffic_ops_golang/riaksvc/riak_services.go b/traffic_ops/traffic_ops_golang/riaksvc/riak_services.go
index e0b5bed..daafc3b 100644
--- a/traffic_ops/traffic_ops_golang/riaksvc/riak_services.go
+++ b/traffic_ops/traffic_ops_golang/riaksvc/riak_services.go
@@ -321,10 +321,15 @@ func GetPooledCluster(tx *sql.Tx, authOptions *riak.AuthOptions, riakPort *uint)
newcluster, err := GetRiakCluster(newservers, authOptions)
if err == nil {
if err := newcluster.Start(); err == nil {
- log.Infoln("New cluster started")
+ log.Infof("New riak cluster started: %p\n", newcluster)
if sharedCluster != nil {
- runtime.SetFinalizer(sharedCluster, sharedCluster.Stop())
+ runtime.SetFinalizer(sharedCluster, func(c *riak.Cluster) {
+ log.Infof("running finalizer for riak sharedcluster (%p)\n", c)
+ if err := c.Stop(); err != nil {
+ log.Errorf("in finalizer for riak sharedcluster (%p): stopping cluster: %s\n", c, err.Error())
+ }
+ })
}
sharedCluster = newcluster