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

PHOENIX-7233 : CQSI openConnection should timeout to unblock other connection threads #1871

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
import java.util.Random;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -299,6 +300,7 @@
import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
import org.apache.phoenix.thirdparty.com.google.common.collect.Sets;


public class ConnectionQueryServicesImpl extends DelegateQueryServices implements ConnectionQueryServices {
private static final Logger LOGGER =
LoggerFactory.getLogger(ConnectionQueryServicesImpl.class);
Expand Down Expand Up @@ -3501,7 +3503,18 @@ public Void call() throws Exception {
try {
GLOBAL_QUERY_SERVICES_COUNTER.increment();
LOGGER.info("An instance of ConnectionQueryServices was created.");
openConnection();
CompletableFuture<Void> supplyFuture = CompletableFuture.runAsync(() -> {
try {
openConnection();
} catch (SQLException e) {
throw new RuntimeException(e);
}
});
try {
supplyFuture.get(120000, MILLISECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout should be a configurable value

} catch (TimeoutException e) {
LOGGER.error("openConnection did not return any value");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we swallowing the exception rather than rethrowing it? Shouldn't the timeout be a failure condition rather than proceeding?

}
hConnectionEstablished = true;
String skipSystemExistenceCheck =
props.getProperty(SKIP_SYSTEM_TABLES_EXISTENCE_CHECK);
Expand Down