cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulo Motta (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-11286) streaming socket never times out
Date Wed, 02 Mar 2016 01:07:18 GMT


Paulo Motta commented on CASSANDRA-11286:

In order to verify that socket timeout was indeed not being respected, I added a new property
{{cassandra.dtest.sleep_during_stream_write}} to [this branch|]
and set it to a value much longer than {{streaming_socket_timeout_in_ms}} on [this dtest|],
and verified that the bootstrap streaming session hanged forever.

Two changes are necessary to make stream socket timeout be enforced/respected during a stream
* Creation of socket via {{Channels.newChannel(socket.getInputStream());}} on {{ConnectionHandler.getReadChannel(socket)}},
as suggested in the [blog post|].
* Set socket timeout on follower side on {{IncomingStreamingConnection}}

After these changes, I re-executed the previous dtest on [a fixed branch|]
and verified that the bootstrap stream session did not hang, but instead failed. The reason
for the stream to fail and not to be retried is because {{SocketTimeoutException}} is an {{IOException}},
so it's catch by [this block|]
(and not [this|])
on {{IncomingFileMessage}}.

This behavior of failing on socket timeout is not the one documented on {{cassandra.yaml}}:
# Enable socket timeout for streaming operation.
# When a timeout occurs during streaming, streaming is retried from the start
# of the current file. This _can_ involve re-streaming an important amount of
# data, so you should avoid setting the value too low.
# Default value is 3600000, which means streams timeout after an hour.
# streaming_socket_timeout_in_ms: 3600000

So I updated it to:
# Set socket timeout for streaming operation.
# The stream session is failed if no data is received by any of the
# participants within that period.
# Default value is 3600000, which means streams timeout after an hour.
# streaming_socket_timeout_in_ms: 3600000

While retrying when receiving corrupted data is probably the right approach, I'm not sure
retrying on a socket timeout is desirable here. I can see two main reasons for the socket
to timeout:
* Connection was broken/reset in only one side of the socket (rare but possible situation)
* Deadlock or protocol error on sender side

In both scenarios, I think failing stream is the correct approach, rather than retrying and
dealing with unexpected error conditions. WDYT [~yukim]?

Below are branches with the suggested changes and tests.


commit info: minor conflict on 2.2, but other than that it merges cleanly upwards.

> streaming socket never times out
> --------------------------------
>                 Key: CASSANDRA-11286
>                 URL:
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Streaming and Messaging
>            Reporter: Paulo Motta
>            Assignee: Paulo Motta
> While trying to reproduce CASSANDRA-8343 I was not able to trigger a {{SocketTimeoutException}}
by adding an artificial sleep longer than {{streaming_socket_timeout_in_ms}}.
> After investigation, I detected two problems:
> * {{ReadableByteChannel}} creation via {{socket.getChannel()}}, as done in {{ConnectionHandler.getReadChannel(socket)}},
does not respect {{socket.setSoTimeout()}}, as explained in this [blog post|]
> ** bq. The only difference between “blocking NIO” and “NIO wrapped around IO”
is that you can’t use socket timeout with SocketChannels. Why ? Read a javadoc for setSocketTimeout().
It says that this timeout is used only by streams.
> * {{socketSoTimeout}} is never set on "follower" side, only on initiator side via {{DefaultConnectionFactory.createConnection(peer)}}.
> This may cause streaming to hang indefinitely, as exemplified by CASSANDRA-8621:
> bq. For the scenario that prompted this ticket, it appeared that the streaming process
was completely stalled. One side of the stream (the sender side) had an exception that appeared
to be a connection reset. The receiving side appeared to think that the connection was still
active, at least in terms of the netstats reported by nodetool. We were unable to verify whether
this was specifically the case in terms of connected sockets due to the fact that there were
multiple streams for those peers, and there is no simple way to correlate a specific stream
to a tcp session.

This message was sent by Atlassian JIRA

View raw message