Требуется помощь в решении указанной ниже проблемы.
Проблема : проблема сброса подключения при подключении к серверу Always On MS SQL из автономного приложения java, развернутого в java docker контейнер.
Примечание : автономное приложение работает нормально с windows, но не работает с docker образ, развернутый на linux.
Java код в отдельном приложении:
public class SQLDatabaseConnection {
public static void main(String[] args) {
String connectionUrl =
"jdbc:sqlserver://SXXXXXXX05E:49001;"
+ "database=AdventureWorks;"
+ "user=yourusername@yourserver;"
+ "password=yourpassword;"
+ "loginTimeout=30;"
+ "multisubnetfailover=true";
try (Connection connection = DriverManager.getConnection(connectionUrl);) {
// Code here.
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
Версия драйвера :: ms sql -jdb c -8.2.2.jre8.jar
Docker Java базовый образ : openjdk 8. Java docker контейнер развернут на узле linux с использованием кубернетов.
SQL прослушиватель сервера (SXXXXXXX05E) (всегда включен) имеет два IP-адреса -> 10.100.200.111 - офлайн и 10.100.200.123 онлайн
Наблюдения : с MultisubnetfailOver = true и таймаутом 30 секунд, он пытается подключиться 3 раза.
Основная проблема, которую я вижу: когда два потока запускаются для установления соединения, сокет c onnector для результатов оффлайн IP-адреса, получаемых как УСПЕХ (см. -> Был выбран сокет следующего потока: SocketConnector: 9), после чего немедленно происходит сброс соединения. Я подумал, что автономный IP-адрес должен вызывать тайм-аут, и следует выбирать только разъем сокета с активным IP.
Пожалуйста, поправьте меня, если я ошибаюсь в своих предположениях, и помогите мне в решении проблемы.
Журнал Неудачный сценарий:
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 created by (SQLServerDriver:1)
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 Start time: 1590790973388 Time out time: 1590791003388 Timeout Unit Interval: 2400
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt server name: SXXXXXXX05E port: 49001 InstanceName: null useParallel: true
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt endtime: 1590790975788
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt No: 0
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 Connecting with server: SXXXXXXX05E port: 49001 Timeout slice: 2400 Timeout Full: 30
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Opening TCP socket...
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) Total no of InetAddresses: 2. They are: SXXXXXXX05E /10.100.200.111;SXXXXXXX05E /10.100.200.123;
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3))Using Threading with timeout:2400
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) TimeRemaining:2400; Result:UNKNOWN; Max. open thread count: 2; Current open thread count:0
[pool-6-thread-1] c.m.s.j.i.SocketConnector : SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3))) connecting to InetSocketAddress:SXXXXXXX05E /10.100.200.111:49001 with timeout:2400
[pool-6-thread-2] c.m.s.j.i.SocketConnector : SocketConnector:10(SocketFinder(TDSChannel (ConnectionID:3))) connecting to InetSocketAddress:SXXXXXXX05E /10.100.200.123:49001 with timeout:2400
[pool-6-thread-1] c.m.s.j.i.SocketFinder : The following child thread is waiting for socketFinderLock:SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-1] c.m.s.j.i.SocketFinder : The following child thread acquired socketFinderLock:SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-1] c.m.s.j.i.SocketFinder : The socket of the following thread has been chosen:SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-1] c.m.s.j.i.SocketFinder : The following child thread is waiting for parentThreadLock:SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread is waiting for socketFinderLock:SocketConnector:10(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-1] c.m.s.j.i.SocketFinder : The following child thread acquired parentThreadLock:SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-1] c.m.s.j.i.SocketFinder : The following child thread released parentThreadLock and notified the parent thread:SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-1] c.m.s.j.i.SocketFinder : The following child thread released socketFinderLock:SocketConnector:9(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread acquired socketFinderLock:SocketConnector:10(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread is waiting for parentThreadLock:SocketConnector:10(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread acquired parentThreadLock:SocketConnector:10(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread released parentThreadLock and notified the parent thread:SocketConnector:10(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread released socketFinderLock:SocketConnector:10(SocketFinder(TDSChannel (ConnectionID:3)))
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) The parent thread wokeup.
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) TimeRemaining:2398; Result:SUCCESS; Max. open thread count: 2; Current open thread count:0
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)): Closing TCP socket:Socket[addr=SXXXXXXX05E /10.100.200.123,port=49001,localport=36682]
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: d9091629-33ce-4034-8dcc-bc86a2da0ee6 Requesting encryption level:OFF
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3) read failed:Connection reset
[ main] c.m.s.j.i.SQLServerException : *** SQLException:ConnectionID:3 ClientConnectionId: d9091629-33ce-4034-8dcc-bc86a2da0ee6 com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientCon
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Closing TCP socket...
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: d9091629-33ce-4034-8dcc-bc86a2da0ee6 Prelogin error: host SXXXXXXX05E port 49001 Error reading prelogin response: Connection
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Closing TCP socket...
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: d9091629-33ce-4034-8dcc-bc86a2da0ee6 sleeping milisec: 100
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt server name: SXXXXXXX05E port: 49001 InstanceName: null useParallel: true
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt endtime: 1590790988398
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt No: 1
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 Connecting with server: SXXXXXXX05E port: 49001 Timeout slice: 4800 Timeout Full: 30
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Opening TCP socket...
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) Total no of InetAddresses: 2. They are: SXXXXXXX05E /10.100.200.111;SXXXXXXX05E /10.100.200.123;
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3))Using Threading with timeout:4800
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) TimeRemaining:4800; Result:UNKNOWN; Max. open thread count: 2; Current open thread count:0
[pool-6-thread-2] c.m.s.j.i.SocketConnector : SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3))) connecting to InetSocketAddress:SXXXXXXX05E /10.100.200.111:49001 with timeout:4800
[pool-6-thread-1] c.m.s.j.i.SocketConnector : SocketConnector:26(SocketFinder(TDSChannel (ConnectionID:3))) connecting to InetSocketAddress:SXXXXXXX05E /10.100.200.123:49001 with timeout:4800
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread is waiting for socketFinderLock:SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread acquired socketFinderLock:SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The socket of the following thread has been chosen:SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread is waiting for parentThreadLock:SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread acquired parentThreadLock:SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread released parentThreadLock and notified the parent thread:SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread released socketFinderLock:SocketConnector:25(SocketFinder(TDSChannel (ConnectionID:3)))
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) The parent thread wokeup.
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) TimeRemaining:4800; Result:SUCCESS; Max. open thread count: 2; Current open thread count:1
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)): Closing TCP socket:Socket[addr=SXXXXXXX05E /10.100.200.123,port=49001,localport=37168]
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: 545d8dc6-dcd8-41f5-97b2-f85523cd92c1 Requesting encryption level:OFF
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3) read failed:Connection reset
[ main] c.m.s.j.i.SQLServerException : *** SQLException:ConnectionID:3 ClientConnectionId: 545d8dc6-dcd8-41f5-97b2-f85523cd92c1 com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientCo
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Closing TCP socket...
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: 545d8dc6-dcd8-41f5-97b2-f85523cd92c1 Prelogin error: host SXXXXXXX05E port 49001 Error reading prelogin response: Connection
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Closing TCP socket...
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: 545d8dc6-dcd8-41f5-97b2-f85523cd92c1 sleeping milisec: 200
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt server name: SXXXXXXX05E port: 49001 InstanceName: null useParallel: true
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt endtime: 1590791001001
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 This attempt No: 2
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 Connecting with server: SXXXXXXX05E port: 49001 Timeout slice: 7199 Timeout Full: 30
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Opening TCP socket...
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) Total no of InetAddresses: 2. They are: SXXXXXXX05E/10.100.200.111;SXXXXXXX05E/10.100.200.123;
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3))Using Threading with timeout:7199
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) TimeRemaining:7199; Result:UNKNOWN; Max. open thread count: 2; Current open thread count:0
[pool-6-thread-2] c.m.s.j.i.SocketConnector : SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3))) connecting to InetSocketAddress:SXXXXXXX05E/10.100.200.111:49001 with timeout:7199
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread is waiting for socketFinderLock:SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread acquired socketFinderLock:SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The socket of the following thread has been chosen:SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread is waiting for parentThreadLock:SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread acquired parentThreadLock:SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread released parentThreadLock and notified the parent thread:SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-2] c.m.s.j.i.SocketFinder : The following child thread released socketFinderLock:SocketConnector:43(SocketFinder(TDSChannel (ConnectionID:3)))
[pool-6-thread-1] c.m.s.j.i.SocketConnector : SocketConnector:44(SocketFinder(TDSChannel (ConnectionID:3))) connecting to InetSocketAddress:SXXXXXXX05E/10.100.200.123:49001 with timeout:7199
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) The parent thread wokeup.
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)) TimeRemaining:7198; Result:SUCCESS; Max. open thread count: 2; Current open thread count:0
[ main] c.m.s.j.i.SocketFinder : SocketFinder(TDSChannel (ConnectionID:3)): Closing TCP socket:Socket[addr=SXXXXXXX05E/10.100.200.123,port=49001,localport=37676]
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: 008a03a9-ba52-409e-bade-86a06e3c291b Requesting encryption level:OFF
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3) read failed:Connection reset
[ main] c.m.s.j.i.SQLServerException : *** SQLException:ConnectionID:3 ClientConnectionId: 008a03a9-ba52-409e-bade-86a06e3c291b com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientCo
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Closing TCP socket...
[ main] c.m.s.j.i.SQLServerConnection : ConnectionID:3 ClientConnectionId: 008a03a9-ba52-409e-bade-86a06e3c291b Prelogin error: host SXXXXXXX05E port 49001 Error reading prelogin response: Connection
[ main] c.m.s.j.i.T.Channel : TDSChannel (ConnectionID:3): Closing TCP socket...
Все три раза выбран Offline IP.
Не могли бы вы помочь нам на основании наблюдений?