Database Query Monitor — Monitor & Kill Long-Running Queries from Mendix - Mendix Forum

Database Query Monitor — Monitor & Kill Long-Running Queries from Mendix

0

Hi Team,


I've built and published a Java Action module that monitors and terminates long-running database queries in real-time — directly from a Mendix page. No external tools, no database console access needed.


Point it at any JDBC connection URL and it detects the database engine automatically, queries active sessions, and lets you kill stuck queries with one click.


What it does:


• Retrieves active queries exceeding a configurable time threshold — returns PID, duration, state, full SQL text, username, and application name

• Terminates problematic sessions securely with SQL injection protection (parameterized queries, integer validation, regex enforcement)

• Auto-detects five database engines from the connection URL: PostgreSQL, SQL Server, MySQL, MariaDB, and Oracle Database

• MySQL/MariaDB: Extracts the parent-level stored procedure call (e.g., SELECT my_function()) instead of internal child statements (e.g., DO SLEEP()) using Performance Schema at nesting level zero

• Automatic fallback to information_schema.processlist if Performance Schema is disabled or restricted

• Automatic driver fallback from MySQL to MariaDB connector if the MySQL JAR is absent

• Blocks unsupported built-in databases (H2/HSQLDB) with a clear error message


Use cases:


• Production troubleshooting — instantly find which query is locking your tables

• DBA operations without leaving Mendix — no need to open pgAdmin, SSMS, or MySQL Workbench

• Scheduled health checks — build a microflow that alerts your team when queries exceed a threshold

• Multi-database dashboards — monitor PostgreSQL, MySQL, and SQL Server from a single admin page


What's included:


• GetLongRunningQueries — retrieves all active queries above the threshold

• KillQuery — terminates a session by PID with full SQL injection protection


Requires Mendix 9+. Two Java Actions, two Non-Persistent Entities, zero module dependencies. Users provide their own JDBC driver JAR in userlib/.


Available on the Mendix Marketplace: https://marketplace.mendix.com/link/component/304269


Would love to hear your feedback, suggestions, or feature requests!


Posted
0 comments