Aim is to import a facility non-interactively into a pristine installation of Kolibri with sqlite and Postgres.
I recall having experienced the below errors even earlier when trying to import a facility via CLI. I had tried when I first noticed the --no-provision
option during 0.14.x beta testing. But I gave up assuming that I was attempting an unsupported feature.
I get the following error when using postgres -
$ kolibri manage sync --baseurl <url> --facility <facilityid> --no-push --username <superuser> --password <superuser_password>
WARNING:root:No C Extensions available for this platform.
/usr/lib/python3/dist-packages/kolibri/dist/rest_framework/utils/serializer_helpers.py:107: SyntaxWarning: "is" with a literal. Did you mean "=="?
if value is None or value is '':
INFO Running Kolibri with the following settings: kolibri.deployment.default.settings.base
WARNING Redis is configured without a maximum memory policy. Using Redis with Kolibri, the following is suggested: maxmemory-policy allkeys-lru
WARNING Redis is configured without a maximum memory size.
WARNING Problematic Redis settings detected, please see Redis configuration documentation for details: https://redis.io/topics/config
INFO Invoking command <truncated>
INFO Attempting connections to variations of the URL: http://content.myscoolserver.in
INFO Attempting connection to: http://content.myscoolserver.in/
INFO Success! We connected to: http://content.myscoolserver.in/api/public/info/
INFO Syncing has been initiated (this may take a while)...
INFO Creating pull transfer session
Remotely preparing data [##############################################################################################################################################################] 100%INFO There are no records to transfer
INFO Completed pull transfer session
Traceback (most recent call last):
File "/usr/bin/kolibri", line 11, in <module>
load_entry_point('kolibri==0.14.3', 'console_scripts', 'kolibri')()
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/kolibri/utils/cli.py", line 277, in invoke
return super(KolibriDjangoCommand, self).invoke(ctx)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/utils/cli.py", line 727, in manage
execute_from_command_line(["kolibri manage"] + ctx.args)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/management/commands/base.py", line 113, in handle
return self.handle_async(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 195, in handle_async
create_superuser_and_provision_device(
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/utils.py", line 209, in create_superuser_and_provision_device
facility = Facility.objects.get(dataset_id=dataset_id)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 378, in get
raise self.model.DoesNotExist(
kolibri.core.auth.models.DoesNotExist: Facility matching query does not exist.
Cleaned all sqlite files from .kolibri
and then one attempt with sqlite did seem to succeed and it was asking to create a local superuser but I terminated it mistakenly.
Subsequent attempt with sqlite yielded this error after a complete system and kolibri restart to avoid issues with redis locks -
$ sudo systemctl stop kolibri-server
$ rm .kolibri/db.sqlite3* .kolibri/notifications.sqlite3 .kolibri/job_storage.sqlite3
$ sudo systemctl stop kolibri-server
(checked that kolibri has started and landed at startup wizard)
$ kolibri manage sync --baseurl <url> --facility <facilityid> --no-push --username <superuser> --password <superuser_password>
WARNING:root:No C Extensions available for this platform.
/usr/lib/python3/dist-packages/kolibri/dist/rest_framework/utils/serializer_helpers.py:107: SyntaxWarning: "is" with a literal. Did you mean "=="?
if value is None or value is '':
INFO Running Kolibri with the following settings: kolibri.deployment.default.settings.base
WARNING Redis is configured without a maximum memory policy. Using Redis with Kolibri, the following is suggested: maxmemory-policy allkeys-lru
WARNING Redis is configured without a maximum memory size.
WARNING Problematic Redis settings detected, please see Redis configuration documentation for details: https://redis.io/topics/config
INFO Invoking command <truncated>
INFO Attempting connections to variations of the URL: http://content.myscoolserver.in
INFO Attempting connection to: http://content.myscoolserver.in/
INFO Success! We connected to: http://content.myscoolserver.in/api/public/info/
INFO Syncing has been initiated (this may take a while)...
INFO Creating pull transfer session
Receiving data (1000/1353, 2.38MB) [#####################################################################################################------------------------------------] 74% 00:00:42INFO Receiving data (1000/1353, 2.38MB)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/sqlite3/base.py", line 328, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.IntegrityError: UNIQUE constraint failed: morango_buffer.transfer_session_id, morango_buffer.model_uuid
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/bin/kolibri", line 11, in <module>
load_entry_point('kolibri==0.14.3', 'console_scripts', 'kolibri')()
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/kolibri/utils/cli.py", line 277, in invoke
return super(KolibriDjangoCommand, self).invoke(ctx)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/utils/cli.py", line 727, in manage
execute_from_command_line(["kolibri manage"] + ctx.args)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/management/commands/base.py", line 113, in handle
return self.handle_async(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 184, in handle_async
self._handle_pull(
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 269, in _handle_pull
sync_client.run()
File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/syncsession.py", line 692, in run
self._pull_records(callback=status.in_progress.fire)
File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/syncsession.py", line 757, in _pull_records
validate_and_create_buffer_data(
File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/utils.py", line 146, in validate_and_create_buffer_data
Buffer.objects.bulk_create(buffer_list)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 443, in bulk_create
ids = self._batched_insert(objs_without_pk, fields, batch_size)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 1102, in _batched_insert
self._insert(item, fields=fields, using=self.db)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 1079, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/sql/compiler.py", line 1112, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/sqlite3/base.py", line 328, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: UNIQUE constraint failed: morango_buffer.transfer_session_id, morango_buffer.model_uuid
All subsequent attempts after a system reboot with sqlite eventually results in the above error -
django.db.utils.IntegrityError: UNIQUE constraint failed: morango_buffer.transfer_session_id, morango_buffer.model_uuid
or even at times -
ERROR 2020-09-02 16:45:57,144 kolibri.core.tasks.worker Job 9201d5e21fdc445295232684c37605df raised an exception: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/worker.py", line 72, in handle_finished_future
result = future.result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/worker.py", line 217, in wrap
return f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/job.py", line 194, in y
result = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/core/analytics/utils.py", line 453, in _ping
ping_once(started, server=server)
File "/usr/lib/python3/dist-packages/kolibri/core/analytics/utils.py", line 445, in ping_once
create_and_update_notifications(data, nutrition_endpoints.PINGBACK)
File "/usr/lib/python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
File "/usr/lib/python3/dist-packages/kolibri/core/analytics/utils.py", line 374, in create_and_update_notifications
PingbackNotification.objects.filter(source=source).exclude(
File "/usr/lib/python3/dist-packages/kolibri/core/utils/cache.py", line 70, in __exit__
self.release()
File "/usr/lib/python3/dist-packages/kolibri/core/utils/cache.py", line 64, in release
self._lock.release()
File "/usr/lib/python3/dist-packages/kolibri/dist/redis/lock.py", line 224, in release
raise LockError("Cannot release an unlocked lock")
redis.exceptions.LockError: Cannot release an unlocked lock
With Postgres pristine db and a complete server restart -
$ kolibri manage sync --baseurl <url> --facility <facilityid> --no-push --username <superuser> --password <superuser_password>
WARNING:root:No C Extensions available for this platform.
/usr/lib/python3/dist-packages/kolibri/dist/rest_framework/utils/serializer_helpers.py:107: SyntaxWarning: "is" with a literal. Did you mean "=="?
if value is None or value is '':
INFO Running Kolibri with the following settings: kolibri.deployment.default.settings.base
WARNING Redis is configured without a maximum memory policy. Using Redis with Kolibri, the following is suggested: maxmemory-policy allkeys-lru
WARNING Redis is configured without a maximum memory size.
WARNING Problematic Redis settings detected, please see Redis configuration documentation for details: https://redis.io/topics/config
INFO Invoking command <truncated>
INFO Attempting connections to variations of the URL: http://content.myscoolserver.in
INFO Attempting connection to: http://content.myscoolserver.in/
INFO Success! We connected to: http://content.myscoolserver.in/api/public/info/
INFO Syncing has been initiated (this may take a while)...
INFO Creating pull transfer session
Receiving data (1353/1353, 2.92MB) [###################################################################################################################################################] 100%INFO Receiving data (1353/1353, 2.92MB)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "morango_buffer_transfer_session_id_model_uuid_2a7288db_uniq"
DETAIL: Key (transfer_session_id, model_uuid)=(7aa3fb3e-6a2c-4522-aafc-242fc9d8ff95, 0e2cf944-d328-1e1a-1575-7f845211ade3) already exists.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/bin/kolibri", line 11, in <module>
load_entry_point('kolibri==0.14.3', 'console_scripts', 'kolibri')()
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/kolibri/utils/cli.py", line 277, in invoke
return super(KolibriDjangoCommand, self).invoke(ctx)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/utils/cli.py", line 727, in manage
execute_from_command_line(["kolibri manage"] + ctx.args)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/management/commands/base.py", line 113, in handle
return self.handle_async(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 184, in handle_async
self._handle_pull(
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 269, in _handle_pull
sync_client.run()
File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/syncsession.py", line 692, in run
self._pull_records(callback=status.in_progress.fire)
File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/syncsession.py", line 757, in _pull_records
validate_and_create_buffer_data(
File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/utils.py", line 146, in validate_and_create_buffer_data
Buffer.objects.bulk_create(buffer_list)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 443, in bulk_create
ids = self._batched_insert(objs_without_pk, fields, batch_size)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 1096, in _batched_insert
inserted_id = self._insert(item, fields=fields, using=self.db, return_id=True)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 1079, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/sql/compiler.py", line 1112, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "morango_buffer_transfer_session_id_model_uuid_2a7288db_uniq"
DETAIL: Key (transfer_session_id, model_uuid)=(7aa3fb3e-6a2c-4522-aafc-242fc9d8ff95, 0e2cf944-d328-1e1a-1575-7f845211ade3) already exists.
Every attempt to import a facility from UI, including a complete reinstall of Kolibri and clearing of KOLIBRI_HOME
results in a failure with this in the logs -
INFO 2020-09-02 19:24:45,374 kolibri.core.auth.management.commands.sync Completed pull transfer session
ERROR 2020-09-02 19:24:45,390 kolibri.core.tasks.worker Job b35765430c37409fa745d9b25e6bb778 raised an exception: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/worker.py", line 72, in handle_finished_future
result = future.result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/worker.py", line 217, in wrap
return f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/job.py", line 194, in y
result = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 131, in call_command
return command.execute(*args, **defaults)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/tasks/management/commands/base.py", line 113, in handle
return self.handle_async(*args, **options)
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 184, in handle_async
self._handle_pull(
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 271, in _handle_pull
sync_client.finalize()
File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
next(self.gen)
File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 222, in _lock
yield
File "/usr/lib/python3/dist-packages/kolibri/core/utils/cache.py", line 70, in __exit__
self.release()
File "/usr/lib/python3/dist-packages/kolibri/core/utils/cache.py", line 64, in release
self._lock.release()
File "/usr/lib/python3/dist-packages/kolibri/dist/redis/lock.py", line 222, in release
expected_token = self.local.token
AttributeError: '_thread._local' object has no attribute 'token'
Environment:
Kolibri 0.14.3 deb + Kolibri server 0.3.8~beta2-0ubuntu1 + redis 5.0.7 + Ubuntu 20.04
I don’t even see a pattern apart from that all attempts to import are now failing.
Is there a pattern that I am missing? Not sure if I am missing anything obvious and doing it all wrong.