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

Add LogRequest variable to config input #5197

Merged
merged 6 commits into from
May 13, 2020

Conversation

animesh2049
Copy link
Contributor

@animesh2049 animesh2049 commented Apr 14, 2020

Fixes DGRAPH-1123

This PR adds support for logRequest config param. logRequest can have true/false values. True
value of logRequest enables logging of all requests coming to alphas. False value of logRequest
disables it.
Users will be able to dynamically change this param using graphql admin endpoint.
Sample query:

mutation {
  config(input: {logRequest: true}){
    response {
      code
      message
    }
  }
}

Internally we have added one more field in WorkerOptions(WorkerConfig) called as LogRequest
of int32 type. Value of this field is checked atomically upon every request arrival. If value of
LogRequest is 1, it results in logging of requests.


This change is Reviewable

Docs Preview: Dgraph Preview

@animesh2049 animesh2049 requested review from manishrjain and a team as code owners April 14, 2020 09:55
Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @animesh2049 and @manishrjain)


graphql/admin/config.go, line 43 at r1 (raw file):

	// It will be used like a boolean. We are keeping int32 because we want to
	// modify it using atomics(atomics doesn't have support for bool).
	LogRequest int32

From a user perspective, the mechanism to avoid using bools is confusing and is an internal limitation of golang to which they are now exposed. I think having a lock-protected boolean would be better. It could lead to contention but I don't think this endpoint will be called very often so that shouldn't be a problem.

Copy link
Contributor Author

@animesh2049 animesh2049 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @manishrjain and @martinmr)


graphql/admin/config.go, line 43 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

From a user perspective, the mechanism to avoid using bools is confusing and is an internal limitation of golang to which they are now exposed. I think having a lock-protected boolean would be better. It could lead to contention but I don't think this endpoint will be called very often so that shouldn't be a problem.

Changed it to bool

Copy link
Contributor

@pawanrawal pawanrawal 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 4 files at r3, 3 of 3 files at r4.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @animesh2049, @manishrjain, and @martinmr)


graphql/admin/config.go, line 56 at r4 (raw file):

	if input.LogRequest != nil {
		if *input.LogRequest {
			atomic.StoreInt32(&x.WorkerConfig.LogRequest, 1)

0 can be false and 1 can be true.


x/config.go, line 87 at r3 (raw file):

	// BadgerKeyFile is the file containing the key used for encryption. Enterprise only feature.
	BadgerKeyFile string
	// LogRequest indicates whehter alpha should print all the requests

whether

Copy link
Contributor

@ashish-goswami ashish-goswami left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 4 files reviewed, 3 unresolved discussions (waiting on @manishrjain, @martinmr, and @pawanrawal)


graphql/admin/config.go, line 56 at r4 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

0 can be false and 1 can be true.

Done.


x/config.go, line 87 at r3 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

whether

Done.

Copy link
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.

Reviewed 1 of 4 files at r3, 1 of 3 files at r4, 2 of 2 files at r5.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @animesh2049, @martinmr, and @pawanrawal)


graphql/admin/config.go, line 43 at r1 (raw file):

Previously, animesh2049 (Animesh Chandra Pathak) wrote…

Changed it to bool

Why is this a pointer, when LruMB is not?


graphql/admin/config.go, line 55 at r5 (raw file):

	// input.LogRequest will be nil, when it is not specified explicitly in config request.
	if input.LogRequest != nil {
		if *input.LogRequest {

No need for 2 level if. Can be one statement. But, again, don't think LogRequest should be a pointer to begin with.

Copy link
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.

Based on slack discussion, keep the logRequest bool pointer, but do address other comments.

:lgtm:

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @animesh2049, @martinmr, and @pawanrawal)

Copy link
Contributor

@gja gja left a comment

Choose a reason for hiding this comment

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

Please move into a function, but otherwise looks ok

}

// input.LogRequest will be nil, when it is not specified explicitly in config request.
if input.LogRequest != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

workerConfig.SetLogRequest(true)

workerConfig.ShouldLogRequest()

// Ideally LogRequest should be a bool value. But we are reading it using atomics across
// queries hence it has been kept as int32. LogRequest value 1 enables logging of requests
// coming to alphas and 0 disables it.
LogRequest int32
Copy link
Contributor

Choose a reason for hiding this comment

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

make this private, and use the getters / setters

@ashish-goswami ashish-goswami merged commit 449c06b into master May 13, 2020
@ashish-goswami ashish-goswami deleted the animesh2049/log-requests branch May 13, 2020 11:38
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 18, 2020
Fixes: DGRAPH-1123

This PR adds support for logRequest config param. logRequest can have true/false values. True
value of logRequest enables logging of all requests coming to alphas. False value of logRequest
disables it.
Users will be able to dynamically change this param using graphql admin endpoint.
Sample query:

mutation {
  config(input: {logRequest: true}){
    response {
      code
      message
    }
  }
}
Internally we have added one more field in WorkerOptions(WorkerConfig) called as LogRequest
of int32 type. Value of this field is checked atomically upon every request arrival. If value of
LogRequest is 1, it results in logging of requests.


Co-authored-by: Ashish Goswami <[email protected]>
OmarAyo pushed a commit that referenced this pull request Dec 8, 2020
Fixes: DGRAPH-1123

This PR adds support for logRequest config param. logRequest can have true/false values. True
value of logRequest enables logging of all requests coming to alphas. False value of logRequest
disables it.
Users will be able to dynamically change this param using graphql admin endpoint.
Sample query:

mutation {
  config(input: {logRequest: true}){
    response {
      code
      message
    }
  }
}
Internally we have added one more field in WorkerOptions(WorkerConfig) called as LogRequest
of int32 type. Value of this field is checked atomically upon every request arrival. If value of
LogRequest is 1, it results in logging of requests.

Co-authored-by: Ashish Goswami <[email protected]>
(cherry picked from commit 449c06b)
OmarAyo pushed a commit that referenced this pull request Dec 8, 2020
Fixes: DGRAPH-1123

This PR adds support for logRequest config param. logRequest can have true/false values. True
value of logRequest enables logging of all requests coming to alphas. False value of logRequest
disables it.
Users will be able to dynamically change this param using graphql admin endpoint.
Sample query:

mutation {
  config(input: {logRequest: true}){
    response {
      code
      message
    }
  }
}
Internally we have added one more field in WorkerOptions(WorkerConfig) called as LogRequest
of int32 type. Value of this field is checked atomically upon every request arrival. If value of
LogRequest is 1, it results in logging of requests.


Co-authored-by: Ashish Goswami <[email protected]>
(cherry picked from commit 449c06b)
OmarAyo added a commit that referenced this pull request Dec 10, 2020
* Add LogRequest variable to config input (#5197)

Fixes: DGRAPH-1123

This PR adds support for logRequest config param. logRequest can have true/false values. True
value of logRequest enables logging of all requests coming to alphas. False value of logRequest
disables it.
Users will be able to dynamically change this param using graphql admin endpoint.
Sample query:

mutation {
  config(input: {logRequest: true}){
    response {
      code
      message
    }
  }
}
Internally we have added one more field in WorkerOptions(WorkerConfig) called as LogRequest
of int32 type. Value of this field is checked atomically upon every request arrival. If value of
LogRequest is 1, it results in logging of requests.


Co-authored-by: Ashish Goswami <[email protected]>
(cherry picked from commit 449c06b)

* fix(GraphQL): don't update cacheMb if not specified by user (GRAPHQL-888) (#7103)

Fixes GRAPHQL-888.
Previously, if you ran this request:
```
$ curl -H "Content-Type: application/json" http://localhost:8080/admin -d '{"query": "mutation {config(input: {logRequest: false}){response {code message}}}"}'
```
Alpha logs would also print this:
```
I1205 22:22:51.684693 2681396 middlewares.go:178] GraphQL admin mutation. Name =  config
I1205 22:22:51.684724 2681396 config.go:38] Got config update through GraphQL admin API
I1205 22:22:51.684810 2681396 worker.go:138] Updating cacheMb to 0
```
Indicating that cacheMb was also updated, even it wasn't specified in the request.

This PR fixes this issue.

(cherry picked from commit c03c327)

# Conflicts:
#	graphql/admin/config.go

Co-authored-by: Animesh Chandra Pathak <[email protected]>
Co-authored-by: Abhimanyu Singh Gaur <[email protected]>
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.

6 participants