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

disk I/O error #152

Closed
walseb opened this issue Jul 21, 2024 · 4 comments
Closed

disk I/O error #152

walseb opened this issue Jul 21, 2024 · 4 comments

Comments

@walseb
Copy link

walseb commented Jul 21, 2024

Hello!

After I install this library on my Nixos laptop and run ekg-capture, I get an IO error.

Upon investigation, the error is with the ekg-add-schema function. When I run it, emacs gives with the following error:

Debugger entered--Lisp error: (sqlite-error "disk I/O error")
  sqlite-execute(#<sqlite db=0x47193388 name=/home/admin/.emacs.d/triples-4.db> "REPLACE INTO triples VALUES (?, ?, ?, ?)" ("text/mode" "base/unique" "t" "()"))
  triples-db-insert(#<sqlite db=0x47193388 name=/home/admin/.emacs.d/triples-4.db> text/mode base/unique t)
  apply(triples-db-insert #<sqlite db=0x47193388 name=/home/admin/.emacs.d/triples-4.db> (text/mode base/unique t))
  #f(compiled-function (triple) #<bytecode 0x1d7438b6fd243890>)((text/mode base/unique t))
  mapc(#f(compiled-function (triple) #<bytecode 0x1d7438b6fd243890>) ((text base/type schema) (text schema/property text) (text/text base/unique t) (text/text base/type string) (text schema/property mode) (text/mode base/unique t) (text/mode base/type symbol) (text schema/property inlines) (text/inlines base/virtual-reversed inline/for-text)))
  triples--add(#<sqlite db=0x47193388 name=/home/admin/.emacs.d/triples-4.db> (replace-subject-type (text base/type schema) (text schema/property text) (text/text base/unique t) (text/text base/type string) (text schema/property mode) (text/mode base/unique t) (text/mode base/type symbol) (text schema/property inlines) (text/inlines base/virtual-reversed inline/for-text)))
  triples-add-schema(#<sqlite db=0x47193388 name=/home/admin/.emacs.d/triples-4.db> text (text :base/unique t :base/type string) (mode :base/unique t :base/type symbol) (inlines :base/virtual-reversed inline/for-text))
  ekg-add-schema()
  eval((ekg-add-schema) nil)
  elisp--eval-last-sexp(nil)
  #f(compiled-function () #<bytecode 0x184a83b9b632a>)()
  eval-last-sexp(nil)

When entering the function and executing each step manually, the call to

(triples-add-schema ekg-db 'tagged '(tag :base/type string))

suceeds always unless I execute it too quickly. When it fails, it fails with the IO error above. Running the more complex calls to triples-add-schema fails more reliably.

Running it twice in a row makes it almost always fail:

(progn
(triples-add-schema ekg-db 'tagged '(tag :base/type string))
(triples-add-schema ekg-db 'tagged '(tag :base/type string)))

Running the function triples calls under the hood many times also causes the same IO error consistently:

(progn
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
  (sqlite-execute ekg-db "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()")))

I haven't done much work with Sqlite in the past. Have you encountered something like this before in regard to the emacs sqlite library? Do you know what the issue could be?

I tried running hundereds of SQL write commands from the console as fast as possible and got no error.

Is there a way to make this library use the CLI version?

I have tried this in both Emacs 30 and Emacs 29.3 with the same results.

Thanks for any help!

@walseb
Copy link
Author

walseb commented Jul 21, 2024

I get the same error when running
emacs -Q -l /home/admin/nixos/deps/emacs/sql-test.el
where the contents of that file is:

(let ((con (sqlite-open "/home/admin/nixos/deps/emacs/triples.db")))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))
    (sqlite-execute con "REPLACE INTO triples VALUES (?, ?, ?, ?)" '("text/mode" "base/unique" "t" "()"))))

Probably it's a bug relating to emac's implementation of sqlite.

@ahyatt
Copy link
Owner

ahyatt commented Jul 21, 2024

Thanks for the investigation! You should probably open an emacs bug (M-x report-emacs-bug) with a small test-case that you can verify in a plain emacs (emacs -Q).

For using ekg if sqlite-execute doesn't work, you can try using emacsql. Install the emacs package separately, and then (setq triples-sqlite-interface 'emacsql). This should work for you, let me know if you have issues.

@walseb
Copy link
Author

walseb commented Jul 21, 2024

Yes although my issue probably doesn't happen on anyone else's machine because it affects all complex or rapid calls to sqlite. I think this is related to my system configuration. I will try to test this issue on my other machines to see which parts of my configuration might be causing the issue.

Thanks so much for the tip! When using emacsql it works fine, although I'm getting an error after saving changes to an imported org-roam note. I will look into it more later.

I'm wondering, is there a simple way to interactively search across all note contents with a live preview of results? Like grep with consult? I didn't find any functions for that, and it was useful in org-roam when quickly searching for some note I remembered a part of that wasn't the tag.

Thanks so much for this package and the help!

@walseb walseb closed this as completed Jul 21, 2024
@ahyatt
Copy link
Owner

ahyatt commented Jul 22, 2024

We don't have the kind of search you are thinking of, although it'd be a good idea to add. What we do have is, llm-embedding, where you can do a semantic search after you hook up your notes to a provider of embeddings (Open AI, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants