Skip to content

Do not set nil value for log_backtrace_at flag#3077

Merged
manishrjain merged 1 commit intodgraph-io:masterfrom
jarifibrahim:log_backtrace_fix
Mar 1, 2019
Merged

Do not set nil value for log_backtrace_at flag#3077
manishrjain merged 1 commit intodgraph-io:masterfrom
jarifibrahim:log_backtrace_fix

Conversation

@jarifibrahim
Copy link
Copy Markdown
Contributor

@jarifibrahim jarifibrahim commented Feb 28, 2019

#3062 added capabilities to set flag values from config file (we need this for glog).
This caused an issue with the log_backtrace_at flag.
The flag is defined as flag.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace") where tracelocation is

// traceLocation represents the setting of the -log_backtrace_at flag.
type traceLocation struct {
	file string
	line int
}

If the value isn't specified the nil value for tracelocation type is set in the config, which is tracelocation{"", 0}.
But this value can't be set to the flag because of the check on line https://github.com/golang/glog/blob/master/glog.go#L374

This PR adds skips setting the flag to nil value if it nil in the config.

Fixes #3076

Signed-off-by: Ibrahim Jarif jarifibrahim@gmail.com


This change is Reviewable

dgraph-io#3062 added capabilities to set flag values from config file (we need this for glog).
This caused an issue with the log_backtrace_at flag.
The flag is defined as `flag.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace")` where tracelocation is

```
// traceLocation represents the setting of the -log_backtrace_at flag.
type traceLocation struct {
	file string
	line int
}
```
If the value isn't specified the nil value for `tracelocation` type is set in the config, which is `tracelocation{"", 0}`.
But this value can't be set to the flag because of the check on line https://github.com/golang/glog/blob/master/glog.go#L374

This PR adds skips setting the flag to nil value if it nil in the config.

Fixes dgraph-io#3076

Signed-off-by: Ibrahim Jarif <jarifibrahim@gmail.com>
@jarifibrahim
Copy link
Copy Markdown
Contributor Author

@danielmai can you please review this PR?

@danielmai
Copy link
Copy Markdown
Contributor

It looks like this addresses it. Will do some testing.

@jarifibrahim
Copy link
Copy Markdown
Contributor Author

I see 5 checks on other PRs but this one has only 2 checks. I don't know why.

@jarifibrahim
Copy link
Copy Markdown
Contributor Author

It looks like this addresses it. Will do some testing.

I wish we could have some tests.

Copy link
Copy Markdown
Contributor

@danielmai danielmai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Copy Markdown
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@manishrjain manishrjain merged commit e34f6a0 into dgraph-io:master Mar 1, 2019
@jarifibrahim jarifibrahim deleted the log_backtrace_fix branch March 1, 2019 05:31
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 19, 2019
dgraph-io#3062 added capabilities to set flag values from config file (we need this for glog).
This caused an issue with the log_backtrace_at flag.
The flag is defined as `flag.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace")` where tracelocation is

```
// traceLocation represents the setting of the -log_backtrace_at flag.
type traceLocation struct {
	file string
	line int
}
```
If the value isn't specified the nil value for `tracelocation` type is set in the config, which is `tracelocation{"", 0}`.
But this value can't be set to the flag because of the check on line https://github.com/golang/glog/blob/master/glog.go#L374

This PR adds skips setting the flag to nil value if it nil in the config.

Fixes dgraph-io#3076

Signed-off-by: Ibrahim Jarif <jarifibrahim@gmail.com>
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.

3 participants