Add warning when using SQLite as the database backend.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-04-09 03:48:47 -04:00
parent 27a257f010
commit 13f1730dda
7 changed files with 63 additions and 22 deletions

View File

@@ -145,6 +145,7 @@
- Make error messages persistent and increase the timeout of warning to 10 seconds.
- Improve rendering of the details form.
- Update rendering of the readonly multiselect widget to conform to Django's updated field class interface.
- Add warning when using SQLite as the database backend.
2.7.3 (2017-09-11)
==================

View File

@@ -339,6 +339,16 @@ transfer the rights to submissions. With these agreements in place
we now have a documented and legally sound method to accept
submissions that we couldn't before.
SQLite
------
Starting with version 3.0, a warning message will be shown in the console and
in the user interface when using SQLite as the database engine. When it comes to
Mayan EDMS, SQLite should only be used for development or testing, never for
production. This is due to Mayan EDMS exceeding the concurrency capabilities of
SQLite. The results are duplicated documents, frequency database locked errors,
among other issues. Suggested database backends are PostgreSQL and MySQL
(or MariaDB) using a transaction aware storage engine like InnoDB.
Other changes worth mentioning
------------------------------
- Add Makefile target to check the format of the README.rst file.

View File

@@ -26,7 +26,15 @@
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
{% block messages %}{% endblock %}
{% check_sqlite as check_sqlite %}
{% if check_sqlite %}
<div class="alert alert-dismissible alert-warning">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<p><strong>{% trans 'Warning' %}</strong> {{ check_sqlite }}</p>
</div>
{% endif %}
{% block messages %}
{% endblock %}
</div>
</div>

View File

@@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
from datetime import timedelta
import logging
import warnings
from kombu import Exchange, Queue
@@ -27,7 +28,7 @@ from .links import (
link_packages_licenses, link_setup, link_support, link_tools
)
from .literals import DELETE_STALE_UPLOADS_INTERVAL
from .literals import DELETE_STALE_UPLOADS_INTERVAL, MESSAGE_SQLITE_WARNING
from .menus import (
menu_about, menu_main, menu_secondary, menu_user
)
@@ -36,6 +37,7 @@ from .queues import * # NOQA - Force queues registration
from .settings import setting_auto_logging, setting_production_error_log_path
from .signals import pre_initial_setup, pre_upgrade
from .tasks import task_delete_stale_uploads # NOQA - Force task registration
from .utils import check_for_sqlite
logger = logging.getLogger(__name__)
@@ -87,6 +89,8 @@ class CommonApp(MayanAppConfig):
def ready(self):
super(CommonApp, self).ready()
if check_for_sqlite():
warnings.warn(force_text(MESSAGE_SQLITE_WARNING))
app.conf.CELERYBEAT_SCHEDULE.update(
{

View File

@@ -3,7 +3,12 @@ from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
DELETE_STALE_UPLOADS_INTERVAL = 60 * 10 # 10 minutes
DJANGO_SQLITE_BACKEND = 'django.db.backends.sqlite3'
MAYAN_PYPI_NAME = 'mayan-edms'
MESSAGE_SQLITE_WARNING = _(
'Your database backend is set to use SQLite. SQLite should only be used '
'for development and testing, not for production.'
)
PYPI_URL = 'https://pypi.python.org/pypi'
TIME_DELTA_UNIT_DAYS = 'days'
TIME_DELTA_UNIT_HOURS = 'hours'

View File

@@ -4,6 +4,7 @@ from json import dumps
import sh
from django.conf import settings
from django.template import Context, Library
from django.template.loader import get_template
from django.utils.encoding import force_text
@@ -11,7 +12,8 @@ from django.utils.encoding import force_text
import mayan
from ..classes import Collection, Dashboard
from ..utils import return_attrib
from ..literals import MESSAGE_SQLITE_WARNING
from ..utils import check_for_sqlite, return_attrib
register = Library()
@@ -23,6 +25,23 @@ except sh.CommandNotFound:
DATE = None
@register.simple_tag
def build():
if BUILD:
try:
return '{} {}'.format(BUILD(), DATE())
except sh.ErrorReturnCode_128:
return ''
else:
return ''
@register.simple_tag
def check_sqlite():
if check_for_sqlite():
return MESSAGE_SQLITE_WARNING
@register.simple_tag
def get_collections():
return Collection.get_all()
@@ -41,9 +60,9 @@ def get_encoded_parameter(item, parameters_dict):
return dumps(result)
@register.simple_tag
def project_information(attribute_name):
return getattr(mayan, attribute_name)
@register.filter
def get_type(value):
return force_text(type(value))
@register.filter
@@ -51,6 +70,11 @@ def object_property(value, arg):
return return_attrib(value, arg)
@register.simple_tag
def project_information(attribute_name):
return getattr(mayan, attribute_name)
@register.simple_tag(takes_context=True)
def render_subtemplate(context, template_name, template_context):
"""
@@ -61,18 +85,3 @@ def render_subtemplate(context, template_name, template_context):
new_context.update(Context(template_context))
return get_template(template_name).render(new_context.flatten())
@register.simple_tag
def build():
if BUILD:
try:
return '{} {}'.format(BUILD(), DATE())
except sh.ErrorReturnCode_128:
return ''
else:
return ''
@register.filter
def get_type(value):
return force_text(type(value))

View File

@@ -20,12 +20,16 @@ from common.compat import dict_type, dictionary_type
import mayan
from .exceptions import NotLatestVersion
from .literals import MAYAN_PYPI_NAME, PYPI_URL
from .literals import DJANGO_SQLITE_BACKEND, MAYAN_PYPI_NAME, PYPI_URL
from .settings import setting_temporary_directory
logger = logging.getLogger(__name__)
def check_for_sqlite():
return settings.DATABASES['default']['ENGINE'] == DJANGO_SQLITE_BACKEND
def check_version():
pypi = xmlrpc_client.ServerProxy(PYPI_URL)
versions = pypi.package_releases(MAYAN_PYPI_NAME)