Jump to: navigation, search

Jetty/Feature/JVM NIO Bug

< Jetty‎ | Feature
Revision as of 20:08, 9 February 2010 by Gregw.webtide.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



Introduction

The Sun JVM contains several NIO bugs that appear to mostly affect linux servers:

These bugs should be fixed in java 7, but jetty includes several work arounds to deal with these problems. If jetty has to employ these work arounds, you will see messages in your logs like:

  JVM BUG(s) - cancelled keys 16 times
  JVM BUG(s) - recreating selector 4 times, cancelled keys 32 times
  JVM BUG(s) - injecting delay 8 times

Feature

Triggering Work Arounds

The JVM bugs workarounds trigger whenever the NIO SelectSet returns from a select with zero keys selected, but before the expected timeout. The simple fixes (cancelling keys) always apply. The more draconian fixes are only attempted if the number of triggers exceeds a threshhold within a period, controlled by the following system parameters:

  • org.mortbay.io.nio.JVMBUG_THRESHHOLD, defaults to 512 and is the number of zero select returns that must be exceeded in a period.
  • org.mortbay.io.nio.MONITOR_PERIOD, defaults to 1000 and is the period over which the threshhold applies.

Cancelling Keys

Jetty has an optimization that dispatch connections are not removed from the select set, as this is an expensive operation. Instead, their interested operations are set to zero, so the registered key should be ignored. However this is one of the conditions that triggers


Recreating Selector

Injecting Delay

Busy key

Busy selector