Skip to content

Commit c85c626

Browse files
authored
Fixed an issue with timeouts. (#41)
This change ensures that the timeout sent to the server is always the amount of time remaining before the overall request times out, regardless of internal retries and/or internal rate limiting. Also updated low throughput test to not take too long when server-side rate limiting is in place.
1 parent 9e76549 commit c85c626

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

driver/src/main/java/oracle/nosql/driver/http/Client.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ public Result execute(Request kvRequest) {
515515
break;
516516
}
517517

518+
/* update iteration timeout in case limiters slept for some time */
519+
thisTime = System.currentTimeMillis();
520+
thisIterationTimeoutMs = timeoutMs - (int)(thisTime - startTime);
521+
518522
final String authString =
519523
authProvider.getAuthorizationString(kvRequest);
520524
authProvider.validateAuthString(authString);
@@ -566,6 +570,9 @@ public Result execute(Request kvRequest) {
566570
*/
567571
kvRequest.setCheckRequestSize(false);
568572

573+
/* update timeout in request to match this iteration timeout */
574+
kvRequest.setTimeoutInternal(thisIterationTimeoutMs);
575+
569576
serialVersionUsed = writeContent(buffer, kvRequest);
570577

571578
/*

driver/src/test/java/oracle/nosql/driver/QueryTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ public void testLowThroughput() {
17101710
if (onprem == false) {
17111711
assumeKVVersion("testLowThroughput", 21, 3, 1);
17121712
}
1713-
final int numRows = 500;
1713+
final int numRows = 30;
17141714
String name = "testThroughput";
17151715
String createTableDdl =
17161716
"CREATE TABLE " + name +
@@ -1719,7 +1719,7 @@ public void testLowThroughput() {
17191719
tableOperation(handle, createTableDdl, new TableLimits(2, 20000, 1));
17201720

17211721
MapValue value = new MapValue()
1722-
.put("bin", new byte[10000])
1722+
.put("bin", new byte[3000])
17231723
.put("json", "abc");
17241724
PutRequest putReq = new PutRequest().setTableName(name);
17251725

@@ -1732,7 +1732,9 @@ public void testLowThroughput() {
17321732
}
17331733

17341734
/*
1735-
* Ensure that this query completes
1735+
* Ensure that this query completes.
1736+
* 30 rows of 3K+ each = ~90KB.
1737+
* at 2RUs/sec, that's about 45 seconds.
17361738
*/
17371739
try (QueryRequest queryReq = newQueryRequest()) {
17381740
queryReq.setStatement("select * from " + name);

0 commit comments

Comments
 (0)