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

Google.Cloud.Firestore: Backoff on FirestoreDb.RunTransactionAsync retry #10513

Closed
kasperhhk opened this issue Jun 12, 2023 · 7 comments · Fixed by #11564
Closed

Google.Cloud.Firestore: Backoff on FirestoreDb.RunTransactionAsync retry #10513

kasperhhk opened this issue Jun 12, 2023 · 7 comments · Fixed by #11564
Assignees
Labels
api: firestore Issues related to the Firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@kasperhhk
Copy link

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is your feature request related to a problem? Please describe.
Regarding RunTransactionAsync on the FirestoreDb class in the Google.Cloud.Firestore package.

When we call it with MaxAttempts > 1 option, then we would like to have some sort of backoff policy, in our case for data contention, so that it does not spam the document when it is already in contention.
(note there is a backoff variable that is unused in the source code, not really relevant to the solution proposed below though)

Describe the solution you'd like
Either a backoff policy similar to what we see in the _batchGetCallSettings field or being able to pass an optional backoff policy to the method / client.
There's the issue of backwards compatibility, so maybe it does need to configurable by the user, defaulting to current behavior (no backoff).

Describe alternatives you've considered
Currently we're implementing our own backoff policy, wrapping around the firestoredb, but since you already have a backoff concept, it seemed reasonable to add it here as well.

Additional context
I admit that I'm a bit unsure if there's some internal backoff policy inside the lower internal functions that I haven't been able to divine, but from what I could see there's nothing obvious going on, so please correct me if there's anything I've misunderstood.

@jskeet jskeet self-assigned this Jun 12, 2023
@jskeet
Copy link
Collaborator

jskeet commented Jun 12, 2023

This sounds entirely reasonable, but we'll need to talk with the Firestore SDK team - we'll want to make sure that we're consistent with other languages.

@jskeet jskeet added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: firestore Issues related to the Firestore API. labels Jun 12, 2023
@jskeet
Copy link
Collaborator

jskeet commented Jun 14, 2023

I've talked with the Firestore team, and they're going to write an internal document to design how this can be achieved consistently across languages. Thanks for bringing it up.

@jskeet
Copy link
Collaborator

jskeet commented Jan 19, 2024

Just to avoid leaving you completely in the dark - this is still bubbling along. I'm hoping we'll get somewhere "soonish" but I can't make any promises about a timeline. We haven't forgotten about it though.

@jskeet
Copy link
Collaborator

jskeet commented Jan 19, 2024

@kasperhhk: Thinking about this in terms of what I'm doing for #11322, would a FirestoreDb-wide setting for retry configuration work for you? I can imagine some times when you might want per-call settings, but if we were to expose a FirestoreDbBuilder.RunTransactionRetrySettings property, would that at least get most of the way there?

@jskeet
Copy link
Collaborator

jskeet commented Jan 19, 2024

Actually, I now wonder whether we should just have a RetrySettings in TransactionOptions, given that that's got MaxAttempts already. (We'd probably need some sort of precedence - if the RetrySettings is specified, that overrides MaxAttempts, given that a RetrySettings effectively includes max attempts already.)

@jskeet
Copy link
Collaborator

jskeet commented Jan 19, 2024

(Or if we don't want to allow the set of RPC failures to be customized, we could potentially only expose the timing part. RetrySettings has quite a few parts though, so maybe we should just expose a RetrySettings property, and say that MaxAttempts and RetryFilter are ignored? Hmm.)

jskeet added a commit to jskeet/google-cloud-dotnet that referenced this issue Jan 19, 2024
There are further changes to come in terms of transaction retry, but
this is at least a start. Note that this changes the default backoff
from "none at all" to "100ms initial, with a multiplier of 1.3".
That's a more reasonable default, and it seems unlikely that
customers would actually *depend* on there being no backoff.

Fixes googleapis#10513
@jskeet
Copy link
Collaborator

jskeet commented Jan 19, 2024

@kasperhhk: If you could have a look at #11564 and add any thoughts about the API, that would be much appreciated. If you're happy with it, I'll write appropriate tests and check whether the Firestore team is okay with it too.

jskeet added a commit to jskeet/google-cloud-dotnet that referenced this issue Jan 23, 2024
There are further changes to come in terms of transaction retry, but
this is at least a start. Note that this changes the default backoff
from "none at all" to "100ms initial, with a multiplier of 1.3".
That's a more reasonable default, and it seems unlikely that
customers would actually *depend* on there being no backoff.

Fixes googleapis#10513
jskeet added a commit to jskeet/google-cloud-dotnet that referenced this issue Jan 29, 2024
There are further changes to come in terms of transaction retry, but
this is at least a start. Note that this changes the default backoff
from "none at all" to "100ms initial, with a multiplier of 1.3".
That's a more reasonable default, and it seems unlikely that
customers would actually *depend* on there being no backoff.

Fixes googleapis#10513
jskeet added a commit that referenced this issue Jan 29, 2024
There are further changes to come in terms of transaction retry, but
this is at least a start. Note that this changes the default backoff
from "none at all" to "100ms initial, with a multiplier of 1.3".
That's a more reasonable default, and it seems unlikely that
customers would actually *depend* on there being no backoff.

Fixes #10513
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants