Skip to content

Commit 5bb17ea

Browse files
committed
Added extra logs
1 parent 74ce244 commit 5bb17ea

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

jdbc/src/main/java/tech/ydb/jdbc/context/QueryServiceExecutor.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.util.Collections;
1010
import java.util.List;
1111
import java.util.concurrent.TimeUnit;
12+
import java.util.logging.Level;
13+
import java.util.logging.Logger;
1214

1315
import tech.ydb.common.transaction.TxMode;
1416
import tech.ydb.core.Issue;
@@ -41,6 +43,8 @@
4143
* @author Aleksandr Gorshenin
4244
*/
4345
public class QueryServiceExecutor extends BaseYdbExecutor {
46+
private static final Logger LOGGER = Logger.getLogger(QueryServiceExecutor.class.getName());
47+
4448
private final Duration sessionTimeout;
4549
private final QueryClient queryClient;
4650

@@ -66,9 +70,11 @@ public QueryServiceExecutor(YdbContext ctx, int transactionLevel, boolean autoCo
6670

6771
protected QuerySession createNewQuerySession(YdbValidator validator) throws SQLException {
6872
try {
69-
Result<QuerySession> session = queryClient.createSession(sessionTimeout).join();
70-
validator.addStatusIssues(session.getStatus());
71-
return session.getValue();
73+
Result<QuerySession> result = queryClient.createSession(sessionTimeout).join();
74+
validator.addStatusIssues(result.getStatus());
75+
QuerySession session = result.getValue();
76+
LOGGER.log(Level.FINEST, "Acquired session {0}", session);
77+
return session;
7278
} catch (UnexpectedResultException ex) {
7379
throw ExceptionFactory.createException("Cannot create session with " + ex.getStatus(), ex);
7480
}
@@ -82,6 +88,7 @@ public void close() {
8288

8389
private void cleanTx() {
8490
if (tx != null) {
91+
LOGGER.log(Level.FINEST, "Released session {0}", tx.getSession());
8592
tx.getSession().close();
8693
tx = null;
8794
}

jdbc/src/main/java/tech/ydb/jdbc/context/YdbValidator.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ public void execute(String msg, Supplier<CompletableFuture<Status>> fn) throws S
7373
try {
7474
runImpl(msg, fn);
7575
logger.log(Level.FINEST, "[{0}] OK ", sw.stop());
76-
} catch (SQLException | RuntimeException ex) {
76+
} catch (SQLException ex) {
7777
logger.log(Level.FINE, "[{0}] {1} ", new Object[] {sw.stop(), ex.getMessage()});
7878
throw ex;
79+
} catch (Exception ex) {
80+
logger.log(Level.WARNING, "ERROR ", ex);
81+
throw ex;
7982
}
8083
}
8184

@@ -91,8 +94,11 @@ public <R> R call(String msg, Supplier<CompletableFuture<Result<R>>> fn) throws
9194
R value = callImpl(msg, fn);
9295
logger.log(Level.FINEST, "[{0}] OK ", sw.stop());
9396
return value;
94-
} catch (SQLException | RuntimeException ex) {
95-
logger.log(Level.FINE, "[{0}] {1} ", new Object[] {sw.stop(), ex.getMessage()});
97+
} catch (SQLException ex) {
98+
logger.log(Level.FINE, "[{0}] FAIL {1} ", new Object[] {sw.stop(), ex.getMessage()});
99+
throw ex;
100+
} catch (Exception ex) {
101+
logger.log(Level.WARNING, "ERROR ", ex);
96102
throw ex;
97103
}
98104
}

0 commit comments

Comments
 (0)