mirror of
https://github.com/lldap/lldap.git
synced 2026-04-25 00:05:50 +03:00
[PR #1270] [MERGED] Fix database connection pool graceful shutdown using actix built-in signal handling #1220
Labels
No labels
backend
blocked
bug
cleanup
dependencies
docker
documentation
duplicate
enhancement
enhancement
frontend
github_actions
good first issue
help wanted
help wanted
integration
invalid
ldap
pull-request
question
rust
rust
tests
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/lldap-lldap#1220
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?
📋 Pull Request Information
Original PR: https://github.com/lldap/lldap/pull/1270
Author: @Copilot
Created: 9/3/2025
Status: ✅ Merged
Merged: 9/4/2025
Merged by: @nitnelave
Base:
main← Head:copilot/fix-1269📝 Commits (4)
5125002Initial plan864e7c7Implement graceful database connection pool shutdown1b43afcFix code formatting and finalize graceful DB shutdown implementationaf0382bSimplify database pool closure to use built-in actix signal handling📊 Changes
1 file changed (+14 additions, -6 deletions)
View changed files
📝
server/src/main.rs(+14 -6)📄 Description
Problem
Database connection pools were not being properly closed during server shutdown, causing the database server to remain unaware that connections were closed until TCP timeout. This could lead to connection limit issues during rapid server restarts, especially with client/server databases like MySQL and PostgreSQL.
From the sqlx documentation:
Solution
This PR implements proper graceful shutdown by calling
.close().awaiton database connection pools when the server shuts down, leveraging actix-server's built-in signal handling.Changes Made
Modified
set_up_server()functionResult<(ServerBuilder, DatabaseConnection)>to expose the database connection for cleanupSimplified
run_server_command()with minimal changesset_up_server()server.run().awaitwhich uses actix-server's built-in signal handlingUpdated
create_schema_command()Approach
Rather than implementing custom signal handling, this solution leverages actix-server's existing signal handling capabilities. When SIGTERM or SIGINT is received, actix-server gracefully shuts down and
server.run().awaitreturns, at which point we close the database connection pool.This ensures database servers are immediately notified of connection closures, preventing potential connection limit issues during deployments or rapid restarts.
Fixes #1269.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.