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

Bulk mutator fixes #1880

Merged
merged 3 commits into from
Jan 30, 2019
Merged

Bulk mutator fixes #1880

merged 3 commits into from
Jan 30, 2019

Conversation

dopiera
Copy link
Contributor

@dopiera dopiera commented Jan 28, 2019

This addresses two issues in BulkMutator:

  • -1 as index in mutations which have never been confirmed by the service
  • OK status returned for such mutations.

Whenever a mutation was not confirmed by the service (e.g. because the stream was broken every retry), it was returned as failed (correct) with -1 as original index (incorrect).

In such cases OK was returned, which was very confusing - it broke the invariant that every failure has a non-zero exit code, which I believe users would assume.


This change is Reviewable

Whenever a mutation was not confirmed by the server (e.g. because the
stream was broken every retry), it was returned as failed (correct) with
-1 as original index (incorrect). This patch fixes it.
If BulkMutator never gets a response for a mutation it used to return
OK, which was very confusing - it broke the invariant that every failure
has a non-zero exit code, which I believe users would assume.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 28, 2019
@dopiera dopiera added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 28, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 28, 2019
@dopiera
Copy link
Contributor Author

dopiera commented Jan 28, 2019

This is required for #1881.

@dopiera dopiera requested a review from coryan January 28, 2019 03:00
@codecov
Copy link

codecov bot commented Jan 28, 2019

Codecov Report

Merging #1880 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1880      +/-   ##
==========================================
- Coverage   92.88%   92.85%   -0.03%     
==========================================
  Files         297      298       +1     
  Lines       16790    16884      +94     
==========================================
+ Hits        15595    15678      +83     
- Misses       1195     1206      +11
Impacted Files Coverage Δ
google/cloud/bigtable/mutations.h 100% <ø> (ø) ⬆️
google/cloud/bigtable/internal/bulk_mutator.cc 98.71% <100%> (+0.05%) ⬆️
google/cloud/bigtable/table.cc 95.74% <0%> (-4.26%) ⬇️
google/cloud/storage/internal/curl_client.cc 95.92% <0%> (-0.12%) ⬇️
google/cloud/storage/internal/bucket_requests.cc 97.34% <0%> (-0.04%) ⬇️
google/cloud/storage/list_buckets_reader.h 95.23% <0%> (ø) ⬆️
google/cloud/storage/list_objects_reader.h 95.45% <0%> (ø) ⬆️
google/cloud/storage/object_access_control.cc 100% <0%> (ø) ⬆️
google/cloud/storage/object_access_control.h 100% <0%> (ø) ⬆️
google/cloud/bigtable/table.h 100% <0%> (ø) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f4ae11...e70aa25. Read the comment docs.

Copy link
Contributor

@devjgm devjgm 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 @coryan and @dopiera)


google/cloud/bigtable/internal/bulk_mutator.cc, line 165 at r1 (raw file):

  int idx = 0;
  for (auto& mutation : *pending_mutations_.mutable_entries()) {
    auto &annotation = pending_annotations_[idx++];

I'm new to the bigtable code here, so please forgive my newbie question. But it likes there is an implicit assumption/guarantee that pending_mutations_ and pending_annotations_ are the same size. That is they are "parallel arrays" (or containers) of some objects, where the items at index i are related.

If that's the case, should we consider making this implicit assumption an explicit requirement in the code? To be specific, maybe we should consider having the BulkMutator class replace both the pending_mutations_ and pending_annotations collections with a single data member like:

struct MutationAnnotation {
  google::bigtable::v2::Mutation mutation;
  Annotations annotation;
};
std::vector<MutationAnnotation> pending_;

I wonder if that would result in clearer code that is also easier to use and iterate. For example, here you wouldn't need to keep a separate index counter; you would only need a simple range-for loop.

Thoughts?

Copy link
Contributor Author

@dopiera dopiera 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 @coryan and @devjgm)


google/cloud/bigtable/internal/bulk_mutator.cc, line 165 at r1 (raw file):

Previously, devjgm (Greg Miller) wrote…

I'm new to the bigtable code here, so please forgive my newbie question. But it likes there is an implicit assumption/guarantee that pending_mutations_ and pending_annotations_ are the same size. That is they are "parallel arrays" (or containers) of some objects, where the items at index i are related.

If that's the case, should we consider making this implicit assumption an explicit requirement in the code? To be specific, maybe we should consider having the BulkMutator class replace both the pending_mutations_ and pending_annotations collections with a single data member like:

struct MutationAnnotation {
  google::bigtable::v2::Mutation mutation;
  Annotations annotation;
};
std::vector<MutationAnnotation> pending_;

I wonder if that would result in clearer code that is also easier to use and iterate. For example, here you wouldn't need to keep a separate index counter; you would only need a simple range-for loop.

Thoughts?

Hi Greg,
I think you're right. How about I do what you're suggesting in another PR, though, not to mix the bugfix with refactoring?

Copy link
Contributor Author

@dopiera dopiera 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 @coryan and @devjgm)


google/cloud/bigtable/internal/bulk_mutator.cc, line 165 at r1 (raw file):

Previously, dopiera (Marek Dopiera) wrote…

Hi Greg,
I think you're right. How about I do what you're suggesting in another PR, though, not to mix the bugfix with refactoring?

Actually, after I started writing the refactor, I realized that pending_mutations_ is a single proto. In order to achieve what you're suggesting, we'd have to keep the proto's entries in a vector and serialize them right before sending. I think that would actually add complexity and cost, so we shouldn't do it. Does this make sense?

@coryan coryan added the api: bigtable Issues related to the Bigtable API. label Jan 28, 2019
@devjgm
Copy link
Contributor

devjgm commented Jan 28, 2019

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

google/cloud/bigtable/internal/bulk_mutator.cc, line 165 at r1 (raw file):

Previously, dopiera (Marek Dopiera) wrote…
Actually, after I started writing the refactor, I realized that pending_mutations_ is a single proto. In order to achieve what you're suggesting, we'd have to keep the proto's entries in a vector and serialize them right before sending. I think that would actually add complexity and cost, so we shouldn't do it. Does this make sense?

I see. OK. Thanks for explaining.

@devjgm devjgm closed this Jan 28, 2019
@dopiera
Copy link
Contributor Author

dopiera commented Jan 28, 2019

Did you close it on purpose? I think we need this fix.

@devjgm
Copy link
Contributor

devjgm commented Jan 28, 2019

D'oh! sorry.

@devjgm devjgm reopened this Jan 28, 2019
@dopiera dopiera added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 29, 2019
@coryan coryan removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 29, 2019
for (auto& mutation : *pending_mutations_.mutable_entries()) {
result.emplace_back(
FailedMutation(SingleRowMutation(std::move(mutation)), ok_status));
auto &annotation = pending_annotations_[idx++];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Please place the & adjacent to the auto, not the variable name. per the style guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the annotation variable altogether.

@coryan coryan added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 30, 2019
@coryan
Copy link
Contributor

coryan commented Jan 30, 2019

LGTM, please let's wait until Kokoro has a chance to run over this.

@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 30, 2019
@codecov
Copy link

codecov bot commented Jan 30, 2019

Codecov Report

Merging #1880 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1880      +/-   ##
==========================================
- Coverage   92.88%   92.85%   -0.03%     
==========================================
  Files         297      298       +1     
  Lines       16790    16884      +94     
==========================================
+ Hits        15595    15678      +83     
- Misses       1195     1206      +11
Impacted Files Coverage Δ
google/cloud/bigtable/mutations.h 100% <ø> (ø) ⬆️
google/cloud/bigtable/internal/bulk_mutator.cc 98.71% <100%> (+0.05%) ⬆️
google/cloud/bigtable/table.cc 95.74% <0%> (-4.26%) ⬇️
google/cloud/storage/internal/curl_client.cc 95.92% <0%> (-0.12%) ⬇️
google/cloud/storage/internal/bucket_requests.cc 97.34% <0%> (-0.04%) ⬇️
google/cloud/storage/list_buckets_reader.h 95.23% <0%> (ø) ⬆️
google/cloud/storage/list_objects_reader.h 95.45% <0%> (ø) ⬆️
google/cloud/storage/object_access_control.cc 100% <0%> (ø) ⬆️
google/cloud/storage/object_access_control.h 100% <0%> (ø) ⬆️
google/cloud/bigtable/table.h 100% <0%> (ø) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f4ae11...e70aa25. Read the comment docs.

@dopiera dopiera merged commit efaed61 into googleapis:master Jan 30, 2019
@dopiera dopiera deleted the bulk_mutator_fixes branch January 30, 2019 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the Bigtable API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants