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

Device or resource busy #3440

Closed
xoriole opened this issue Feb 5, 2018 · 23 comments
Closed

Device or resource busy #3440

xoriole opened this issue Feb 5, 2018 · 23 comments
Assignees

Comments

@xoriole
Copy link
Contributor

xoriole commented Feb 5, 2018

From reporter (Tribler 7.0.0)

crash occured shortly after displaying first channels after first startup

Traceback (most recent call last):
File "/usr/share/tribler/TriblerGUI/event_request_manager.py", line 99, in on_read_data
raise RuntimeError(json_dict["event"]["text"])
RuntimeError: [Failure instance: Traceback: <class 'socket.error'>: [Errno 16] Device or resource busy
/usr/lib/python2.7/threading.py:801:__bootstrap_inner
/usr/lib/python2.7/threading.py:754:run
/usr/lib/python2.7/site-packages/twisted/_threads/_threadworker.py:46:work
/usr/lib/python2.7/site-packages/twisted/_threads/_team.py:190:doWork
--- <exception caught here> ---
/usr/lib/python2.7/site-packages/twisted/python/threadpool.py:250:inContext
/usr/lib/python2.7/site-packages/twisted/python/threadpool.py:266:<lambda>
/usr/lib/python2.7/site-packages/twisted/python/context.py:122:callWithContext
/usr/lib/python2.7/site-packages/twisted/python/context.py:85:callWithContext
/usr/lib/python2.7/site-packages/twisted/internet/_resolver.py:124:get
]
@non-Jedi
Copy link

non-Jedi commented May 2, 2018

Per conversation on NixOS/nixpkgs#36065, it seems this bug was introduced some time between 7.0.0 rc3 and the 7.0.0 release. I was going to take a look and see if I could find anything, but there are quite a few commits there. Might want to control your rc process a little better.

@qstokkink
Copy link
Contributor

qstokkink commented Jun 22, 2018

The error seems to be here:

https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/_resolver.py#L123

My best guess is that this is the line that would cause this:

self.ip_resolve_deferred = self.register_task("resolve", reactor.resolve(self._tracker_address[0]))

@devos50
Copy link
Contributor

devos50 commented Jun 22, 2018

@non-Jedi thank you for your report. We are currently in the process of reproducing and fixing this bug within our environment. We will keep you updated!

@qstokkink
Copy link
Contributor

Can someone with NixOS send me the output of this script?

import urllib2, socket, urlparse
from twisted.internet import defer, reactor, threads


def error(failure):
    print str(failure)


def run():
    urls = ["https://www.google.com/", "http://www.python.org/", "https://github.com/"]
    try:
        deferreds = []
        for url in (urls):
            deferreds.append(reactor.resolve(url))
            deferreds[-1].addErrback(error)
        threads.blockingCallFromThread(reactor, lambda: defer.DeferredList(deferreds))
        print "Finished Twisted resolution"
    except:
        import traceback
        traceback.print_exc()
        print "Twisted reactor.resolve failed"

    try:
        for url in (urls):
            socket.gethostbyname(urlparse.urlparse(urllib2.urlopen(url).geturl()).hostname)
        print "Finished socket resolution"
    except:
        import traceback
        traceback.print_exc()
        print "Socket gethostbyname failed"
        
    reactor.callFromThread(reactor.stop)

reactor.callInThread(run)
reactor.run()

@non-Jedi
Copy link

@xvapx I'm not sure how to make a python environment with nix that looks like the one tribler sees. Maybe you have a better idea.

@xvapx
Copy link

xvapx commented Jun 26, 2018

@non-Jedi Yes, nixos generates a wrapper for tribler which exports all the needed environment variables and paths, you can actually run cat $(which tribler) to see the entire environment in which tribler will run.

@qstokkink output:

[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.DNSLookupError'>: DNS lookup failed: https://github.com/.
]
[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.DNSLookupError'>: DNS lookup failed: https://www.google.com/.
]
[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.DNSLookupError'>: DNS lookup failed: http://www.python.org/.
]
Finished Twisted resolution
Finished socket resolution

Is there any more test more I can do to help?

@qstokkink
Copy link
Contributor

@xvapx Thanks for testing: this apparently is not the issue making Tribler crash on Nix though.

One side-effect of testing this, is that we discovered that reactor.resolve is pretty bad at what it does.

@xvapx
Copy link

xvapx commented Jun 27, 2018

@qstokkink No problem, I'm testing 7.1.0-exp2 to see if something has changed on nixos, I'll report back.

@xvapx
Copy link

xvapx commented Jun 28, 2018

I'm working on it, having to fix some dependencies in nixpkgs.

@xvapx
Copy link

xvapx commented Jun 28, 2018

@qstokkink @non-Jedi
7.1.0-exp2 is no longer crashing in nixos, I'm testing that it actually works and will PR in nixpkgs.

EDIT: Lol, after about 10 minutes running, I just wrote this comment and tribler crashed with [Errno 16] Device or resource busy

@xvapx
Copy link

xvapx commented Jun 28, 2018

crash log:

Traceback (most recent call last):
  File "/home/xvapx/tmp/tribler/tmp/tribler/TriblerGUI/event_request_manager.py", line 127, in on_read_data
    raise RuntimeError(json_dict["event"]["text"])
RuntimeError: [Failure instance: Traceback: <class 'socket.error'>: [Errno 16] Device or resource busy
/nix/store/d3aa78jf7pm9lk6ad67x4f21a068dxn6-python-2.7.15/lib/python2.7/threading.py:801:__bootstrap_inner
/nix/store/d3aa78jf7pm9lk6ad67x4f21a068dxn6-python-2.7.15/lib/python2.7/threading.py:754:run
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/_threads/_threadworker.py:46:work
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/_threads/_team.py:190:doWork
--- <exception caught here> ---
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/threadpool.py:250:inContext
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/threadpool.py:266:<lambda>
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/context.py:122:callWithContext
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/context.py:85:callWithContext
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/internet/_resolver.py:124:get
]

@qstokkink
Copy link
Contributor

It seems the error is with Twisted: https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/_resolver.py#L123 seems to only catch gaierror and not a socket.error.

If we fix this on our end, it would be a nasty patch.

@qstokkink qstokkink reopened this Jun 28, 2018
@qstokkink
Copy link
Contributor

We appear to already have a nasty workaround method which we can add to: https://github.com/Tribler/tribler/blob/next/Tribler/Core/Session.py#L149 .

@qstokkink
Copy link
Contributor

This should be fixed now. We'll keep you posted on the build completion.

@qstokkink
Copy link
Contributor

Actually, release candidate 3 should be out tomorrow evening.

@xvapx
Copy link

xvapx commented Jun 28, 2018

Great, I'll test it ASAP, thanks a lot!

@xvapx
Copy link

xvapx commented Jun 29, 2018

@qstokkink
Sorry, bad news:

Traceback (most recent call last):
  File "/home/xvapx/tmp/tribler/tmp/tribler/TriblerGUI/event_request_manager.py", line 127, in on_read_data
    raise RuntimeError(json_dict["event"]["text"])
RuntimeError: [Failure instance: Traceback: <class 'socket.error'>: [Errno 16] Device or resource busy
/nix/store/d3aa78jf7pm9lk6ad67x4f21a068dxn6-python-2.7.15/lib/python2.7/threading.py:801:__bootstrap_inner
/nix/store/d3aa78jf7pm9lk6ad67x4f21a068dxn6-python-2.7.15/lib/python2.7/threading.py:754:run
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/_threads/_threadworker.py:46:work
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/_threads/_team.py:190:doWork
--- <exception caught here> ---
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/threadpool.py:250:inContext
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/threadpool.py:266:<lambda>
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/context.py:122:callWithContext
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/python/context.py:85:callWithContext
/nix/store/hfq5vjpvsx9j38jc30fkg0r095m4lq3r-python2.7-Twisted-18.4.0/lib/python2.7/site-packages/twisted/internet/_resolver.py:124:get
]

I've sent the report, it's the same bug, version 7.1.0-exp3, on NixOS.

@qstokkink qstokkink reopened this Jun 30, 2018
@xvapx
Copy link

xvapx commented Jul 3, 2018

Great, thanks a lot!

@devos50
Copy link
Contributor

devos50 commented Jul 4, 2018

@xvapx could you try out this build? https://jenkins.tribler.org/job/Build_Tribler_next/297/

@xvapx
Copy link

xvapx commented Jul 4, 2018

Yep, I'll try and report back

@xvapx
Copy link

xvapx commented Jul 5, 2018

@devos50 It's been running for more than one hour now, without a single crash.

@viric
Copy link

viric commented May 1, 2020

This crashes again in Tribler 7.4.4 (on NixOS release-20.03). Same thing.

Traceback (most recent call last):
  File "/nix/store/3rwchz4m7qbjm43x57pq7dsg3zzaz25a-tribler-7.4.4/TriblerGUI/event_request_manager.py", line 114, in on_read_data
    raise RuntimeError(json_dict["event"]["text"])
RuntimeError: [Failure instance: Traceback: <class 'OSError'>: [Errno 16] Device or resource busy
/nix/store/z4y3q5nsm1hhk7g18ywpnsdgqcgsvc2i-python3-3.7.6/lib/python3.7/threading.py:926:_bootstrap_inner
/nix/store/z4y3q5nsm1hhk7g18ywpnsdgqcgsvc2i-python3-3.7.6/lib/python3.7/threading.py:870:run
/nix/store/98n0hbsr0022jarj6xal83w5wldiyrqb-python3.7-Twisted-20.3.0/lib/python3.7/site-packages/twisted/_threads/_threadworker.py:46:work
/nix/store/98n0hbsr0022jarj6xal83w5wldiyrqb-python3.7-Twisted-20.3.0/lib/python3.7/site-packages/twisted/_threads/_team.py:190:doWork
--- <exception caught here> ---
/nix/store/98n0hbsr0022jarj6xal83w5wldiyrqb-python3.7-Twisted-20.3.0/lib/python3.7/site-packages/twisted/python/threadpool.py:250:inContext
/nix/store/98n0hbsr0022jarj6xal83w5wldiyrqb-python3.7-Twisted-20.3.0/lib/python3.7/site-packages/twisted/python/threadpool.py:266:<lambda>
/nix/store/98n0hbsr0022jarj6xal83w5wldiyrqb-python3.7-Twisted-20.3.0/lib/python3.7/site-packages/twisted/python/context.py:122:callWithContext
/nix/store/98n0hbsr0022jarj6xal83w5wldiyrqb-python3.7-Twisted-20.3.0/lib/python3.7/site-packages/twisted/python/context.py:85:callWithContext
/nix/store/98n0hbsr0022jarj6xal83w5wldiyrqb-python3.7-Twisted-20.3.0/lib/python3.7/site-packages/twisted/internet/_resolver.py:124:get
/nix/store/z4y3q5nsm1hhk7g18ywpnsdgqcgsvc2i-python3-3.7.6/lib/python3.7/socket.py:752:getaddrinfo
]```

@viric
Copy link

viric commented May 1, 2020

This doesn't happen in 7.5.0-rc5 so I guess it's all fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants