mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-02 22:57:00 -05:00
MSSQL concurrent connections to multiple servers interfere with each other #1713
Labels
No labels
A:accessibility
A:api
A:cert-expiry
A:core
A:dashboard
A:deployment
A:documentation
A:domain expiry
A:incidents
A:maintenance
A:metrics
A:monitor
A:notifications
A:reports
A:settings
A:status-page
A:ui/ux
A:user-management
Stale
ai-slop
blocked
blocked-upstream
bug
cannot-reproduce
dependencies
discussion
duplicate
feature-request
feature-request
good first issue
hacktoberfest
help
help wanted
house keeping
invalid
invalid-format
invalid-format
question
releaseblocker 🚨
security
spam
type:enhance-existing
type:new
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/uptime-kuma#1713
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jeff0485 on GitHub (Dec 29, 2022).
⚠️ Please verify that this bug has NOT been raised before.
🛡️ Security Policy
Description
Attempting to monitor multiple SQL servers, and have been receiving odd messages, intermittently. Have changed the connection strings multiple times to verify that everything connects properly, and when clicking 'Save', the connection succeeds.
Errors received:
'Database [Database] does not exist. Make sure that the name is entered correctly.' (after putting USE Database; into the query)
'Invalid object name 'Table'.' (without USE Database; in the query)
The head scratching part was that multiple servers would start having this issue simultaneously, and then they would all clear. Changing the timeout period did not have an effect. Increasing the 'retries' would cause the servers to all go yellow (Pending) for a while, and then after ONE failure they would all go green and start working again. Increasing the retries would simply increase the yellow/pending period, they would still return to green after one red/failure.
The giveaway was one period when there was an actual network disruption, one monitor showed a failure to connect -- to different monitor's SQL server address! Well no wonder you can't find the database and table, you're looking on the wrong server! The connection pool is sending queries out to any active connection, not necessarily the correct one. Resetting the connections, which is done when clicking 'save' on the configuration or presumably when a server errors out, gets them going again for a while until the next mix-up.
Digging through I have found some documentation on Node.js mssql which refers to common connection pools and a confirmation of my thought on StackOverflow here: https://stackoverflow.com/questions/64254145/node-js-mssql-multiple-concurrent-connections-to-sql-servers-interfering-with-ea
The relevant Node MSSQL documentation is here: https://www.npmjs.com/package/mssql#advanced-pool-management
Advanced Pool Management
For some use-cases you may want to implement your own connection pool management, rather than using the global connection pool. Reasons for doing this include:
Supporting connections to multiple databases
I unfortunately don't have the skill to merge the code together right now for a fix, but the page above includes a function that was built to check the connection pool for the proper connection string, and if present use that, but if not create a new connection.
👟 Reproduction steps
Add SQL monitors that link to multiple different servers which do not share identical database and table names.
👀 Expected behavior
Each SQL server is monitored separately and returns 'up' when the server is up.
😓 Actual Behavior
Servers (multiple at one time) would simultaneously fail with 'object not found' or 'database does not exist'. The queries do not appear to be going out through their respective connections, but to random or otherwise incorrect connections to the wrong server.
🐻 Uptime-Kuma Version
1.18.5
💻 Operating System and Arch
Ubuntu 20.04 amd64
🌐 Browser
Chrome 108.0.5359.124
🐋 Docker Version
Docker 20.10.17
🟩 NodeJS Version
No response
📝 Relevant log output
No response
@louislam commented on GitHub (Dec 29, 2022):
https://github.com/louislam/uptime-kuma/issues/2344#issuecomment-1339002296
I think I also found the issue a few week ago.
The current implementation is using only one connection pool globally, which is the main issue.