magit / emacsql

A high-level Emacs Lisp RDBMS front-end
The Unlicense
552 stars 41 forks source link

magit-status initially fails with "process emacsql-sqlite no longer connected to pipe; closed it" #106

Closed hexmode closed 1 year ago

hexmode commented 1 year ago

magit-version: Magit v3.3.0-493-g59833692, Git 2.39.0, Emacs 30.0.50, gnu/linux

I have xhprof as a project so I can load it with C-x p p xhprof RET. When I do that with a newly compiled emacs I see the message: process emacsql-sqlite no longer connected to pipe; closed it

Using M-x toggle-debug-on-error RET and retrying gives me this backtrace:

Debugger entered--Lisp error: (error "Selecting deleted buffer")
  #f(compiled-function (connection) "Return true if the end of the buffer has a properly-formatted prompt." #<bytecode 0x192a892b74129127>)(#<forge-database forge-database-158fe14d54f8>)
  apply(#f(compiled-function (connection) "Return true if the end of the buffer has a properly-formatted prompt." #<bytecode 0x192a892b74129127>) #<forge-database forge-database-158fe14d54f8> nil)
  emacsql-waiting-p(#<forge-database forge-database-158fe14d54f8>)
  #f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode -0x1deef287a2d77172>)(#<forge-database forge-database-158fe14d54f8>)
  apply(#f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode -0x1deef287a2d77172>) #<forge-database forge-database-158fe14d54f8> nil)
  emacsql-wait(#<forge-database forge-database-158fe14d54f8>)
  #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>)(#<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000)
  apply(#f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>) (#<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000))
  (closure ((cl--args #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000) (cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest args) (apply cl--nm (or args cl--args)))(#<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000)
  apply((closure ((cl--args #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000) (cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest args) (apply cl--nm (or args cl--args))) #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000)
  (mapcar #'closql--extern-unbound (apply cl--cnm connection sql (mapcar #'(lambda (arg) (if (stringp arg) (let (...) (set-text-properties 0 ... nil copy) copy) arg)) args)))
  (progn (mapcar #'closql--extern-unbound (apply cl--cnm connection sql (mapcar #'(lambda (arg) (if (stringp arg) (let ... ... copy) arg)) args))))
  (closure ((cl--cnm closure ((cl--args #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000) (cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest args) (apply cl--nm (or args cl--args)))) (cl--cnm connection sql &rest args) (progn (mapcar #'closql--extern-unbound (apply cl--cnm connection sql (mapcar #'(lambda ... ...) args)))))((closure ((cl--args #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000) (cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest args) (apply cl--nm (or args cl--args))) #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000)
  apply((closure ((cl--cnm closure ((cl--args #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000) (cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest args) (apply cl--nm (or args cl--args)))) (cl--cnm connection sql &rest args) (progn (mapcar #'closql--extern-unbound (apply cl--cnm connection sql (mapcar #'(lambda ... ...) args))))) (closure ((cl--args #<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000) (cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest args) (apply cl--nm (or args cl--args))) (#<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000))
  (let ((cl--cnm #'(lambda (&rest args) (apply cl--nm (or args cl--args))))) (apply #'(lambda (cl--cnm connection sql &rest args) (progn (mapcar #'closql--extern-unbound (apply cl--cnm connection sql (mapcar ... args))))) cl--cnm cl--args))
  (closure ((cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest cl--args) "\n\n(fn CONNECTION SQL &rest ARGS)" (let ((cl--cnm #'(lambda (&rest args) (apply cl--nm ...)))) (apply #'(lambda (cl--cnm connection sql &rest args) (progn (mapcar ... ...))) cl--cnm cl--args)))(#<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000)
  apply((closure ((cl--nm . #f(compiled-function (connection sql &rest args) #<bytecode -0x98fcdf6beddeea4>))) (&rest cl--args) "\n\n(fn CONNECTION SQL &rest ARGS)" (let ((cl--cnm #'(lambda (&rest args) (apply cl--nm ...)))) (apply #'(lambda (cl--cnm connection sql &rest args) (progn (mapcar ... ...))) cl--cnm cl--args))) #<forge-database forge-database-158fe14d54f8> ([:pragma (= busy-timeout $s1)] 15000))
  emacsql(#<forge-database forge-database-158fe14d54f8> [:pragma (= busy-timeout $s1)] 15000)
  #f(compiled-function (connection &rest rest) #<bytecode -0xf47d4b519101ea9>)(#<forge-database forge-database-158fe14d54f8> (:file "/home/mah/.emacs.d/forge-database.sqlite"))
  apply(#f(compiled-function (connection &rest rest) #<bytecode -0xf47d4b519101ea9>) (#<forge-database forge-database-158fe14d54f8> (:file "/home/mah/.emacs.d/forge-database.sqlite")))
  #f(compiled-function (&rest args) #<bytecode 0x1d0de56ae1ef1f61>)(#<forge-database forge-database-158fe14d54f8> (:file "/home/mah/.emacs.d/forge-database.sqlite"))
  apply(#f(compiled-function (&rest args) #<bytecode 0x1d0de56ae1ef1f61>) #<forge-database forge-database-158fe14d54f8> (:file "/home/mah/.emacs.d/forge-database.sqlite"))
  initialize-instance(#<forge-database forge-database-158fe14d54f8> (:file "/home/mah/.emacs.d/forge-database.sqlite"))
  #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 0x10b66ca98f305fde>)(forge-database :file "/home/mah/.emacs.d/forge-database.sqlite")
  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 0x10b66ca98f305fde>) forge-database (:file "/home/mah/.emacs.d/forge-database.sqlite"))
  make-instance(forge-database :file "/home/mah/.emacs.d/forge-database.sqlite")
  (let ((db-init (not (and file (file-exists-p file)))) (db (make-instance class :file file))) (if (and (slot-boundp db 'process) (processp (eieio-oref db 'process))) (progn (set-process-query-on-exit-flag (eieio-oref db 'process) nil))) (if debug (progn (emacsql-enable-debugging db))) (emacsql db [:pragma (= foreign-keys on)]) (if db-init (progn (closql--db-init db))) (if variable (progn (set variable db))) db)
  (or (let ((db (and variable (symbol-value variable)))) (and db (emacsql-live-p db) (prog1 db (emacsql db [:pragma (= foreign-keys on)])))) (let ((db-init (not (and file (file-exists-p file)))) (db (make-instance class :file file))) (if (and (slot-boundp db 'process) (processp (eieio-oref db 'process))) (progn (set-process-query-on-exit-flag (eieio-oref db 'process) nil))) (if debug (progn (emacsql-enable-debugging db))) (emacsql db [:pragma (= foreign-keys on)]) (if db-init (progn (closql--db-init db))) (if variable (progn (set variable db))) db))
  (progn (or (let ((db (and variable (symbol-value variable)))) (and db (emacsql-live-p db) (prog1 db (emacsql db [:pragma (= foreign-keys on)])))) (let ((db-init (not (and file (file-exists-p file)))) (db (make-instance class :file file))) (if (and (slot-boundp db 'process) (processp (eieio-oref db 'process))) (progn (set-process-query-on-exit-flag (eieio-oref db 'process) nil))) (if debug (progn (emacsql-enable-debugging db))) (emacsql db [:pragma (= foreign-keys on)]) (if db-init (progn (closql--db-init db))) (if variable (progn (set variable db))) db)))
  (closure (t) (class &optional variable file debug) (progn (or (let ((db (and variable ...))) (and db (emacsql-live-p db) (prog1 db (emacsql db ...)))) (let ((db-init (not ...)) (db (make-instance class :file file))) (if (and (slot-boundp db ...) (processp ...)) (progn (set-process-query-on-exit-flag ... nil))) (if debug (progn (emacsql-enable-debugging db))) (emacsql db [:pragma (= foreign-keys on)]) (if db-init (progn (closql--db-init db))) (if variable (progn (set variable db))) db))))(forge-database forge--db-connection "/home/mah/.emacs.d/forge-database.sqlite" t)
  apply((closure (t) (class &optional variable file debug) (progn (or (let ((db (and variable ...))) (and db (emacsql-live-p db) (prog1 db (emacsql db ...)))) (let ((db-init (not ...)) (db (make-instance class :file file))) (if (and (slot-boundp db ...) (processp ...)) (progn (set-process-query-on-exit-flag ... nil))) (if debug (progn (emacsql-enable-debugging db))) (emacsql db [:pragma (= foreign-keys on)]) (if db-init (progn (closql--db-init db))) (if variable (progn (set variable db))) db)))) forge-database (forge--db-connection "/home/mah/.emacs.d/forge-database.sqlite" t))
  closql-db(forge-database forge--db-connection "/home/mah/.emacs.d/forge-database.sqlite" t)
  forge-db()
  forge-sql([:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "phacility" "xhprof")
  #f(compiled-function (&rest rest) "((host owner name) &optional remote demand)\n\nReturn the repository identified by HOST, OWNER and NAME." #<bytecode 0x1812831423bdd40d>)(("github.com" "phacility" "xhprof") "upstream" full)
  apply(#f(compiled-function (&rest rest) "((host owner name) &optional remote demand)\n\nReturn the repository identified by HOST, OWNER and NAME." #<bytecode 0x1812831423bdd40d>) ("github.com" "phacility" "xhprof") ("upstream" full))
  forge-get-repository(("github.com" "phacility" "xhprof") "upstream" full)
  #f(compiled-function (url &optional remote demand) "Return the repository at URL." #<bytecode -0x1471994b134c701e>)("https://github.com/phacility/xhprof.git" "upstream" full)
  apply(#f(compiled-function (url &optional remote demand) "Return the repository at URL." #<bytecode -0x1471994b134c701e>) "https://github.com/phacility/xhprof.git" ("upstream" full))
  forge-get-repository("https://github.com/phacility/xhprof.git" "upstream" full)
  #f(compiled-function (demand &optional remote) "Return the current forge repository.\n\nIf the `forge-buffer-repository' is non-nil, then return that.\nOtherwise if `forge-buffer-topic' is non-nil, then return the\nrepository for that.  Finally if both variables are nil, then\nreturn the forge repository corresponding to the current Git\nrepository, if any." #<bytecode 0x816804696273260>)(full)
  apply(#f(compiled-function (demand &optional remote) "Return the current forge repository.\n\nIf the `forge-buffer-repository' is non-nil, then return that.\nOtherwise if `forge-buffer-topic' is non-nil, then return the\nrepository for that.  Finally if both variables are nil, then\nreturn the forge repository corresponding to the current Git\nrepository, if any." #<bytecode 0x816804696273260>) full nil)
  forge-get-repository(full)
  forge-bug-reference-setup()
  run-hooks(change-major-mode-after-body-hook special-mode-hook magit-section-mode-hook magit-mode-hook magit-status-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook special-mode-hook magit-section-mode-hook magit-mode-hook magit-status-mode-hook))
  run-mode-hooks(magit-status-mode-hook)
  magit-status-mode()
  magit-setup-buffer-internal(magit-status-mode nil ((magit-buffer-diff-args ("--no-ext-diff")) (magit-buffer-diff-files nil) (magit-buffer-log-args ("-n256" "--decorate")) (magit-buffer-log-files nil)))
  magit-status-setup-buffer("/home/mah/work/code/xhprof/")
  vc-dir("~/work/code/xhprof/")
  project-vc-dir()
  funcall-interactively(project-vc-dir)
  project-switch-project("~/work/code/xhprof/")
  funcall-interactively(project-switch-project "~/work/code/xhprof/")
  command-execute(project-switch-project)

I reported this yesterday as a comment with a minimal init.el that can reproduce this but decided it should really be its own bug since @tarsius comment with code modifications don't work for me.

VitalyAnkh commented 1 year ago

I have a similar problem with emacsql (with org-roam) on emacs 30.0.50 built on master branch: any operations involving emacsql failed with "Process emacsql-sqlite not running: finished":

;; in the *Message* buffer
Initializing org-roam database...
Process emacsql-sqlite not running: finished

Process emacsql-sqlite not running: finished

Process emacsql-sqlite not running: finished

Process emacsql-sqlite not running: finished

Login...done
Process emacsql-sqlite not running: finished

Process emacsql-sqlite not running: finished

It seems that emacsql doesn't work well with the most recent master branch emacs. We should bisect which upstream change caused this then fix this.

My emacs version:

GNU Emacs 30.0.50
Development version 70477be3e38d on master branch; build date 2023-01-16.

emacsql version in use:

commit 6b2e65bdf785364cf7c34c31fea5812e1e58c657 (HEAD -> main, replaced, origin/master, origin/main, master)
Author: Jonas Bernoulli <jonas@bernoul.li>
Date:   Sun Nov 27 22:46:37 2022 +0100

    Use new version string format for unreleased revisions

    "N-git" < "N"; but "N.50-git" > "N".
geza-herman commented 1 year ago

I think this emacs commit caused this: https://git.savannah.gnu.org/cgit/emacs.git/commit/src/coding.c?h=bb679244152dddd9949ca065aa6617457f7a7144&id=cfd2b3504ab5de6eb5f3c7a0784cb447883e1326

tsdh commented 1 year ago

Bug report on the emacs side: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60872

tarsius commented 1 year ago

Fixed. Also see https://github.com/magit/forge/issues/535#issuecomment-1387734805.