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

[7.2.x-7.11] Tribler often requires force shutdown to quit #6968

Closed
kozlovsky opened this issue Jul 13, 2022 · 1 comment
Closed

[7.2.x-7.11] Tribler often requires force shutdown to quit #6968

kozlovsky opened this issue Jul 13, 2022 · 1 comment
Assignees
Milestone

Comments

@kozlovsky
Copy link
Collaborator

kozlovsky commented Jul 13, 2022

Recently I started observing a bug when an attempt to close Tribler does not lead to a proper shutdown. Instead, a "Force shutdown" button appears after some delay, and clicking on it terminates the Core process without any finalization. As a result, the triblerd.lock file remains undeleted, and the internal libtorrent state remains unsaved. Some Tribler users experienced this bug as well.

It was not clear to me what was the cause for the force shutdown, and I suspected our latest refactorings. Because of this, I hesitated to publish a new release, as the reason for that bug could be something very nasty.

Now I finally was able to track the root of the problem. I added the logging of REST API requests cancellation, and it turns out that some requests are canceled pretty often, mainly to the /downloads?get_pieces=1 endpoint. The shutdown request is often become canceled as well.

I fixed the problem by re-sending the shutdown request if the previous one was canceled.

Byt why the shutdown request was canceled? Initially, I suspected that REST API could become overloaded with queries from the GUI, which may lead to dropped requests. But the real reason turns out to be a race condition in the TriblerWindow.close_tribler() method:

    def close_tribler(self, checked=False):
        ...
        self.core_manager.stop()  # <-- The shutdown request is created here
        self.downloads_page.stop_loading_downloads()
        request_manager.clear()  # <-- all requests to the REST API are canceled here

In the close_tribler method, a shutdown request is created, and almost immediately after that, all requests to Core are canceled. If the shutdown request is lucky and fast enough, it can reach Core before it is canceled, and in that case, we see the proper shutdown. But if Tribler is downloading several torrents and has some outgoing requests, the shutdown request is canceled before Tribler GUI can send it.

The addition of the re-sending logic to the canceled shutdown request was able to fix the problem.

@kozlovsky
Copy link
Collaborator Author

Fixed in 7.12

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

1 participant