@Jdiaz-co said in Timeout to lock table systemsettings:
hello good,
I'm having a problem. I'm using Mango 3.7.7 and the application crashes every so often.
The error I'm getting is this:
ERROR 2025-10-27T08:26:50,187 (com.serotonin.m2m2.util.timeout.TimeoutTask.run:61) - Uncaught Task Exception
org.springframework.dao.CannotAcquireLockException: PreparedStatementCallback; SQL [select settingValue from systemSettings where settingName=?]; Tiempo vencido intentando trabar (lock) la tabla "SYSTEMSETTINGS"
Timeout trying to lock table "SYSTEMSETTINGS"; SQL statement:
select settingValue from systemSettings where settingName=? [50200-199]; nested exception is org.h2.jdbc.JdbcSQLTimeoutException: Tiempo vencido intentando trabar (lock) la tabla "SYSTEMSETTINGS"I would appreciate any help.
thank you
Hello,
This error comes from the embedded H2 database: something is holding a lock on the SYSTEMSETTINGS table too long, so reads (like select settingValue from systemSettings…) time out and throw CannotAcquireLockException.
Common causes:
-
Another process/tool (H2 console, external SQL client) connected to the same H2 DB while Mango is running.
-
Long-running DB operations (backups, purges, heavy writes) that keep the table locked.
-
Short default H2 LOCK_TIMEOUT (1s) causing normal contention to show up as errors.
Things to try:
-
Make sure only Mango is connected to the H2 DB (no external tools while it’s running).
-
Increase H2 lock timeout in env.properties/mango.properties, e.g.
db.url=jdbc:h2:${ma.home}/databases/mah2;LOCK_TIMEOUT=10000 -
Check logs around the crash time for other FATAL/DB errors that might be the real shutdown cause.
If this is a production system (not just a test setup), I strongly recommend:
-
Migrating from H2 to MySQL (more robust under load and concurrency).
-
Upgrading Mango to a more recent supported version if possible, to benefit from DB and stability fixes.