[ 
https://issues.apache.org/jira/browse/THRIFT-2883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14241667#comment-14241667
 ] 

ASF GitHub Bot commented on THRIFT-2883:
----------------------------------------

GitHub user rthille opened a pull request:

    https://github.com/apache/thrift/pull/314

    THRIFT-2883 Fix dict changed size during iteration exception

    During the notification of outstanding requests via errback that the
      connection has failed, new requests can be attempted which change
      the size of the client._reqs dict.  This change uses a temp variable
      to hold the old dict, and resets client._reqs to a new, empty dict.
      Also, it iterates until the new dict does not have any requests added
      by the errbacks.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rthille/thrift THRIFT-2883

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/314.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #314
    
----
commit 55a86f53c05d243258f01037778fad20d53d070b
Author: Robert Thille <[email protected]>
Date:   2014-12-10T20:16:01Z

    THRIFT-2883 Fix dict changed size during iteration exception
    During the notification of outstanding requests via errback that the
      connection has failed, new requests can be attempted which change
      the size of the client._reqs dict.  This change uses a temp variable
      to hold the old dict, and resets client._reqs to a new, empty dict.
      Also, it iterates until the new dict does not have any requests added
      by the errbacks.

----


> TTwisted.py, during ConnectionLost processing: exceptions.RuntimeError: 
> dictionary changed size during iteration
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-2883
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2883
>             Project: Thrift
>          Issue Type: Bug
>    Affects Versions: 0.9.2
>            Reporter: Robert P. Thille
>              Labels: easyfix, patch
>         Attachments: THRIFT-2883.patch
>
>   Original Estimate: 5m
>  Remaining Estimate: 5m
>
> If any of the errbacks called by the connectionLost routine attempt to make 
> new requests over thrift (retries), the requests dictionary will change size 
> and Python with throw the RuntimeError exception and the clients will not be 
> properly notified of the connectionLost state change.
> 2014-12-06 02:22:16,808 ERROR    twisted      Unhandled Error
> Traceback (most recent call last):
>   File "/usr/lib/pymodules/python2.7/companyutils/service/__init__.py", line 
> 292, in main
>     self.reactor.run()
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 
> 1169, in run
>     self.mainLoop()
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 
> 1181, in mainLoop
>     self.doIteration(t)
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.py", 
> line 379, in doPoll
>     log.callWithLogger(selectable, _drdw, selectable, fd, event)
> --- <exception caught here> ---
>   File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in 
> callWithLogger
>     return callWithContext({"system": lp}, func, *args, **kw)
>   File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 69, in 
> callWithContext
>     return context.call({ILogContext: newCtx}, func, *args, **kw)
>   File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 
> 118, in callWithContext
>     return self.currentContext().callWithContext(ctx, func, *args, **kw)
>   File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, 
> in callWithContext
>     return func(*args,**kw)
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 
> 627, in _doReadOrWrite
>     self._disconnectSelectable(selectable, why, inRead)
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 
> 258, in _disconnectSelectable
>     selectable.readConnectionLost(f)
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 267, 
> in readConnectionLost
>     self.connectionLost(reason)
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 473, 
> in connectionLost
>     self._commonConnection.connectionLost(self, reason)
>   File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 287, 
> in connectionLost
>     protocol.connectionLost(reason)
>   File "/usr/lib/pymodules/python2.7/telephus/protocol.py", line 63, in 
> connectionLost
>     self._parent_protocol.connectionLost(self, reason)
>   File "/usr/lib/pymodules/python2.7/thrift/transport/TTwisted.py", line 84, 
> in connectionLost
>     for k, v in self.client._reqs.iteritems():
> exceptions.RuntimeError: dictionary changed size during iteration



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

Reply via email to