Skip to content
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

Allow to set logger to nil #738

Closed
wants to merge 1 commit into from

Conversation

ivanvc
Copy link
Member

@ivanvc ivanvc commented Apr 24, 2024

The implementation doesn't look pretty. But now, when the logger is not defined (rather than using the discardLogger, skip logging altogether). By doing this, the main branch restores the benchmark results from release 1.3.

Related to #720.

@ivanvc ivanvc force-pushed the dont-log-if-logger-not-defined branch from 5a028f7 to 6469b69 Compare April 24, 2024 00:25
When the logger was introduced, the performance of the database
operations was affected. Allow setting the logger to nil; if
unset, ignore logging.

Signed-off-by: Ivan Valdes <[email protected]>
@ivanvc ivanvc force-pushed the dont-log-if-logger-not-defined branch from 6469b69 to e8d5c0a Compare April 24, 2024 03:07
@ivanvc
Copy link
Member Author

ivanvc commented Apr 24, 2024

/cc @ahrtr @fuweid @tjungblu @Elbehery

@ahrtr
Copy link
Member

ahrtr commented Apr 27, 2024

There are some places that you do not check if lg != nil, for example

  • (*DB) grow(...): line 1234/1256/1261 in db.go
  • (*DB) Sync(): line 1132 in db.go
  • Open: line 276 in db.go
  • ......

It's really error prone. Some code branches are not covered by test, so the issue may not be discovered until running in production environment.

Probably the second solution mentioned in #720 (comment) is safer.

@ivanvc
Copy link
Member Author

ivanvc commented Apr 28, 2024

There are some places that you do not check if lg != nil, for example

* (*DB) grow(...): line 1234/1256/1261 in db.go

* (*DB) Sync(): line 1132 in db.go

* Open: line 276 in db.go

* ......

It's really error prone. Some code branches are not covered by test, so the issue may not be discovered until running in production environment.

Probably the second solution mentioned in #720 (comment) is safer.

You're right; I realize I missed it in some places, e.g., db.Sync(). It definitely is more error-prone. I can review all log lines again if we want to take this approach. If we decide not to, then I don't think it's worth addressing all log lines.

@ivanvc
Copy link
Member Author

ivanvc commented Apr 29, 2024

Closing this PR. I'll open a new PR following the suggested approach.

@ivanvc ivanvc closed this Apr 29, 2024
@ivanvc ivanvc deleted the dont-log-if-logger-not-defined branch April 29, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants