translate / pootle

Online translation tool
http://pootle.translatehouse.org
GNU General Public License v3.0
1.49k stars 288 forks source link

Can't Init the databse #6875

Closed goetas closed 6 years ago

goetas commented 6 years ago

Hi, Im having some troubles to init the database (mysql 5.7). Any help?

Steps to reproduce:

(env) root@f4dbe971a6b1:/home/pootle/env# pootle initdb

Results (Expected/Actual):

Actual:

(env) root@f4dbe971a6b1:/home/pootle/env# pootle initdb
Populating the database.
Traceback (most recent call last):
  File "/home/pootle/env/bin/pootle", line 11, in <module>
    sys.exit(main())
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/runner.py", line 357, in main
    run_app(project='pootle', django_settings_module='pootle.settings')
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/runner.py", line 338, in run_app
    management.execute_from_command_line(command)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_app/management/commands/initdb.py", line 36, in handle
    InitDB().init_db(options["create_projects"])
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/core/initdb.py", line 36, in init_db
    self._init_db(create_projects)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/core/initdb.py", line 49, in _init_db
    self.create_terminology_project()
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/core/initdb.py", line 244, in create_terminology_project
    terminology = self._create_object(Project, **criteria)[0]
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/core/initdb.py", line 62, in _create_object
    instance, created = model_klass.objects.get_or_create(**criteria)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_project/models.py", line 75, in get_or_create
    ProjectManager, self).get_or_create(*args, **kwargs)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 475, in get_or_create
    return self._create_object_from_params(lookup, params)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 505, in _create_object_from_params
    obj = self.create(**params)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 399, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_project/models.py", line 405, in save
    super(Project, self).save(*args, **kwargs)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 796, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 833, in save_base
    update_fields=update_fields, raw=raw, using=using)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 191, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_translationproject/models.py", line 442, in scan_languages
    tp.update_from_disk()
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_translationproject/models.py", line 326, in update_from_disk
    self._update_from_disk(force=force, overwrite=overwrite)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_translationproject/models.py", line 352, in _update_from_disk
    if store.updater.update_from_disk(overwrite=overwrite):
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_store/updater.py", line 372, in update_from_disk
    store_revision=store_revision)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_store/updater.py", line 275, in update
    return self._update(*args, **kwargs)
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_store/updater.py", line 302, in _update
    self.target_store.save()
  File "/home/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_store/models.py", line 859, in save
    super(Store, self).save(*args, **kwargs)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 796, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 824, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 889, in _save_table
    forced_update)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 939, in _do_update
    return filtered._update(values) > 0
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 654, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1148, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
    cursor.execute(sql, params)
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 59, in execute
    self.db.validate_no_broken_transaction()
  File "/home/pootle/env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 428, in validate_no_broken_transaction
    "An error occurred in the current transaction. You can't "
django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
(env) root@f4dbe971a6b1:/home/pootle/env# 

Expected to have the database initialized

Environment (i.e. 'pootle --version', DB, OS, Browser):

(env) root@f4dbe971a6b1:/home/pootle/env# pootle --version
Pootle 2.8.2 (Django 1.10.8, Translate Toolkit 2.2.5)

Database config section:

# Database backend settings
DATABASES = {
    'default': {
        # Replace 'sqlite3' with 'postgresql' or 'mysql'.
        'ENGINE': 'django.db.backends.mysql',
        # Database name or path to database file if using sqlite3.
        'NAME': os.environ.get('MYSQL_DATABASE'),
        # Not used with sqlite3.
        'USER': os.environ.get('MYSQL_USER'),
        # Not used with sqlite3.
        'PASSWORD': os.environ.get('MYSQL_PASSWORD'),
        # Set to empty string for localhost. Not used with sqlite3.
        'HOST': 'mysql',
        # Set to empty string for default. Not used with sqlite3.
        'PORT': '3306',
        'ATOMIC_REQUESTS': True
    }
}

pootle migrate worked fine, so the connection to the db should be ok. Tried removing ATOMIC_REQUESTS but same results

goetas commented 6 years ago

The mysql 5.7 default collation is Swedish :-/ .... starting mysql with mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci worked