QueryDeadlockError (1020) on fresh Docker install with MariaDB 11 when Insights is installed

## Environment

- Frappe version: v15.101.3 (latest)
- Insights version: 3.3.1
- MariaDB: 11.8 (official docker image)
- Deployment: Docker (custom image based on frappe/bench)
- Transaction isolation: REPEATABLE-READ (default)

## Steps to Reproduce

1. Fresh Docker deployment
2. Install Insights
3. Login for the first time
4. System automatically creates User → Contact
5. Background job `create_contact` runs
6. Error occurs

## Error

QueryDeadlockError: (1020, "Record has changed since last read in table 'tabContact'")

Traceback attached below.

## Observation

- If Insights is NOT installed → no error
- If database isolation level is changed to READ-COMMITTED → no error

## Suspected Cause

Insights hooks on Contact insert/update may be triggering additional DB reads/writes within the same transaction, which conflicts with MariaDB 11 default REPEATABLE READ isolation.

## Question

Should Insights defer its hooks using enqueue_after_commit=True or after_commit mechanism to avoid transaction conflicts under default MariaDB settings?
This commit is contained in:
1060778506 2026-03-02 20:54:37 +08:00 committed by GitHub
parent 85aaca4bd5
commit 73689ccf9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,6 +21,7 @@ services:
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
- --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6
- --transaction-isolation=READ-COMMITTED
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-123}
MARIADB_AUTO_UPGRADE: 1