emacsql icon indicating copy to clipboard operation
emacsql copied to clipboard

emacsql-sqlite failing (timeout, still running) on OS X (Big Sur)

Open adamConnerSax opened this issue 3 years ago • 14 comments

I was trying to switch to a new version of emacs which caused "straight" to rebuild everything and since then whenever I try to open a file (any file, I think?) emacs hangs, eventually a 'Query timeout error: "Query timed out", 30' appears and then I have a running "emacsql-sqlite" process running, using one entire core. If I open another file, it'll happen again and I'll then have another process running, using a full core.

I tried reverting the sqlite package back a couple versions (in case something that had happened since the last time I asked straight to update packages) and the problem remains.

I'd be happy to help debug but I have no idea--after much trying!--to get more information on what is happening.

adamConnerSax avatar Apr 27 '22 14:04 adamConnerSax

I have the same issue, but on macOS Monterey. My trigger appears to have been upgrading to Emacs 28.

Here's a stack trace from calling (debug (org-roam-db-sync)):

Debugger entered--Lisp error: (emacsql-timeout "Query timed out" 30)
  signal(emacsql-timeout ("Query timed out" 30))
  #f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode 0x30bbf493e45af39>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76>)
  apply(#f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode 0x30bbf493e45af39>) #<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> nil)
  emacsql-wait(#<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76>)
  #f(compiled-function (connection sql &rest args) "Send SQL s-expression to CONNECTION and return the results." #<bytecode 0x7adfae282d8d4af>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> [:pragma (= busy-timeout $s1)] 15000)
  apply(#f(compiled-function (connection sql &rest args) "Send SQL s-expression to CONNECTION and return the results." #<bytecode 0x7adfae282d8d4af>) #<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> ([:pragma (= busy-timeout $s1)] 15000))
  emacsql(#<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> [:pragma (= busy-timeout $s1)] 15000)
  #f(compiled-function (#<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> (:file "~/.config/emacs/org-roam.db"))
  apply(#f(compiled-function 
  #f(compiled-function (&rest args) #<bytecode 0x24e89310fe154b8>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> (:file "~/.config/emacs/org-roam.db"))
  apply(#f(compiled-function (&rest args) #<bytecode 0x24e89310fe154b8>) #<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> (:file "~/.config/emacs/org-roam.db"))
  initialize-instance(#<emacsql-sqlite-connection emacsql-sqlite-connection-1fe524df3b76> (:file "~/.config/emacs/org-roam.db"))
  #f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode -0x10007b56552b4f0c>)(emacsql-sqlite-connection :file "~/.config/emacs/org-roam.db")
  apply(#f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode -0x10007b56552b4f0c>) emacsql-sqlite-connection (:file "~/.config/emacs/org-roam.db"))
  make-instance(emacsql-sqlite-connection :file "~/.config/emacs/org-roam.db")
  emacsql-sqlite("~/.config/emacs/org-roam.db")
  org-roam-db()
  org-roam-db-sync()
  (debug (org-roam-db-sync))
  eval((debug (org-roam-db-sync)) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

stig avatar May 02 '22 22:05 stig

False alarm for me, I think. It turns out a lot of things didn't work, as exec-path had not been set correctly and Emacs couldn't find any binaries. Fixing that looks promising. (Emacs is now compiling SQLite...)

stig avatar May 02 '22 23:05 stig

Let me know how that works out! I ended up removing forge, which I hadn't really been using anyway, and now everything works. But that's not a solution for anyone else...

adamConnerSax avatar May 03 '22 00:05 adamConnerSax

It worked great :-)

stig avatar May 04 '22 13:05 stig

@stig Can you elaborate on how you've set exec-path to make it work? I'm also experiencing this issue. Thanks.

benthamite avatar May 26 '22 15:05 benthamite

@benthamite I used the exec-path-from-shell package

stig avatar May 26 '22 16:05 stig

Thanks, yes, that's what I use. I was wondering if there was a particular environmental variable you had to change to make it work.

benthamite avatar May 26 '22 16:05 benthamite

FWIW, disabling forge (following @adamConnerSax's suggestion) solved some of the issues I was experiencing, but not others. I'm finding it pretty hard to diagnose the underlying problem.

benthamite avatar May 26 '22 16:05 benthamite

I think my problem was related to an Emacs 28 upgrade. I think there were incompatibilities with the old .elc files, so I blew away everything and let straight re-download. Except, it failed to download / build everything, including exec-path-from-shell, so I had to help it along a bit. (I can't remember how, exactly. Possibly all I did was start Emacs a few more times, and it got a bit further each time.)

stig avatar May 27 '22 09:05 stig

I had the same problem after upgrading to 28. I had to clear out the build files for emacsql-sqlite in order to get it to rebuild it (I am using straight, so the build files were located at .emacs.d/straight/build/emacsql-sqlite). This might be helpful to @benthamite

CeleritasCelery avatar Jun 15 '22 19:06 CeleritasCelery

I meet the same problem on Version 27.2 (9.0) after I delete folder /Users/abc/.emacs.d/elpa/ to refresh all package

  1. at begining there was one emacsql-sqlite process

  2. after I got the error "Error (use-package): org-roam/:config: Query timeout error: "Query timed out", 30 " I got 2 process running, is this normal? ps -ef | grep sql 502 8678 8632 0 7:48下午 ?? 1:16.69 /Users/abc/.emacs.d/elpa/emacsql-sqlite-3.0.0/sqlite/emacsql-sqlite /Users/abc/.emacs.d/org-roam.db 502 8759 8632 0 7:49下午 ?? 0:46.94 /Users/abc/.emacs.d/elpa/emacsql-sqlite-3.0.0/sqlite/emacsql-sqlite /Users/abc/.emacs.d/org-roam.db

  3. I run org-roam-db-sync again, there will be a third emacsql-sqlite process created.

  4. Currently I have to swith to another db tpye to solve the problem (use-package emacsql-sqlite3) (setq org-roam-database-connector 'sqlite3)

webloginwu avatar Jun 22 '22 11:06 webloginwu

I'm having the same problem; had to turn off forge to fix it, just rebuilding sqlite package did nothing.

mtravers avatar Jul 12 '22 22:07 mtravers

I've got a new M1 Macbook Pro for work, and this problem has re-surfaced for me. I've not been able to fix it after several hours today.

stig avatar Aug 12 '22 21:08 stig

Actually, @webloginwu 's solution (switching to the sqlite3 connector) works for me too.

stig avatar Aug 12 '22 21:08 stig

I've just released v4.0.0. This includes new, more reliable sqlite back-ends. This older sqlite back-end is still included in this release, but will be removed in the future. I don't intend to fix any issues of this back-end on its way out.

tarsius avatar Aug 09 '24 20:08 tarsius