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

Safiefy protobuf #2477

Merged
merged 6 commits into from
Jul 20, 2020
Merged

Safiefy protobuf #2477

merged 6 commits into from
Jul 20, 2020

Conversation

purew
Copy link
Contributor

@purew purew commented Jul 17, 2020

PR adds checks on protobuf serializing and de-serializing in the worker, and logs request-id of failing requests.

Produces log:

2020/07/17 18:31:10.483608 [INFO] Got Loki Request 0
2020/07/17 18:31:10.486783 [ANALYTICS] locations_count::2
2020/07/17 18:31:10.486822 [ANALYTICS] costing_type::auto
2020/07/17 18:31:10.486859 [ANALYTICS] total_location_distance::7.487539km
2020/07/17 18:31:10.622645 [INFO] Got Thor Request 0
2020/07/17 18:31:10.622708 [ERROR] Failed parsing pbf in Thor::Worker
2020/07/17 18:31:10.622739 [ANALYTICS] 400::Failed parsing pbf in Thor::Worker request_id=0
0 2020/07/17 18:31:10.622851 400 239

@purew purew requested review from danpaz and gknisely July 17, 2020 18:34
@@ -96,6 +96,16 @@ thor_worker_t::thor_worker_t(const boost::property_tree::ptree& config,
thor_worker_t::~thor_worker_t() {
}

std::string serialize_to_pbf(Api& request) {
std::string buf;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's likely a bit unoptimized to allocate the string every time but it should still be very little work in comparison to actually running pathfinding or mapmatching or similar.

std::string buf;
if (!request.SerializeToString(&buf)) {
LOG_ERROR("Failed serializing to pbf in Thor::Worker - trace_route");
throw valhalla_exception_t{401, boost::optional<std::string>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is valhalla_exception_t appropriate here instead of std::runtime_error?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at other exceptions thrown here, seems like valhalla_exception_t is the right choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aye, removed the runtime error for valhalla_exception_t

Example log:

```
2020/07/17 18:31:10.483608 [INFO] Got Loki Request 0
2020/07/17 18:31:10.486783 [ANALYTICS] locations_count::2
2020/07/17 18:31:10.486822 [ANALYTICS] costing_type::auto
2020/07/17 18:31:10.486859 [ANALYTICS] total_location_distance::7.487539km
2020/07/17 18:31:10.622645 [INFO] Got Thor Request 0
2020/07/17 18:31:10.622708 [ERROR] Failed parsing pbf in Thor::Worker
2020/07/17 18:31:10.622739 [ANALYTICS] 400::Failed parsing pbf in Thor::Worker request_id=0
0 2020/07/17 18:31:10.622851 400 239
```
std::string serialize_to_pbf(Api& request) {
std::string buf;
if (!request.SerializeToString(&buf)) {
LOG_ERROR("Failed serializing to pbf in Thor::Worker - trace_route");
Copy link
Contributor

Choose a reason for hiding this comment

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

We're calling this helper from optimized_route, route & trace_route. So maybe we can be remove the trace_route part of the error message since it could be generated for other options.

mandeepsandhu
mandeepsandhu previously approved these changes Jul 17, 2020
Copy link
Contributor

@mandeepsandhu mandeepsandhu left a comment

Choose a reason for hiding this comment

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

Just 1 minor comment. Otherwise looks good to me 👍

@danpaz
Copy link
Collaborator

danpaz commented Jul 20, 2020

Pushed an update to the osrm error message for the 401 valhalla exception 6037949

@purew purew merged commit ff06cdb into master Jul 20, 2020
@purew purew deleted the safiefy-protobuf branch July 20, 2020 16:26
@purew purew added this to the Sprint 14 - Left Turn milestone Jul 20, 2020
yuzheyan added a commit that referenced this pull request Jul 28, 2020
* 'master' of github.com:valhalla/valhalla:
  Make tile building reproducible (#2480)
  Fix install-script for ubuntu 18.04 (#2306) (#2486)
  nit(git): Configures changelog to resolve conflicts with union strategy (#2489)
  feat(traffictile.h): Adds versioning checks (#2484)
  Fix dereferencing of end for std::lower_bound and possible UB (#2488)
  Minor fixes to tests (#2483)
  nit: Missing changelog entry (#2478)
  Safiefy protobuf (#2477)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants