Bug #16848 Hang in SocketRead
Submitted: 27 Jan 2006 18:09 Modified: 2 Feb 2006 16:31
Reporter: Jim Redman Email Updates:
Status: Not a Bug Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.10 OS:Linux (Linux JDK1.4.2)
Assigned to: CPU Architecture:Any

[27 Jan 2006 18:09] Jim Redman
If you pull a network connection on the system that has the DB running, you can hit this situation.  (This is a simulation of a field situation reported by a customer who looses a network connection for various reasons). The socketRead does not appear to have a timeout set to it, so will hang forever.  This is somewhat terminal for the application.  I can't find a spot to set a timeout - but maybe setting a timeout would be a work around.  Even if there is such a spot, this should have a default timeout of some reasonable value, even if that is some minutes.)

Thread [Timer for SynchronizedClockTick "SynchronizedClockTick" - Value "0"] (Suspended)
	owns: ReadAheadInputStream  (id=789)
	owns: Object  (id=790)
	owns: PreparedStatement  (id=791)
	owns: Connection  (id=792)
	SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]
	SocketInputStream.read(byte[], int, int) line: not available
	ReadAheadInputStream.fill(int) line: 105
	ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(byte[], int, int) line: 148
	ReadAheadInputStream.read(byte[], int, int) line: 176
	MysqlIO.readFully(InputStream, byte[], int, int) line: 1899
	MysqlIO.reuseAndReadPacket(Buffer) line: 2348
	MysqlIO.checkErrorPacket(int) line: 2858
	MysqlIO.sendCommand(int, String, Buffer, boolean, String) line: 1570
	MysqlIO.sqlQueryDirect(Statement, String, String, Buffer, int, Connection, int, int, boolean, String, boolean) line: 1665
	Connection.execSQL(Statement, String, int, Buffer, int, int, boolean, boolean, String, boolean, byte) line: 2978
	Connection.execSQL(Statement, String, int, Buffer, int, int, boolean, boolean, String, boolean) line: 2902
	PreparedStatement.executeInternal(int, Buffer, boolean, boolean, boolean) line: 930
	PreparedStatement.executeUpdate(byte[][], InputStream[], boolean[], int[], boolean[]) line: 1159
	PreparedStatement.executeUpdate(boolean) line: 1076
	PreparedStatement.executeUpdate() line: 1061
	TriggeredHistorical.update(long, Hashtable) line: 628
	TriggeredHistorical.trigger(ValueChangedEvent) line: 738
	TriggeredHistorical.valueChanged(int, ValueChangedEvent) line: 183
	StaticConnector.validatedValueChanged(ValueChangedEvent) line: 101
	StaticConnector(Connector).valueChanged(ValueChangedEvent) line: 671
	DataValve(DataSource).updateListener(DataSource, Connector, ValueChangedEvent) line: 400
	DataValve(DataSource).updateListeners() line: 865
	DataValve(DataSource).setValueObjectInternal(ValueObjectInterface) line: 774
	DataValve.update() line: 46
	DataValve.valueInput(ValueChangedEvent) line: 37
	DataValve(Manipulator).valueChanged(int, ValueChangedEvent) line: 84
	DataValve.valueChanged(int, ValueChangedEvent) line: 66
	StaticConnector.validatedValueChanged(ValueChangedEvent) line: 101
	StaticConnector(Connector).valueChanged(ValueChangedEvent) line: 671
	SynchronizedClockTick(DataSource).updateListener(DataSource, Connector, ValueChangedEvent) line: 400
	SynchronizedClockTick(DataSource).updateListeners() line: 865
	SynchronizedClockTick(DataSource).setValueObjectInternal(ValueObjectInterface) line: 774
	SynchronizedClockTick.refreshCurrentValue(long) line: 79
	SynchronizedClockTick.tick(Timer) line: 61
	SyncTimer(Timer).run() line: 442
	Thread.run() line: not available

How to repeat:
Pull the network connection.  Not totally reproducible. (You have to get lucky, or unlucky).

Suggested fix:
Set a default read timout on the socket and provide the user a way to modify this.
[29 Jan 2006 18:40] Shane Bester
See 'connectTimeout' and 'socketTimeout' descriptions for the url:
[2 Feb 2006 16:31] Mark Matthews
See shane's comment. You can set socket-level timeouts via those parameters.