Closed hazzakak closed 5 years ago
Interesting, I think I just found the problem. If you look at our API, we have it written in golang and the way it connects to a database is a pool of connections. So when we make a database query, golang already has a number of active maintained connections, we take one from the pool, execute it, finish our query and return our connection to the pool. If no connection is available from the pool, we request one from the database.
The problem arises because a database can hold about 256 connections at a time, at least our database behaves that way. When I was looking at the logs, the exceptions were that database could not provide more connections and API was failing because of that. I would say it is because some scripts do no sanitize or close their requests properly, se we have some dangling connections. Basically, a leak. It is an internal error. I will try to take a look at our Go scripts and see if I did not closes something. Which would be very weird, as I always defer any opening statements.
Maybe it is our python scripts that overwhelm the database. I will take a look at this. Feel free to inspect it too or report if you have more questions. To battle this, I restarted the database, which flushed all of the active/dangling connections.
O LA LA. Silly me. I found the error. In one of the methods, I did not close a DB connection and it was dangling after that. Our DB has a limit of 100 simultaneous connections, so if the function is executed 100 times, DB dies. I just fixed it in the following urgent commit! c6669ee
O LA LA. Silly me. I found the error. In one of the methods, I did not close a DB connection and it was dangling after that. Our DB has a limit of 100 simultaneous connections, so if the function is executed 100 times, DB dies. I just fixed it in the following urgent commit! c6669ee
Thank you!!!
Also, here is the next commit 5a0d59d
Describe the bug I have a discord script which allows users to see active investments, a summary of their account etc but I have noticed that it produces an error if it's used too many times. The rate is ridiculous it's like 1 command per 10 seconds or it returns an error.
To Reproduce Steps to reproduce the behaviour:
Go to https://meme.market/api/investor/hazzakak_ Reload a few times See error Expected behaviour The page to not return an error but to return the investor.
Screenshots https://gyazo.com/37772d4721c17a72b8f3390794842954
Desktop (please complete the following information):
OS: Win10 Browser: Chrome Additional context I'm using requests_async