[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2018-02-23 Thread Emmanuel Lecharny (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16374155#comment-16374155
 ] 

Emmanuel Lecharny commented on DIRMINA-1057:


Hi David,

sorry, I'm totally under the water :/

Jonathan is currently working on some critical fixes that I'd like to have 
included in the release. I hope it's going to be ready soon. We have to discuss 
that.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>Priority: Major
> Fix For: 2.0.17
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2018-02-23 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16374134#comment-16374134
 ] 

David Gibbs commented on DIRMINA-1057:
--

[~elecharny] Hi Emanuel I see that 2.0.17 is complete but not released, could 
you let us know the the plans for the release please ?

thanks and regards

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>Priority: Major
> Fix For: 2.0.17
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2018-01-12 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16323727#comment-16323727
 ] 

David Gibbs commented on DIRMINA-1057:
--

[~elecharny] Hi Emanuel, we've been waiting with 'bated breath for the release 
of this fix. If no-one is working on the last issue for 2.0.17 could you move 
that issue to 2.0.18 so that 2.0.17 can be released please ? Thanks and regards 
Dave


> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
> Fix For: 2.0.17
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-16 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16206198#comment-16206198
 ] 

David Gibbs commented on DIRMINA-1057:
--

Super, good news, thanks [~elecharny] and [~johnnyv]

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
> Fix For: 2.0.17
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-16 Thread Emmanuel Lecharny (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16205806#comment-16205806
 ] 

Emmanuel Lecharny commented on DIRMINA-1057:


It'll be in 2.0.17.

I'm a bit swamped this week, with a conference I have to give a talk at by the 
end of this week, but I may find some time to cut a release this week-end.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
> Fix For: 2.0.17
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-16 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16205767#comment-16205767
 ] 

David Gibbs commented on DIRMINA-1057:
--

Thank you gentlemen, what are the next steps ? Will the fix be in a 2.0.17 bug 
fix release?

[~johnnyv] I updated the integration test at 
https://github.com/david-gibbs-ig/mina-test-case/tree/mina-only-case. 
It now runs multiple producer threads and consumers. 
That does not really prove anything of course but such tests may intermittently 
fail if there are concurrency issues.
The second test in "ScheduledBytesAndMessagesIT" reliably fails with 2.0.16.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


Re: [jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-14 Thread Jonathan Valliere
Yay! Thanks Emmanuel!

On Sat, Oct 14, 2017 at 7:48 AM, Emmanuel Lecharny (JIRA) 
wrote:

>
> [ https://issues.apache.org/jira/browse/DIRMINA-1057?page=
> com.atlassian.jira.plugin.system.issuetabpanels:comment-
> tabpanel=16204593#comment-16204593 ]
>
> Emmanuel Lecharny commented on DIRMINA-1057:
> 
>
> Ok, I have reapplied the patch ( with a minor correction) and ran the test
> : all is green.
>
> The correction is :
>
> {code:java}
> try {
> localWrittenBytes = write(session, buf, length);
> }
> {code}
>
> instead
> of
>
> {code:java}
> try {
> localWrittenBytes = this.write(session, buf, length);
> }
> {code}
>
> > AbstractIoSession getScheduledWriteMessages always -negative?
> > -
> >
> > Key: DIRMINA-1057
> > URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> > Project: MINA
> >  Issue Type: Bug
> >  Components: Core
> >Affects Versions: 2.0.16
> > Environment: I'm testing slow consumer backlog detection and
> while getScheduledWriteBytes() correctly grows, getScheduledWriteMessages
> is always negative and does not increase. looking into code to see why but
> putting bug report here as well for tracking
> >Reporter: Andre Mermegas
> >
>
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.4.14#64029)
>


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-14 Thread Emmanuel Lecharny (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16204593#comment-16204593
 ] 

Emmanuel Lecharny commented on DIRMINA-1057:


Ok, I have reapplied the patch ( with a minor correction) and ran the test : 
all is green.

The correction is :

{code:java}
try {
localWrittenBytes = write(session, buf, length);
}
{code}

instead
of 

{code:java}
try {
localWrittenBytes = this.write(session, buf, length);
}
{code}

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-13 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16203654#comment-16203654
 ] 

David Gibbs commented on DIRMINA-1057:
--

I can try that with my new build. Will do soon. thanks

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-13 Thread Jonathan Valliere (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16203637#comment-16203637
 ] 

Jonathan Valliere commented on DIRMINA-1057:


David,

I ran the updated tests you provided and they passed against tag/2

10:28:34.981 [main] INFO  Producer - Is Completed ? [true]
10:28:34.981 [main] INFO  Producer - Task completed : [Success]. messages sent 
10, messages specified 10
10:28:34.981 [NioProcessor-2] INFO  Producer - session closed.
10:28:34.982 [main] INFO  Producer - Producer stopped.
10:28:34.982 [main] INFO  Producer - maxScheduledWriteBytes 1833 
10:28:34.982 [main] INFO  Producer - meanScheduledWriteBytes2.0  
10:28:34.984 [main] INFO  Producer - maxScheduledWriteMessages  39
10:28:34.984 [main] INFO  Producer - meanScheduledWriteMessages 0.0
10:28:34.984 [main] INFO  Producer - maxWriteRequestQueueSize   77
10:28:34.984 [main] INFO  Producer - meanWriteRequestQueueSize  0.0
10:28:34.984 [main] INFO  Producer - Status [Success]

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-13 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16203617#comment-16203617
 ] 

David Gibbs commented on DIRMINA-1057:
--

[~johnnyv] I have updated the test case in to run as an integration test, in 
case it is any help.
https://github.com/david-gibbs-ig/mina-test-case/tree/mina-only-case

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-11 Thread Emmanuel Lecharny (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16199971#comment-16199971
 ] 

Emmanuel Lecharny commented on DIRMINA-1057:


Hi Jonathan,

I'm pretty sure I didn't see the error before your patch. I will re-run it 
again to be sure it's not an artefact.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-10 Thread Jonathan Valliere (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16199124#comment-16199124
 ] 

Jonathan Valliere commented on DIRMINA-1057:


Emmanuel, are you sure that error wasn't present before the patch?  The 
assertion is based on a counter for {{messageReceived}}.  Since the proposed 
patch does not call or change the behavior of {{messageReceived}} I don't know 
how it could be responsible for the error.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-10 Thread Emmanuel Lecharny (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16198530#comment-16198530
 ] 

Emmanuel Lecharny commented on DIRMINA-1057:


Thanks for the patch, Jonathan, 

I have applied it and ran the tests, but I get an error :

{code:java}
testWriteUsingSocketTransport(org.apache.mina.filter.stream.StreamWriteFilterTest)
  Time elapsed: 5.112 sec  <<< FAILURE!
java.lang.AssertionError: expected:<4194304> but was:<1853616>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at 
org.apache.mina.filter.stream.AbstractStreamWriteFilterTest.testWriteUsingSocketTransport(AbstractStreamWriteFilterTest.java:355)
{code}

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-08 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16196042#comment-16196042
 ] 

David Gibbs commented on DIRMINA-1057:
--

Great thanks Jonathan. I'll watch for a post on commit. I appreciate your help.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread Jonathan Valliere (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195937#comment-16195937
 ] 

Jonathan Valliere commented on DIRMINA-1057:


Okay, sorry for all the edits of the previous comment.

Here is the deal.  
* {{org.apache.mina.filter.codec.ProtocolCodecFilter}} produces two 
WriteRequest objects for every 1 input.
* {{DefaultIoFilterChain$HeadFilter#filterWrite}} only called 
{{increaseScheduledWriteMessages}} when {{getMessage()}} was not an instanceof 
{{IoBuffer}} which causes other problems because File requests are transferred 
down the {{fireMessageSent}} chain and cause the count to go negative also.
* {{DefaultIoFilterChain#fireMessageSent}} discriminates against Encoded 
requests and will not allow them down the chain.
* {{AbstractPollingIoProcessor#writeBuffer}} contains a couple of errors when 
dealing with empty write requests or null checks for the existance of an 
OriginalRequest.

h3. *Fix HeadFilter*

{code:java}
public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest 
writeRequest) throws Exception
{
AbstractIoSession s = (AbstractIoSession) session;

// Maintain counters.
if (writeRequest.getMessage() instanceof IoBuffer)
{
IoBuffer buffer = (IoBuffer) 
writeRequest.getMessage();
// I/O processor implementation will call 
buffer.reset()
// it after the write operation is finished, 
because
// the buffer will be specified with 
messageSent event.
buffer.mark();
int remaining = buffer.remaining();

if (remaining > 0)
{

s.increaseScheduledWriteBytes(remaining);
}
}

if (!writeRequest.isEncoded())
{
s.increaseScheduledWriteMessages();
}

WriteRequestQueue writeRequestQueue = 
s.getWriteRequestQueue();

if (!s.isWriteSuspended())
{
if (writeRequestQueue.isEmpty(session))
{
// We can write directly the message
s.getProcessor().write(s, writeRequest);
}
else
{
s.getWriteRequestQueue().offer(s, 
writeRequest);
s.getProcessor().flush(s);
}
}
else
{
s.getWriteRequestQueue().offer(s, writeRequest);
}
}
{code}

h3. *Fix AbstractPollingIoProcessor*

{code:java}
private int writeBuffer(S session, WriteRequest req, boolean hasFragmentation, 
int maxLength, long currentTime) throws Exception
{
IoBuffer buf = (IoBuffer) req.getMessage();
int localWrittenBytes = 0;

if (buf.hasRemaining())
{
int length;

if (hasFragmentation)
{
length = Math.min(buf.remaining(), maxLength);
}
else
{
length = buf.remaining();
}

try
{
localWrittenBytes = this.write(session, buf, 
length);
}
catch (IOException ioe)
{
ioe.printStackTrace();

// We have had an issue while trying to send 
data to the
// peer : let's close the session.
buf.free();
session.closeNow();
this.removeNow(session);

return 0;
}

session.increaseWrittenBytes(localWrittenBytes, 
currentTime);

// Now, forward the original message
if (!buf.hasRemaining() || (!hasFragmentation && 
(localWrittenBytes != 0)))
{
WriteRequest originalRequest = 
req.getOriginalRequest();

  

[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread Jonathan Valliere (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195839#comment-16195839
 ] 

Jonathan Valliere commented on DIRMINA-1057:


Okay, looks like I found a condition where fireMessageSent can occur more than 
once per WriteRequest causing the counter to go negative.


{code:java}
int localWrittenBytes = send(session, buf, destination);

if ((localWrittenBytes == 0) || (writtenBytes >= 
maxWrittenBytes)) {
// Kernel buffer is full or wrote too much
setInterestedInWrite(session, true);

session.getWriteRequestQueue().offer(session, writeRequest);
scheduleFlush(session);
} else {
setInterestedInWrite(session, false);

// Clear and fire event
session.setCurrentWriteRequest(null);
writtenBytes += localWrittenBytes;
buf.reset();
session.getFilterChain().fireMessageSent(writeRequest);

break;
}
{code}

It checks the condition {{((localWrittenBytes == 0) || (writtenBytes >= 
maxWrittenBytes))}} which is incorrect.  It should be {{((localWrittenBytes == 
0) || buf.hasRemaining() || (writtenBytes >= maxWrittenBytes))}}



> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195832#comment-16195832
 ] 

David Gibbs commented on DIRMINA-1057:
--

Will do.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread Jonathan Valliere (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195829#comment-16195829
 ] 

Jonathan Valliere commented on DIRMINA-1057:


Can you check {{session.getWriteRequestQueue.size}} and see if that goes 
negative?

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195828#comment-16195828
 ] 

David Gibbs commented on DIRMINA-1057:
--

Thank you Jonathan, I started investigating as it seems as if a QuickfFIX/J 
that relies on getScheduledMessages to detect slow consumers did not behave as 
I expected. getScheduledBytes does seem to work. I attached a link to an 
example that shows getScheduledMessages decrementing.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread Jonathan Valliere (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195825#comment-16195825
 ] 

Jonathan Valliere commented on DIRMINA-1057:


Okay, I pulled the {{tag/2.0.16}} and found {{FileRegion}} writes increase the 
write counter and decrease the backlog causing a negative backlog because the 
{{FileRegion}} never increases the backlog.  Are you writing Files at all?

Also {{decreaseScheduledBytesAndMessages}} is called during close and not 
during the normal course of operation.  What you should look at is 
{{session.increaseWrittenBytes}} because it in turn decreases backlog by 
calling {{increaseScheduledBytes}}

The function {{increaseScheduledBytes}} is only called by:
* {{AbstractIoSession#decreaseScheduledBytesAndMessages}} 
* {{HeadFilter#filterWrite}} 
* {{AbstractIoSession#increaseWrittenBytes}}

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195758#comment-16195758
 ] 

David Gibbs commented on DIRMINA-1057:
--

In AbstractIoSession - the method decreaseScheduledBytesAndMessages decrements 
the message count when the buffer is empty. This is  called from 
clearWriteRequestQueue(S session) in AbstractPollinIoProcessor. I think that in 
cases where the message is IoBuffer the message count is only decremented. I 
don't know how to write a unit test for this but if I write messages with a 
delay "session.write(news).await(10);" or wait uninterruptedly I can see the 
result of getScheduledWriteMessages() decrementing constantly while 
getScheduledWriteBytes() remains 0.

If I don't wait the sceduledMsgBytes increases due to the buffer and 
getScheduledWriteMessages remains 0, presumably as a result of the code below. 
line 1012 in AbstractIoSession .

I was thinking that the "WriteMessages" does not make sense when the message is 
an IoBuffer but I doubt that I understand the intent of this code.

Oct 07, 2017 4:33:06 PM org.apache.mina.filter.logging.LoggingFilter log
INFO: SENT: 8=FIX.4.49=2535=B148=Headline : 778410=048
scheduled write messages -7785
scheduled write bytes 0

/**
 * Decrease the counters of written messages and written bytes when a 
message has been written
 * 
 * @param request The written message
 */
public final void decreaseScheduledBytesAndMessages(WriteRequest request) {
Object message = request.getMessage();

if (message instanceof IoBuffer) {
IoBuffer b = (IoBuffer) message;

if (b.hasRemaining()) {
increaseScheduledWriteBytes(-((IoBuffer) message).remaining());
} else {
decreaseScheduledWriteMessages();
}
} else {
decreaseScheduledWriteMessages();
}
}

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


Re: [jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-07 Thread Jonathan Valliere
Emmanuel,

I’m not sure my discussions is warranted inside of the ticket unless I come
to some sort of conclusion.

I don’t think that is true that the message is stacked in the IoProcessor
Queue.

@Override
public void write(S session, WriteRequest writeRequest) {
WriteRequestQueue writeRequestQueue =
session.getWriteRequestQueue();

writeRequestQueue.offer(session, writeRequest);

if (!session.isWriteSuspended()) {
this.flush(session);
}
}

WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();

if (!s.isWriteSuspended()) {
if (writeRequestQueue.isEmpty(session)) {
// We can write directly the message
s.getProcessor().write(s, writeRequest);
} else {
s.getWriteRequestQueue().offer(s, writeRequest);
s.getProcessor().flush(s);
}
} else {
s.getWriteRequestQueue().offer(s, writeRequest);
}

@Override
public final void flush(S session) {
// add the session to the queue if it's not already
// in the queue, then wake up the select()
if (session.setScheduledForFlush(true)) {
flushingSessions.add(session);
wakeup();
}
}

Both use Session.getWriteRequestQueue.  Seems like the IoProcessor has a
Queue which contains IoSession objects and not the Writable Data.
Basically, I’m looking for a concise place to unify and make the counters
thread-safe.

On Fri, Oct 6, 2017 at 6:56 PM, Emmanuel Lécharny 
wrote:

> Hi Jonathan,
>
>
> it's probably better to put your comment in the JIRA ticket, for a
> better follow up...
>
>
> That being said,
>
>
> Le 06/10/2017 à 20:08, Jonathan Valliere a écrit :
> > I haven’t looked at the Mina code in a while.  Looking at
> > DefaultIoFilterChain.java under HeadFilter#filterWrite
> >
> > WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();
> >
> > if (!s.isWriteSuspended()) {
> > if (writeRequestQueue.isEmpty(session)) {
> > // We can write directly the message
> > s.getProcessor().write(s, writeRequest);
> > } else {
> > s.getWriteRequestQueue().offer(s, writeRequest);
> > s.getProcessor().flush(s);
> > }
> > } else {
> > s.getWriteRequestQueue().offer(s, writeRequest);
> > }
> >
> > Checking and working with the WriteRequestQueue is unnecessary because
> the
> > AbstractPollingIoProcessor adds all write requests to the Queue anyway.
>
> Those are two different queues. The HeadFilter stacks the message in a
> session queue, while the AbstractPollingIoProcessor stacks the message
> in the IoProcessor queue. You may have thousands of sessions but nly a
> few IoProcessor which handle many sessions.
> >
> > Similarly, it is confusing that the HeadFilter is controlling the
> > increaseScheduledWriteBytes.  This should be controlled by the
> > AbstractPollingIoProcessor to ensure safety of the increase/decrease
> > operations.
>
> Again, this is a per session counter vs a per IoProcessor counter. The
> application is really interested on what happens on ifself.
>
> --
> Emmanuel Lecharny
>
> Symas.com
> directory.apache.org
>
>


Re: [jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-06 Thread Jonathan Valliere
Additionally, moving the Queue control into the AbstractPollingIoProcessor
and increasing backlog before adding to Queue and decreasing after removing
will prevent the negative number race condition.

On Fri, Oct 6, 2017 at 2:08 PM, Jonathan Valliere 
wrote:

> I haven’t looked at the Mina code in a while.  Looking at
> DefaultIoFilterChain.java under HeadFilter#filterWrite
>
> WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();
>
> if (!s.isWriteSuspended()) {
> if (writeRequestQueue.isEmpty(session)) {
> // We can write directly the message
> s.getProcessor().write(s, writeRequest);
> } else {
> s.getWriteRequestQueue().offer(s, writeRequest);
> s.getProcessor().flush(s);
> }
> } else {
> s.getWriteRequestQueue().offer(s, writeRequest);
> }
>
> Checking and working with the WriteRequestQueue is unnecessary because the
> AbstractPollingIoProcessor adds all write requests to the Queue anyway.
>
> Similarly, it is confusing that the HeadFilter is controlling the
> increaseScheduledWriteBytes.  This should be controlled by the
> AbstractPollingIoProcessor to ensure safety of the increase/decrease
> operations.
>
> On Fri, Oct 6, 2017 at 12:05 PM, Emmanuel Lecharny (JIRA)  > wrote:
>
>>
>> [ https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.
>> atlassian.jira.plugin.system.issuetabpanels:comment-tabpane
>> l=16194776#comment-16194776 ]
>>
>> Emmanuel Lecharny commented on DIRMINA-1057:
>> 
>>
>> There might be a race condition, where the {{scheduledWriteMessages}} is
>> decremented before being incremented.
>>
>> Now this counter is not really interesting : it just count the number of
>> messages waiting to be sent (or fully written) to the client. Ultimately,
>> it should be 0 most of the time.
>>
>> > AbstractIoSession getScheduledWriteMessages always -negative?
>> > -
>> >
>> > Key: DIRMINA-1057
>> > URL: https://issues.apache.org/jira/browse/DIRMINA-1057
>> > Project: MINA
>> >  Issue Type: Bug
>> >  Components: Core
>> >Affects Versions: 2.0.16
>> > Environment: I'm testing slow consumer backlog detection and
>> while getScheduledWriteBytes() correctly grows, getScheduledWriteMessages
>> is always negative and does not increase. looking into code to see why but
>> putting bug report here as well for tracking
>> >Reporter: Andre Mermegas
>> >
>>
>>
>>
>>
>> --
>> This message was sent by Atlassian JIRA
>> (v6.4.14#64029)
>>
>
>


Re: [jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-06 Thread Jonathan Valliere
I haven’t looked at the Mina code in a while.  Looking at
DefaultIoFilterChain.java under HeadFilter#filterWrite

WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();

if (!s.isWriteSuspended()) {
if (writeRequestQueue.isEmpty(session)) {
// We can write directly the message
s.getProcessor().write(s, writeRequest);
} else {
s.getWriteRequestQueue().offer(s, writeRequest);
s.getProcessor().flush(s);
}
} else {
s.getWriteRequestQueue().offer(s, writeRequest);
}

Checking and working with the WriteRequestQueue is unnecessary because the
AbstractPollingIoProcessor adds all write requests to the Queue anyway.

Similarly, it is confusing that the HeadFilter is controlling the
increaseScheduledWriteBytes.  This should be controlled by the
AbstractPollingIoProcessor to ensure safety of the increase/decrease
operations.

On Fri, Oct 6, 2017 at 12:05 PM, Emmanuel Lecharny (JIRA) 
wrote:

>
> [ https://issues.apache.org/jira/browse/DIRMINA-1057?page=
> com.atlassian.jira.plugin.system.issuetabpanels:comment-
> tabpanel=16194776#comment-16194776 ]
>
> Emmanuel Lecharny commented on DIRMINA-1057:
> 
>
> There might be a race condition, where the {{scheduledWriteMessages}} is
> decremented before being incremented.
>
> Now this counter is not really interesting : it just count the number of
> messages waiting to be sent (or fully written) to the client. Ultimately,
> it should be 0 most of the time.
>
> > AbstractIoSession getScheduledWriteMessages always -negative?
> > -
> >
> > Key: DIRMINA-1057
> > URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> > Project: MINA
> >  Issue Type: Bug
> >  Components: Core
> >Affects Versions: 2.0.16
> > Environment: I'm testing slow consumer backlog detection and
> while getScheduledWriteBytes() correctly grows, getScheduledWriteMessages
> is always negative and does not increase. looking into code to see why but
> putting bug report here as well for tracking
> >Reporter: Andre Mermegas
> >
>
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.4.14#64029)
>


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-06 Thread Emmanuel Lecharny (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194776#comment-16194776
 ] 

Emmanuel Lecharny commented on DIRMINA-1057:


There might be a race condition, where the {{scheduledWriteMessages}} is 
decremented before being incremented.

Now this counter is not really interesting : it just count the number of 
messages waiting to be sent (or fully written) to the client. Ultimately, it 
should be 0 most of the time.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-06 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194767#comment-16194767
 ] 

David Gibbs commented on DIRMINA-1057:
--

I don't think that I understand this code well but is it the case that if one 
is using a ProtocolCodecFilter - that contains an IoBuffer - 
ScheduledWriteMessages will not be incremented ?
The fragment below from DefaultIoFilterChain (for the referenced version) 
suggests that ScheduledWriteBytes or ScheduledWriteMessages will be 
incremented, not both.

// Maintain counters.
if (writeRequest.getMessage() instanceof IoBuffer) {
IoBuffer buffer = (IoBuffer) writeRequest.getMessage();
// I/O processor implementation will call buffer.reset()
// it after the write operation is finished, because
// the buffer will be specified with messageSent event.
buffer.mark();
int remaining = buffer.remaining();

if (remaining > 0) {
s.increaseScheduledWriteBytes(remaining);
}
} else {
s.increaseScheduledWriteMessages();
} 

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2017-10-06 Thread David Gibbs (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194603#comment-16194603
 ] 

David Gibbs commented on DIRMINA-1057:
--

Andre, how did you test this ? We think that we have the same issue.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2016-11-30 Thread Andre Mermegas (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15708962#comment-15708962
 ] 

Andre Mermegas commented on DIRMINA-1057:
-

not at present. will try and produce one.

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (DIRMINA-1057) AbstractIoSession getScheduledWriteMessages always -negative?

2016-11-29 Thread Emmanuel Lecharny (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15706818#comment-15706818
 ] 

Emmanuel Lecharny commented on DIRMINA-1057:


H, sounds like a bug. Do you have a reproductible test case ?

> AbstractIoSession getScheduledWriteMessages always -negative?
> -
>
> Key: DIRMINA-1057
> URL: https://issues.apache.org/jira/browse/DIRMINA-1057
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.16
> Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)