Skip to content

Commit

Permalink
Fix JDBC driver initialization deadlock (#2604)
Browse files Browse the repository at this point in the history
Fixes #2603
  • Loading branch information
viliam-durina authored Oct 14, 2020
1 parent 9803aff commit ee7c51f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.sql.DriverManager;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -74,6 +75,8 @@ public abstract class CdcSource<T> {
private SourceTask task;

CdcSource(Processor.Context context, Properties properties) {
// workaround for https://github.com/hazelcast/hazelcast-jet/issues/2603
DriverManager.getDrivers();
this.logger = context.logger();
this.properties = properties;
this.reconnectTracker = new RetryTracker(getRetryStrategy(properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private void onSnapshotPhase1Complete(
stats.duration(), stats.numBytes(), stats.numKeys(), stats.numChunks(), snapshotMapName));
}
if (!isSuccess) {
logger.warning(mc.jobIdString() + " snapshot " + snapshotId + " failed on some member(s), " +
logger.warning(mc.jobIdString() + " snapshot " + snapshotId + " phase 1 failed on some member(s), " +
"one of the failures: " + mergedResult.getError());
try {
snapshotMap.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public static <T> ProcessorMetaSupplier supplier(

@Override
protected void init(@Nonnull Context context) {
// workaround for https://github.com/hazelcast/hazelcast-jet/issues/2603
DriverManager.getDrivers();
this.connection = newConnectionFn.get();
this.parallelism = context.totalParallelism();
this.index = context.globalProcessorIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
Expand Down Expand Up @@ -115,6 +116,8 @@ public Collection<? extends Processor> get(int count) {
@Override
public void init(@Nonnull Outbox outbox, @Nonnull Context context) throws Exception {
super.init(outbox, context);
// workaround for https://github.com/hazelcast/hazelcast-jet/issues/2603
DriverManager.getDrivers();
logger = context.logger();
connectAndPrepareStatement();
}
Expand Down

0 comments on commit ee7c51f

Please sign in to comment.