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

C++ migration: port write stream-related part of FSTRemoteStore #2335

Merged
merged 127 commits into from
Feb 7, 2019

Conversation

var-const
Copy link
Contributor

@var-const var-const commented Feb 1, 2019

No description provided.

void OnWriteStreamOpen() override;

/**
* Handles a successful handshake response from the server, which is our cue
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems essentially duplicated from the parent class. I think you could just eliminate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/**
* Handles the closing of the StreamingWrite RPC, either because of an error
* or because the RPC has been terminated by the client or the server.
*/
Copy link
Member

Choose a reason for hiding this comment

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

(again, though the comment is much simpler here. I think it's still essentially the same though.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/**
* Handles the closing of the StreamingWrite RPC, either because of an error or
* because the RPC has been terminated by the client or the server.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Comment duplicated from header. Recommend removing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/**
* Handles a successful StreamingWriteResponse from the server that contains a
* mutation result.
*/
Copy link
Member

Choose a reason for hiding this comment

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

(again)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. This now allows grouping these overridden methods together, which I find more readable.

// If this was a permanent error, the request itself was the problem so it's
// not going to succeed if we resend it.
FSTMutationBatch* batch = write_pipeline_.front();
write_pipeline_.erase(write_pipeline_.begin());
Copy link
Member

Choose a reason for hiding this comment

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

Here (and above) you're deleting from the front of a vector. (And adding to the end.) A std::[de]queue might be a better choice, despite locality of reference. (It also happens to be what android uses.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

std::queue cannot be used because of the for loop at line 351. My impression is that deque starts outperforming vector only for a very large dataset (something like tens of thousands of elements). All things considered, I'm slightly in favor of the more common vector.

@@ -48,6 +52,12 @@
namespace firestore {
namespace remote {

/**
* The maximum number of pending writes to allow.
* TODO(bjornick): Negotiate this value with the backend.
Copy link
Member

Choose a reason for hiding this comment

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

The ts port uses (still open) b/35853402 rather than bjornick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

// If the write stream closed due to an error, invoke the error callbacks if
// there are pending writes.
if (!status.ok() && !write_pipeline_.empty()) {
if (write_stream_->handshake_complete()) {
Copy link
Member

Choose a reason for hiding this comment

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

Well, that doc suggests that unauth errors should trigger a retry with a refreshed token, and then permanently fail. We don't seem to be doing that, so I suspect the TODO is relevant. (Unless this is handled elsewhere...?)

If you want to keep/add the TODO, consider adding some additional context. Maybe:

/*
 * TODO: handle UNAUTHENTICATED status.
 * The first unauthenticated error should trigger a retry with a refreshed token. Subsequent attempts within a
 * time delta should then permanently fail. See go/firestore-client-errors for details.
 */

@rsgowman rsgowman assigned var-const and unassigned rsgowman Feb 4, 2019
@zxu123 zxu123 removed their assignment Feb 5, 2019
@var-const var-const changed the base branch from varconst/fst-remote-store1 to master February 6, 2019 23:49
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@googlebot googlebot added cla: no and removed cla: yes labels Feb 6, 2019
@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Feb 7, 2019
@var-const var-const merged commit 9b3654b into master Feb 7, 2019
bstpierr added a commit that referenced this pull request Feb 8, 2019
* master: (27 commits)
  Pass FSTMutations using a vector (#2357)
  Update CI to use CocoaPods 1.6.0 (#2360)
  Add NS_ASSUME_NONNULL_NOTATION for game center sign in (#2359)
  C++ migration: make all methods of `FSTRemoteStore` delegate to C++ (#2337)
  C++ migration: port write stream-related part of `FSTRemoteStore` (#2335)
  Resolve hard dependency of GameKit (#2355)
  Update gRPC certificate bundles locations for Firebase 5.16 (#2353)
  Start pod lib lint CI for IAM (#2347)
  Update library name to `fire-fiam`. (#2352)
  Bump FirebaseAnalyticsInterop version  (#2315)
  Add IAM headless to CI (#2341)
  C++ migration: port watch stream-related part of `FSTRemoteStore` (#2331)
  Open source FIAM headless SDK (#2312)
  Port flaky test fix from web. (#2332)
  Make scripts/style.sh compatible with newer swiftformat versions (0.38) (#2334)
  C++ migration: port `FSTOnlineStateTracker` (#2325)
  Don't build fuzz tests target on Travis (#2330)
  Remove FSTMutationQueue (#2319)
  C++ migration: port `FSTRemoteEvent` (#2320)
  C++ migration: port `FSTTargetChange` (#2318)
  ...
@paulb777 paulb777 deleted the varconst/fst-remote-store2 branch April 13, 2019 16:00
@firebase firebase locked and limited conversation to collaborators Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants