[GH-ISSUE #393] Bugfix: ... #260

Closed
opened 2026-03-01 14:41:56 +03:00 by kerem · 3 comments
Owner

Originally created by @jamescochran on GitHub (Jul 29, 2020).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/393

Describe the bug

On a fresh install when I run archivebox init I get the error
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (database is locked)

Steps to reproduce

Setup a new vanilla TurnKey Core VM. Got pip installed and setuputils so I could run pip install archivebox. Then did a archivebox init as my non root user.

Screenshots or log output

File "/usr/local/lib/python3.7/dist-packages/django/db/backends/base/base.py", line 243, in _commit
return self.connection.commit()
django.db.utils.OperationalError: database is locked

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/archivebox", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/archivebox/cli/init.py", line 126, in main
pwd=pwd or OUTPUT_DIR,
File "/usr/local/lib/python3.7/dist-packages/archivebox/cli/init.py", line 62, in run_subcommand
module.main(args=subcommand_args, stdin=stdin, pwd=pwd) # type: ignore
File "/usr/local/lib/python3.7/dist-packages/archivebox/cli/archivebox_init.py", line 35, in main
out_dir=pwd or OUTPUT_DIR,
File "/usr/local/lib/python3.7/dist-packages/archivebox/util.py", line 109, in typechecked_function
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/archivebox/main.py", line 296, in init
for migration_line in apply_migrations(out_dir):
File "/usr/local/lib/python3.7/dist-packages/archivebox/util.py", line 109, in typechecked_function
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/archivebox/index/sql.py", line 81, in apply_migrations
call_command("migrate", interactive=False, stdout=out)
File "/usr/local/lib/python3.7/dist-packages/django/core/management/init.py", line 168, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/core/management/commands/migrate.py", line 233, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.7/dist-packages/django/db/migrations/executor.py", line 91, in migrate
self.recorder.ensure_schema()
File "/usr/local/lib/python3.7/dist-packages/django/db/migrations/recorder.py", line 69, in ensure_schema
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (database is locked)

Software versions

  • OS: Debian Buster
  • ArchiveBox version: Welcome to ArchiveBox v0.4.9!
  • Python version: Python 3.7.3
  • Chrome version: NA
Originally created by @jamescochran on GitHub (Jul 29, 2020). Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/393 #### Describe the bug On a fresh install when I run archivebox init I get the error `django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (database is locked)` #### Steps to reproduce Setup a new vanilla TurnKey Core VM. Got pip installed and setuputils so I could run pip install archivebox. Then did a archivebox init as my non root user. #### Screenshots or log output File "/usr/local/lib/python3.7/dist-packages/django/db/backends/base/base.py", line 243, in _commit return self.connection.commit() django.db.utils.OperationalError: database is locked During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/bin/archivebox", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/archivebox/cli/__init__.py", line 126, in main pwd=pwd or OUTPUT_DIR, File "/usr/local/lib/python3.7/dist-packages/archivebox/cli/__init__.py", line 62, in run_subcommand module.main(args=subcommand_args, stdin=stdin, pwd=pwd) # type: ignore File "/usr/local/lib/python3.7/dist-packages/archivebox/cli/archivebox_init.py", line 35, in main out_dir=pwd or OUTPUT_DIR, File "/usr/local/lib/python3.7/dist-packages/archivebox/util.py", line 109, in typechecked_function return func(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/archivebox/main.py", line 296, in init for migration_line in apply_migrations(out_dir): File "/usr/local/lib/python3.7/dist-packages/archivebox/util.py", line 109, in typechecked_function return func(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/archivebox/index/sql.py", line 81, in apply_migrations call_command("migrate", interactive=False, stdout=out) File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 168, in call_command return command.execute(*args, **defaults) File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 369, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/django/core/management/commands/migrate.py", line 233, in handle fake_initial=fake_initial, File "/usr/local/lib/python3.7/dist-packages/django/db/migrations/executor.py", line 91, in migrate self.recorder.ensure_schema() File "/usr/local/lib/python3.7/dist-packages/django/db/migrations/recorder.py", line 69, in ensure_schema raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc) django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (database is locked) #### Software versions - OS: Debian Buster - ArchiveBox version: Welcome to ArchiveBox v0.4.9! - Python version: Python 3.7.3 - Chrome version: NA
kerem closed this issue 2026-03-01 14:41:56 +03:00
Author
Owner

@jamescochran commented on GitHub (Jul 29, 2020):

It looks like it works fine if I'm in a folder in my home directory. I had mounted a cifs share back to my main server and was running archivebox init there since it has much more space and that's where I want everything stored. Permissions seems fine... I can create files. archivebox init created several files on the share. But I continue to get the database is locked error if I try to run from within a network share.

<!-- gh-comment-id:665389588 --> @jamescochran commented on GitHub (Jul 29, 2020): It looks like it works fine if I'm in a folder in my home directory. I had mounted a cifs share back to my main server and was running archivebox init there since it has much more space and that's where I want everything stored. Permissions seems fine... I can create files. archivebox init created several files on the share. But I continue to get the database is locked error if I try to run from within a network share.
Author
Owner

@jamescochran commented on GitHub (Jul 29, 2020):

I solved this by adding 'nolock' to my line in /etc/fstab

<!-- gh-comment-id:665390309 --> @jamescochran commented on GitHub (Jul 29, 2020): I solved this by adding 'nolock' to my line in /etc/fstab
Author
Owner

@pirate commented on GitHub (Jul 29, 2020):

Yeah ArchiveBox is very strict about locking its indexes on the filesystem before writing to them, we've had bad pexperiences in the past with index corruption due to race conditions between processes.

If you disable filesystem locking I recommend not running more than one aarchivebox process at a time until v0.5 when we remove the json main index in favor of pure sqlite.

<!-- gh-comment-id:665391356 --> @pirate commented on GitHub (Jul 29, 2020): Yeah ArchiveBox is very strict about locking its indexes on the filesystem before writing to them, we've had bad pexperiences in the past with index corruption due to race conditions between processes. If you disable filesystem locking I recommend not running more than one aarchivebox process at a time until v0.5 when we remove the json main index in favor of pure sqlite.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ArchiveBox#260
No description provided.