You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/11/15 15:19:59 UTC

[GitHub] rob05c edited a comment on issue #3030: Riak cluster cleanup on cluster rebuid

rob05c edited a comment on issue #3030: Riak cluster cleanup on cluster rebuid
URL: https://github.com/apache/trafficcontrol/issues/3030#issuecomment-439076409
 
 
   I missed the `SetFinalizer` call being added. That needs removed. Go "finalizers" should be used very, very carefully, and very, very sparingly. They don't behave predictably, and have all kinds of subtle nuances. 
   
   For example, they're all run in a single goroutine; does `sharedCluster.Stop()` return very quickly? I doubt it. Then it blocks every other finalizer in the entire application (potentially in libraries we use, and aren't even aware of).
   
   That's just one example. The fact is, the Go garbage collector simply wasn't designed for finalizers. Go doesn't do RAII. And `runtime.SetFinalizer` is subtle and dangerous, and should be avoided if at all possible. Code that needs to "destruct" should be refactored to do so reliably and predictably.
   
   In particular, is there reason not to change that to 
   ```
   go func() {
     if err := sharedCluster.Stop(); err != nil {
       log.Errorln("Stopping Riak cluster: " + err.Error())
     }
   }()
   ```
   ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services