Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlushConsolidationHandler may suppress flushes by mistake #9931

Merged
merged 4 commits into from Jan 9, 2020

Conversation

@carryxyh
Copy link
Contributor

carryxyh commented Jan 9, 2020

Motivation:

When consolidatedWhenNoReadInProgress is true, channel.writeAndFlush (data) .addListener (f-> channel.writeAndFlush (data2)) Will cause data2 to never be flushed.

Because the flush operation will synchronously execute the channel.writeAndFlush (data2)) in the listener, and at this time, since the current execution thread is still an eventloop(executor.inEventLoop() was true), all handlers will be executed synchronously. At this time, since nextScheduledFlush is still not null, the flush operation of data2 will be ignored in FlushConsolidationHandler#scheduleFlush.

Modification:

  • reset nextScheduledFlush before ctx.flush
  • use ObjectUtil to polish code

Result:

Fixes #9923

@netty-bot

This comment has been minimized.

Copy link

netty-bot commented Jan 9, 2020

Can one of the admins verify this patch?

@normanmaurer

This comment has been minimized.

Copy link
Member

normanmaurer commented Jan 9, 2020

@carryxyh can you add a unit test as well ?

@carryxyh

This comment has been minimized.

Copy link
Contributor Author

carryxyh commented Jan 9, 2020

done. pls check..

assertEquals(1L, channel.readOutbound());
assertNull(channel.readOutbound());

channel.finish();

This comment has been minimized.

Copy link
@normanmaurer

normanmaurer Jan 9, 2020

Member

nit: assertFalse(channel.finish);

*/
@Test
public void testResend() throws Exception {

This comment has been minimized.

Copy link
@normanmaurer

normanmaurer Jan 9, 2020

Member

nit: remove empty line

@normanmaurer

This comment has been minimized.

Copy link
Member

normanmaurer commented Jan 9, 2020

@netty-bot test this please

@normanmaurer

This comment has been minimized.

Copy link
Member

normanmaurer commented Jan 9, 2020

@carryxyh please fix check style:

11:21:33 [INFO] --- maven-checkstyle-plugin:3.0.0:check (check-style) @ netty-handler ---
11:21:35 [INFO] Starting audit...
11:21:35 [ERROR] /code/handler/src/main/java/io/netty/handler/flush/FlushConsolidationHandler.java:99: Line is longer than 120 characters (found 122). [LineLength]
11:21:35 Audit done.
@normanmaurer

This comment has been minimized.

Copy link
Member

normanmaurer commented Jan 9, 2020

@netty-bot test this please

@normanmaurer

This comment has been minimized.

Copy link
Member

normanmaurer commented Jan 9, 2020

@carryxyh thanks a lot!

@normanmaurer normanmaurer merged commit 2be3d88 into netty:4.1 Jan 9, 2020
3 checks passed
3 checks passed
pull request validation (centos6-java11) Build finished.
Details
pull request validation (centos6-java12) Build finished.
Details
pull request validation (centos6-java8) Build finished.
Details
@normanmaurer normanmaurer added this to the 4.1.45.Final milestone Jan 9, 2020
normanmaurer added a commit that referenced this pull request Jan 9, 2020
Motivation:

When `consolidatedWhenNoReadInProgress` is true, `channel.writeAndFlush (data) .addListener (f-> channel.writeAndFlush (data2))` Will cause data2 to never be flushed.

Because the flush operation will synchronously execute the `channel.writeAndFlush (data2))` in the `listener`, and at this time, since the current execution thread is still an `eventloop`(`executor.inEventLoop()` was true), all handlers will be executed synchronously. At this time, since `nextScheduledFlush` is still not null, the `flush` operation of `data2` will be ignored in `FlushConsolidationHandler#scheduleFlush`.

Modification:

 - reset `nextScheduledFlush` before `ctx.flush`
 - use `ObjectUtil` to polish code

Result:

Fixes #9923
@carryxyh carryxyh deleted the carryxyh:fix-resend branch Jan 10, 2020
@normanmaurer normanmaurer changed the title Fix resend problem. FlushConsolidationHandler may suppress flushes by mistake Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.