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 load_factor to server_info in reporting mode #3817

Closed
wants to merge 3 commits into from

Conversation

cjcobb23
Copy link
Contributor

@cjcobb23 cjcobb23 commented Apr 9, 2021

load_factor was missing from server_info when the server was running in reporting mode. This commit fixes that by querying the p2p node for the load_factor, and propagating that info back to the client. If the p2p node is unavailable or returns an error, load_factor is set to 1.


This change is Reviewable

* load_factor was missing from server_info when the server was running in
  reporting mode. Now, the reporting mode server calls server_info on the p2p
  node, and propagates the load_factor back to the client.
@cjcobb23
Copy link
Contributor Author

cjcobb23 commented Apr 9, 2021

@ximinez Do you think we should set load_factor to 1 if the p2p node is unavailable?

@ximinez
Copy link
Collaborator

ximinez commented Apr 9, 2021

Do you think we should set load_factor to 1 if the p2p node is unavailable?

Yeah, I think that would be smart, and better than an error in this case.

Copy link
Collaborator

@mtrippled mtrippled left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Left an optional suggestion if it makes sense to you.

@@ -38,6 +40,17 @@ doServerInfo(RPC::JsonContext& context)
context.params.isMember(jss::counters) &&
context.params[jss::counters].asBool());

if (context.app.config().reporting())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this can be simplified into a try ... catch such as:
try:
ret[field] = proxied[result][jssinfo][load_factor]
catch:
ret[field] = 1

Copy link
Collaborator

Choose a reason for hiding this comment

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

This wouldn't work with a try/catch because operator[] doesn't throw. However, the const version returns a nullValue type, which we can test for.

Json::Value const proxied = forwardToP2p(context);
auto const lf = proxied[jss::result][jss::info][jss::load_factor];
ret[jss::info][jss::load_factor] = lf.isNull() ? 1: lf;

@@ -38,6 +40,17 @@ doServerInfo(RPC::JsonContext& context)
context.params.isMember(jss::counters) &&
context.params[jss::counters].asBool());

if (context.app.config().reporting())
Copy link
Collaborator

Choose a reason for hiding this comment

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

This wouldn't work with a try/catch because operator[] doesn't throw. However, the const version returns a nullValue type, which we can test for.

Json::Value const proxied = forwardToP2p(context);
auto const lf = proxied[jss::result][jss::info][jss::load_factor];
ret[jss::info][jss::load_factor] = lf.isNull() ? 1: lf;

Comment on lines 45 to 52
Json::Value proxied = forwardToP2p(context);
if (proxied.isMember(jss::result) &&
proxied[jss::result].isMember(jss::info) &&
proxied[jss::result][jss::info].isMember(jss::load_factor))
ret[jss::info][jss::load_factor] =
proxied[jss::result][jss::info][jss::load_factor];
else
ret[jss::info][jss::load_factor] = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this testable? Can you add or update a unit test for it?

Copy link
Contributor Author

@cjcobb23 cjcobb23 Apr 16, 2021

Choose a reason for hiding this comment

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

No this is not unit testable. Proxying requires running two servers and should be tested in integration/QA.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really testable without adding some type of virtual proxy. This functionality (reporting) will be split into its own code base, so I think this stuff will be removed from rippled itself in that project.

@cjcobb23
Copy link
Contributor Author

@ximinez What changes are you requesting on this? I see your suggestion about the try-catch and the unit test comment. I don't think this change is unit testable, and I interpreted the try-catch comment as just a suggestion. Let me know what you actually want me to change here.

@ximinez
Copy link
Collaborator

ximinez commented Apr 19, 2021

What changes are you requesting on this?

I try to mark significant suggestions as "changes requested" so I know I need to follow-up after a change is made, or there's a discussion to not do it.

@cjcobb23
Copy link
Contributor Author

What changes are you requesting on this?

I try to mark significant suggestions as "changes requested" so I know I need to follow-up after a change is made, or there's a discussion to not do it.

Got it, thanks for clarifying

Copy link
Contributor

@natenichols natenichols left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Collaborator

@ximinez ximinez left a comment

Choose a reason for hiding this comment

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

Looks good!

@cjcobb23 cjcobb23 added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label May 6, 2021
@manojsdoshi manojsdoshi mentioned this pull request May 7, 2021
@MarkusTeufelberger
Copy link
Collaborator

MarkusTeufelberger commented May 15, 2021

I don't use reporting mode, but I assume this is already in server_state (the machine-readable version of server_info)?

This was referenced Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants