Etcd: Handling panic calls in goroutines created.

Created on 28 Feb 2018  路  7Comments  路  Source: etcd-io/etcd

I am starting an etcd server by calling embed.StartEtcd(). This eventually does try to create a backend at here in a different goroutine. Internally, it results in a panic in case of an error. The panic call is in a different goroutine than the one starting etcd. This makes error handling not possible. Deferred handling of panics using recover() can be trickled up only till the top-level function executing in the goroutine.

It would be better if the code that creates goroutines handles the panic instances and return err.

arequestion

All 7 comments

This makes error handling not possible.

Where do you handle the errors? And what was the panic?

The panic occurs here. It would be nice to return an error in that case at embed.StartEtcd(). I believe that would make it robust to use.

Seems too low-level of an error to expose to users. Also breaks current interface, although mvcc is assumed to be internal. Do you have specific use case that needed that bolt.Open error exposed?

I would like to start etcd from within my application and not via cmd line. The panic will result in an app crash as I would not be able to handle the panic which occurs at a goroutine over which I don't have control to handle the panic. Handling the panic at library level will help make it robust.

@georgekuruvillak it may be simpler to do cmd.Run() on etcd from the application if it can't tolerate panics; there are a lot of panics in the core server

what's causing the db to fail to open?

Thanks @heyitsanthony, @gyuho

what's causing the db to fail to open?

@heyitsanthony one reason can be a corrupt db file.

cmd.Run() works well with me. However, it does run etcd as a seperate command. It would have been perfect if I could have used embed.StartEtcd() but this solves my issue. 馃槈

@georgekuruvillak

Even if embed.StartEtcd() wont panic during initialization, etcd might panic in other places when it hits a unrecoverable error internally during its runtime.

Was this page helpful?
0 / 5 - 0 ratings