-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] influxdb: replace log.Fatal() by log.Print() #61
Conversation
I didn't test it yet: Will the client send data, as soon as the database becomes reachable again? |
On a Fatal/panic kills yanic, so you got a nice log to find the problem. A Print will keep yanic running. |
The goal is to keep yanic running, even if the database is not available, to have at least the latest data available for the map. |
database/influxdb/database.go
Outdated
@@ -114,7 +114,7 @@ func (conn *Connection) addWorker() { | |||
// create new batch | |||
timer.Reset(batchTimeout) | |||
if bp, err = client.NewBatchPoints(bpConfig); err != nil { | |||
log.Fatal(err) | |||
log.Print(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NewBatchPoints
only fails if the configured precision can not be passed. In that case it will always fail and should panic:
https://github.com/influxdata/influxdb/blob/3b700863eaa3fae65a995ce65ca12fc85c0a6995/client/v2/client.go#L213
@@ -134,7 +134,7 @@ func (conn *Connection) addWorker() { | |||
log.Println("saving", len(bp.Points()), "points") | |||
|
|||
if err = conn.client.Write(bp); err != nil { | |||
log.Fatal(err) | |||
log.Print(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be fine since the InfluxDB client uses net/http
that has timeouts and reconnects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool
Fatal() calls os.Exit(1), which causes yanic.service to fail if database is not reachable.
@@ -149,7 +149,7 @@ func (conn *Connection) addWorker() { | |||
log.Println("saving", len(bp.Points()), "points") | |||
|
|||
if err = conn.client.Write(bp); err != nil { | |||
log.Fatal(err) | |||
log.Print(err) | |||
} | |||
writeNow = false | |||
bp = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@corny: Müsste dieses bp = nil
nicht in ein else
Zweig? Damit die daten nicht verloren gehen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kann man machen, dann stellt sich aber die Frage, wie lange man Punkte sammeln will.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mir geht es erst einmal darum, dass yanic für die Auslieferung der aktuellen Daten weiterläuft und sich wieder mit der influxdb verbindet, wenn diese wieder online ist. Dass die Daten aus der Offline-Zeit nicht in der DB landen, entspricht ja auch der Erwartung.
Generell wäre es natürlich schick, wenn man auch diese Daten sammeln kann und nachträglich in der DB anlegt, aber da sehe ich auch das Problem der Zwischenspeicherung.
Passt! 👍 |
Fatal() calls os.Exit(1), which causes yanic.service to fail if database is not reachable.