Skip to content

Commit

Permalink
Merge pull request #1527 from dilanSachi/error-hang
Browse files Browse the repository at this point in the history
Fix client getting hanged due to invalid retry configuraiton handling logic
  • Loading branch information
dilanSachi committed Jan 22, 2024
2 parents 5a537e9 + 0c13afe commit 5668d06
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
8 changes: 4 additions & 4 deletions ballerina-tests/tests/22_retry_client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import ballerina/test;

grpc:RetryConfiguration retryConfig = {
retryCount: 3,
interval: 0.002,
maxInterval: 0.01,
interval: 2,
maxInterval: 10,
backoffFactor: 2,
errorTypes: [grpc:UnavailableError, grpc:InternalError]
};

grpc:RetryConfiguration failingRetryConfig = {
retryCount: 2,
interval: 0.002,
maxInterval: 0.01,
interval: 2,
maxInterval: 10,
backoffFactor: 2,
errorTypes: [grpc:UnavailableError, grpc:InternalError]
};
Expand Down
8 changes: 4 additions & 4 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "grpc"
version = "1.10.4"
version = "1.10.5"
distribution = "2201.8.0"
authors = ["Ballerina"]
keywords = ["network", "grpc", "protobuf", "server-streaming", "client-streaming", "bidirectional-streaming"]
Expand All @@ -16,11 +16,11 @@ graalvmCompatible = true
[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "grpc-native"
version = "1.10.4"
path = "../native/build/libs/grpc-native-1.10.4.jar"
version = "1.10.5"
path = "../native/build/libs/grpc-native-1.10.5-SNAPSHOT.jar"

[[platform.java17.dependency]]
path = "../test-utils/build/libs/grpc-test-utils-1.10.4.jar"
path = "../test-utils/build/libs/grpc-test-utils-1.10.5-SNAPSHOT.jar"
scope = "testOnly"

[[platform.java17.dependency]]
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "grpc-compiler-plugin"
class = "io.ballerina.stdlib.grpc.plugin.GrpcCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/grpc-compiler-plugin-1.10.4.jar"
path = "../compiler-plugin/build/libs/grpc-compiler-plugin-1.10.5-SNAPSHOT.jar"
8 changes: 4 additions & 4 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ modules = [
[[package]]
org = "ballerina"
name = "cache"
version = "3.7.0"
version = "3.7.1"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -68,7 +68,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "grpc"
version = "1.10.4"
version = "1.10.5"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "crypto"},
Expand All @@ -94,7 +94,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.3"
version = "2.10.5"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -289,7 +289,7 @@ modules = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.2.0"
version = "1.2.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down
8 changes: 5 additions & 3 deletions ballerina/client_endpoint.bal
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ isolated function retryBlockingExecute(Client grpcClient, string methodID, anyda
headers, RetryConfiguration retryConfig) returns ([anydata, map<string|string[]>]|Error) {
int currentRetryCount = 0;
int retryCount = retryConfig.retryCount;
decimal interval = retryConfig.interval * 1000;
decimal maxInterval = retryConfig.maxInterval * 1000;
decimal interval = retryConfig.interval;
decimal maxInterval = retryConfig.maxInterval;
decimal backoffFactor = retryConfig.backoffFactor;
ErrorType[] errorTypes = retryConfig.errorTypes;
error? cause = ();
Expand All @@ -155,7 +155,9 @@ headers, RetryConfiguration retryConfig) returns ([anydata, map<string|string[]>
cause = result;
}
}
runtime:sleep(interval);
if currentRetryCount < retryCount {
runtime:sleep(interval);
}
decimal newInterval = interval * backoffFactor;
interval = (newInterval > maxInterval) ? maxInterval : newInterval;
currentRetryCount += 1;
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This file contains all the notable changes done to the Ballerina gRPC package th
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- [Fixed the way of handling `grpc:RetryConfiguration`](https://github.com/ballerina-platform/ballerina-library/issues/5970)

## [1.10.4] - 2024-01-04
### Fixed
- [Fixed `grpc:ClientConfiguration` getting overwritten when mutliple clients are present](https://github.com/ballerina-platform/ballerina-library/issues/5892)
Expand Down

0 comments on commit 5668d06

Please sign in to comment.