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

[BUG] REQUEST Connector pins CPU at maximum #1626

Open
lindnma opened this issue Dec 18, 2024 · 2 comments
Open

[BUG] REQUEST Connector pins CPU at maximum #1626

lindnma opened this issue Dec 18, 2024 · 2 comments
Assignees
Labels
bug can be closed If bug fixed or feature is implemented

Comments

@lindnma
Copy link

lindnma commented Dec 18, 2024

Describe the bug
When at least one mapping is assigned (aka. at least one endpoint needs to be queried) the iot-gateway spins the CPU up to whatever the maximum is. In case of a k8s deployment this means it even runs into CPU throttling.

Connector name (If bug in the some connector):
REQUEST Connector

Versions (please complete the following information):

  • OS: Docker Image: thingsboard/tb-gateway
  • Version: 3.6.1
  • Python version: ?
@lindnma
Copy link
Author

lindnma commented Dec 18, 2024

I have also taken a cursory look at the code, and the issue seems to be here:
thingsboard_gateway/connectors/request/request_connector.py Line 84 to 95

def run(self):
    while not self.__stopped:
        if self.__requests_in_progress:                 # This seems to be true as soon as one mapping is
            for request in self.__requests_in_progress: # configured, causing the while loop to always run here
                if time() >= request["next_time"]:
                    thread = Thread(target=self.__send_request, args=(request, self.__convert_queue, self._log),
                                    daemon=True,
                                    name="Request to endpoint \'%s\' Thread" % (request["config"].get("url")))
                    thread.start()
        else:         # The above code causes the sleep to never execute so the code will always immediately
            sleep(.2) # rerun and never put the thread to sleep

A potential fix could be to simply remove the else before the sleep directive and always allow the thread to sleep for .2s, tho I am not deep enough in the matter to know if this would have other ramifications.

@imbeacon
Copy link
Member

imbeacon commented Jan 7, 2025

Hi @lindnma,

Thank you for your interest in ThingsBoard IoT gateway, participation in project life and your investigation. We have added a fix for this issue, it will be available in next release.

@imbeacon imbeacon added the can be closed If bug fixed or feature is implemented label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug can be closed If bug fixed or feature is implemented
Projects
None yet
Development

No branches or pull requests

3 participants