Databases

MySQL

MySQL error: OperationalError: (1267, "Illegal mix of collations (latin1_swedish_ci, IMPLICIT) and (utf8_general_ci, COERCIBLE) for operation '='”)

$ mayan-edms.py shell
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute('SHOW TABLES')
>>> results=[]
>>> for row in cursor.fetchall(): results.append(row)
>>> for row in results: cursor.execute('ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' % (row[0]))

References:

MySQL error: Incorrect string value: `'xE2x80x95rs6…'` for column `'content'` at row 1

When using MySQL and doing OCR on languages other than English

Use utf-8 collation on MySQL server, or at least in table ‘documents_documentpage’, ‘content’ field

References:

MySQL error: Error "django.db.utils.IntegrityError IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`…`.`…`, CONSTRAINT `…_refs_id_b0252274` FOREIGN KEY (`…`) REFERENCES `…` (`…`))')

Solution: Convert all MySQL tables to the same type, either all MyISAM or InnoDB

MySQL error: ValueError: Found wrong number (0) of constraints for actstream_follow(user_id, content_type_id, object_id)

This is caused by a bug in Django 1.11. The issue has been fixed for Django 2.0 version which Mayan EDMS will be migrating to for version 4.0.

Mitigation: Avoid MySQL versions: 8.0.x. Use MySQL 5.7 or earlier.

References: - https://code.djangoproject.com/ticket/27946 - https://code.djangoproject.com/ticket/29480 - https://github.com/divio/django-cms/issues/5716

PostgreSQL

PostgreSQL error: OperationalError: FATAL:  sorry, too many clients already

Set MAYAN_DATABASE_CONN_MAX_AGE to 0

This setting keeps a database connection alive. It allows reuse of database connections. When Mayan EDMS is deployed with Gunicorn a microthreads backend, the database connections are not shared and this setting has the reverse effect of exhausting the available PostgreSQL connections available. To avoid this, Setting MAYAN_DATABASE_CONN_MAX_AGE to 0 will cause all microthreads to release their connections, by closing them when finished.

References:

Postgresq database connection isn’t set to UTC

Django 2.2 not compatible with psycopg 2.9 and this issue won’t be fixed upstream.

The solution is to use psycopg < 2.9. Version 2.8.6 is the latest 2.8.x.

References: