[
https://issues.jboss.org/browse/JGRP-1961?page=com.atlassian.jira.plugin....
]
Bela Ban edited comment on JGRP-1961 at 12/7/15 10:35 AM:
----------------------------------------------------------
Hmm, how about we push the copy logic into {{WriteBuffers}} which could be configured to
enable/disable copying on an unsuccessful write: if a {{write(b1,b2,b3,b4)}} was
unsuccessful and only wrote {{b1}}, {{b2}} and *parts of* {{b3}}, but not {{b4}}, then
null {{b1}} and {{b2}} and *copy* {{b3}} and {{b4}}, leaving {{position}} and {{limit}} of
{{b3}} and {{b4}} intact.
Hmm, what happens if the next write also fails ? How do we prevent an additional copy ?
Perhaps we need to introduce a {{last_copied}} field which keeps track of which buffers
have already been copied...
was (Author: belaban):
Hmm, how about we push the copy logic into {{WriteBuffers}} which could be configured to
enable/disable copying on an unsuccessful write: if a {{write(b1,b2,b3,b4)}} was
unsuccessful and only wrote {{b1}}, {{b2}} and *parts of* {{b3}}, but not {{b4}}, then
null {{b1}} and {{b2}} and *copy* {{b3}} and {{b4}}, leaving {{position}} and {{limit}} of
{{b3}} and {{b4}} intact.
Hmm, what happens if the next write also fails ? How do we prevent an additional copy ?
TCP_NIO2: message bundling can lead to corruption of msgs sent
asynchronously
-----------------------------------------------------------------------------
Key: JGRP-1961
URL:
https://issues.jboss.org/browse/JGRP-1961
Project: JGroups
Issue Type: Bug
Affects Versions: 3.6.5
Reporter: Bela Ban
Assignee: Bela Ban
Priority: Critical
Fix For: 3.6.6
When a message is sent with a message bundler (in {{TP}}), the output buffer in
{{TP.BaseBundler}} is reused for all messages of a given bundle (say {{m1}} and {{m2}}).
This works for {{TCP}} and {{UDP}} because a write _blocks_ and - when it returns -
we're guaranteed that the buffer has been copied into an OS buffer (TCP's send
window).
However, this is different with {{TCP_NIO2}}: *an async write always returns immediately,
irrespective of whether the data was written completely, partially, or not at all !*
If a write only writes a part of its data, on returning from the write, the message
bundler reuses the output buffer and can thus overwrite and corrupt buffers that are in
transit, waiting to be written.
A quick check where buffers were copied fixed the problem.
TODO: see where we need to copy data when using a bundler. Possibly only copy if a write
didn't write all of the data.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)