mgutz / dat

Go Postgres Data Access Toolkit
Other
612 stars 62 forks source link

Disabling logger makes errors become nil, and generates nil pointer dereferences #55

Open manuel-huez opened 7 years ago

manuel-huez commented 7 years ago

We had to disable error logging coming from dat- especially since some queries are extremely long and we don't want to print them when a query crashes. Doing so started generating pointer dereferences in sqlx-runner/execer.go when trying to access res.RowsAffected, meaning res is nil. Doing some digging, it turns out the exec function is returning nil for both values, even when an error should be returned. In fact, logSQLError now seems to be returning nil, even if the parameter isn't.

Our environment variable is set to LOGXI=dat*=OFF.

I'm not sure if this is an intended behavior of the logger, but it is generating some extremely bad side-effects on our production environment.

aksentyev commented 7 years ago

The same issue.

aksentyev commented 7 years ago

And such behavior breaks errors handling, because all errors becomes nil

mgutz commented 7 years ago

This is a problem within the logging package (one I wrote). I found the bug in logger and will update dat soon.