Skip to content

Retry topic subscription on quota errors using exponential backoff #6098

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

Merged
merged 7 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions firebase-messaging/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* [changed] Switched Firelog to use the new TransportBackend.
* [changed] Log analytics for notifications displayed by Google Play services on
behalf of the app.
* [changed] Retry Topic Subscribe/Unsubscribe operations with exponential
backoff if they hit a quota error.


## Kotlin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class GmsRpc {
/** Another server error besides ERROR_SERVICE_NOT_AVAILABLE that we retry on. */
static final String ERROR_INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR";

/** A server error that represents hitting topic subscription quota. Trying again here may
* continue to fail, but as long as we use exponential backoff its okay to retry.
*/
static final String TOO_MANY_SUBSCRIBERS = "TOO_MANY_SUBSCRIBERS";

/** Heartbeat tag for firebase iid. */
static final String FIREBASE_IID_HEARTBEAT_TAG = "fire-iid";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ boolean performTopicOperation(TopicOperation topicOperation) throws IOException
} catch (IOException e) {
// Operation failed, retry failed only if errors from backend are server related error
if (GmsRpc.ERROR_SERVICE_NOT_AVAILABLE.equals(e.getMessage())
|| GmsRpc.ERROR_INTERNAL_SERVER_ERROR.equals(e.getMessage())) {
|| GmsRpc.ERROR_INTERNAL_SERVER_ERROR.equals(e.getMessage())
|| GmsRpc.TOO_MANY_SUBSCRIBERS.equals(e.getMessage())) {
Log.e(TAG, "Topic operation failed: " + e.getMessage() + ". Will retry Topic operation.");

return false; // will retry
Expand Down
Loading