Skip to content

Commit

Permalink
Adding timeout to open table call for function state (apache#9006)
Browse files Browse the repository at this point in the history
Co-authored-by: Jerry Peng <[email protected]>
  • Loading branch information
jerrypeng and Jerry Peng authored Dec 19, 2020
1 parent 99476d3 commit bfdcb77
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.api.StorageClient;
import org.apache.bookkeeper.api.kv.Table;
Expand Down Expand Up @@ -151,11 +153,13 @@ private Table<ByteBuf, ByteBuf> openStateTable(String tenant,
Stopwatch openSw = Stopwatch.createStarted();
while (openSw.elapsed(TimeUnit.MINUTES) < 1) {
try {
return result(client.openTable(name));
return result(client.openTable(name), 1, TimeUnit.MINUTES);
} catch (InternalServerException ise) {
log.warn("Encountered internal server on opening state table '{}/{}/{}', re-attempt in 100 milliseconds : {}",
tenant, namespace, name, ise.getMessage());
TimeUnit.MILLISECONDS.sleep(100);
} catch (TimeoutException e) {
throw new RuntimeException("Failed to open state table for function " + tenant + "/" + namespace + "/" + name + " within timeout period", e);
}
}
throw new IOException("Failed to open state table for function " + tenant + "/" + namespace + "/" + name);
Expand Down

0 comments on commit bfdcb77

Please sign in to comment.