[ https://issues.apache.org/jira/browse/THRIFT-4847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17871057#comment-17871057 ]
Jens Geyer edited comment on THRIFT-4847 at 8/6/24 1:58 PM: ------------------------------------------------------------ {quote}is there an ETA on the next release?{quote} Not yet. When ready. We usually release twice a year, but there is no fixed date. was (Author: jensg): What about tomorrow? Sent from mobile device. > CancelledKeyException causes TThreadedSelectorServer to fail. > ------------------------------------------------------------- > > Key: THRIFT-4847 > URL: https://issues.apache.org/jira/browse/THRIFT-4847 > Project: Thrift > Issue Type: Bug > Components: Java - Library > Affects Versions: 0.12.0 > Reporter: Keith Turner > Assignee: Jens Geyer > Priority: Major > Fix For: 0.21.0 > > Time Spent: 3h 40m > Remaining Estimate: 0h > > When attempting to use TThreadedSelectorServer I see the following exception > and then the server becomes inoperable. > {noformat} > 2019-04-03 11:50:37,638 [server.TThreadedSelectorServer] ERROR: run() on > SelectorThread exiting due to uncaught error > java.nio.channels.CancelledKeyException > at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73) > at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:82) > at > org.apache.thrift.server.AbstractNonblockingServer$FrameBuffer.changeSelectInterests(AbstractNonblockingServer.java:440) > at > org.apache.thrift.server.AbstractNonblockingServer$AbstractSelectThread.processInterestChanges(AbstractNonblockingServer.java:191) > at > org.apache.thrift.server.TThreadedSelectorServer$SelectorThread.run(TThreadedSelectorServer.java:548) > {noformat} > I tracked this down and I think it is caused by the following events : > # A frame buffer is created and given a selection key > [TThreadedSelectorServer.java line > 691|https://github.com/apache/thrift/blob/v0.12.0/lib/java/src/org/apache/thrift/server/TThreadedSelectorServer.java#L691] > # The rebuild selector code introduced in THRIFT-4251 is triggered and all > selectors key are canceled when the selector is closed > [TThreadedSelectorServer.java line > 668|https://github.com/apache/thrift/blob/v0.12.0/lib/java/src/org/apache/thrift/server/TThreadedSelectorServer.java#L668] > # A frame buffer attempts to modify its invalid selection key causing an > exception [AbstractNonblockingServer.java line > 440|https://github.com/apache/thrift/blob/v0.12.0/lib/java/src/org/apache/thrift/server/AbstractNonblockingServer.java#L440] > I added some logging and found that {{selector.select()}} would return 0 > hundreds of times, but not infinitely. I changed > SELECTOR_AUTO_REBUILD_THRESHOLD from 512 to 1,000,000 and the bug did not > happen. I don't think this change is the fix, its just what I did as part of > debugging this. Not sure what the best fix for this is. > The situation that triggers this seems to be lots of connections in a very > short time period. -- This message was sent by Atlassian Jira (v8.20.10#820010)