Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: sqlite database corruption on network filesystem AFS #2356

Open
1 task done
budde25 opened this issue Aug 8, 2024 · 1 comment
Open
1 task done

[Bug]: sqlite database corruption on network filesystem AFS #2356

budde25 opened this issue Aug 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@budde25
Copy link

budde25 commented Aug 8, 2024

What did you expect to happen?

The database would remain in a working state on the network filesystem AFS.

What happened?

Pretty regularly the database would get corrupt causing atuin to panic when retrieving history (up arrow).
(I don't have an example anymore since I have been using a patched version (a fork) that fixes the issue for a while)

After taking a look on the sqlite docs it looks like this can be mitigated by using a rollback mode (recommendation 3). https://www.sqlite.org/useovernet.html. These include "DELETE", "PERSIST", or "TRUNCATE".

I tried changing the database files from WAL (write-ahead log) to DELETE however the the default behavior of atuin is to overwrite this and change it back to WAL on access.

.journal_mode(SqliteJournalMode::Wal)

.journal_mode(SqliteJournalMode::Wal)

I tested removing these two lines in a fork that I compiled and manually changed the database files to DELETE and they have been corruption free for a couple weeks so I am fairly confident that did indeed fix my issues.
https://github.com/budde25/atuin

It would be great if the database files were not forced onto WAL so that manually changing them would keep them working on AFS or adding an option to the config such as "Network Filesystem Support" that would default them to a rollback mode instead of WAL on access.

Atuin doctor output

{
  "atuin": {
    "version": "18.3.0",
    "sync": null,
    "sqlite_version": "3.44.0"
  },
  "shell": {
    "name": "fish",
    "default": "bash",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Red Hat Enterprise Linux",
    "arch": "x86_64",
    "version": "8.8",
    "disks": [
      {
        "name": "/dev/mapper/rootvg-root",
        "filesystem": "xfs"
      },
      {
        "name": "/dev/mapper/rootvg-tmp",
        "filesystem": "xfs"
      },
      {
        "name": "/dev/sda2",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/mapper/rootvg-usr_vice_cache",
        "filesystem": "xfs"
      },
      {
        "name": "/dev/sda1",
        "filesystem": "vfat"
      },
      {
        "name": "AFS",
        "filesystem": "afs"
      }
    ]
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@budde25 budde25 added the bug Something isn't working label Aug 8, 2024
@budde25
Copy link
Author

budde25 commented Aug 8, 2024

I would be happy to make a patch to remove the forced change to the mode to WAL on database access (while still creating in WAL mode if file doesn't exist).
That would require minimal changes to any code and allow me to mitigate by just manually changing my database files after atuin's initial creation.

If that sounds like a reasonable fix 😄 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant