From: Ihor Radchenko <yantar92@posteo.net>
To: Paul Stansell <paulstansell@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] "Invalid search bound (wrong side of point)" [9.8-pre (release_9.7.16-169-ge87ecf @ ~/.emacs.d/org-mode-git/lisp/)]
Date: Tue, 24 Dec 2024 09:00:50 +0000 [thread overview]
Message-ID: <87wmfpihfh.fsf@localhost> (raw)
In-Reply-To: <CAMJKaZwexwPj5PJmwx5kqexV6_Z5LjstJMm0=NKA7UUZ5gVw5w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1192 bytes --]
Paul Stansell <paulstansell@gmail.com> writes:
>>
>> May it be that you often have multiple Emacs processes running
>> simultaneously and killed by signal?
>
> I do typically have multiple Emacs processes running simultaneously, but
> I'm not aware that I kill Emacs processes, I either quit Emacs with C-x
> C-c, or I click on the "X" in the top right of the window. Could the
> latter be sending a kill signal?
No idea :)
In any case, your errors look like some kind of mixed state from
multiple Emacs sessions writing to the same cache file.
May you try the attached patch?
> ... By the way, I've exited Emacs by clicking
> the "X" for years, but I've only recently noticed the warnings. Also, if I
> switch to using the version of Org Mode that comes with the distribution
> (Kubuntu 22.04), instead of using the recent one from a git clone, I don't
> think I get the warmings.
That's because disk cache has been introduced in the recent Org mode
versions.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-persist-Fix-mixing-cace-data-from-multiple-Emacs.patch --]
[-- Type: text/x-patch, Size: 4255 bytes --]
From 15b8681c0c8db555b20d70b2a47cef996ff1cebf Mon Sep 17 00:00:00 2001
Message-ID: <15b8681c0c8db555b20d70b2a47cef996ff1cebf.1735030672.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Tue, 24 Dec 2024 09:45:42 +0100
Subject: [PATCH] org-persist: Fix mixing cace data from multiple Emacs
processes
* lisp/org-persist.el (org-persist--write-elisp-file): When there is a
clash with other Emacs process while writing cache data, discard the
cache to avoid any problem.
(org-persist-write): Return nil when any kind of error occurs when
writing.
(org-persist--refresh-gc-lock):
(org-persist--gc-orphan-p): Bail out when writing fails.
Reported-by: Paul Stansell <paulstansell@gmail.com>
Link: https://orgmode.org/list/YT3PR01MB95943D4DB2E659091A2BDE8DBE2E2@YT3PR01MB9594.CANPRD01.PROD.OUTLOOK.COM
---
lisp/org-persist.el | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 886d227c0a..788714fb15 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -478,11 +478,12 @@ (defun org-persist--write-elisp-file (file data &optional no-circular pp)
(start-time (float-time)))
(unless (file-exists-p (file-name-directory file))
(make-directory (file-name-directory file) t))
- ;; Force writing even when the file happens to be opened by
- ;; another Emacs process.
+ ;; Discard cache when there is a clash with other Emacs process.
+ ;; This way, we make sure that cache is never mixing data & record
+ ;; from different processes.
(cl-letf (((symbol-function #'ask-user-about-lock)
- ;; FIXME: Emacs 27 does not yet have `always'.
- (lambda (&rest _) t)))
+ (lambda (&rest _)
+ (error "Other Emacs process is writing to cache"))))
(with-temp-file file
(insert ";; -*- mode: lisp-data; -*-\n")
(if pp
@@ -1120,12 +1121,13 @@ (defun org-persist-write (container &optional associated ignore-return)
(seq-find (lambda (v)
(run-hook-with-args-until-success 'org-persist-before-write-hook v associated))
(plist-get collection :container)))
- (when (or (file-exists-p org-persist-directory) (org-persist--save-index))
- (let ((file (org-file-name-concat org-persist-directory (plist-get collection :persist-file)))
- (data (mapcar (lambda (c) (cons c (org-persist-write:generic c collection)))
- (plist-get collection :container))))
- (org-persist--write-elisp-file file data)
- (or ignore-return (org-persist-read container associated)))))))
+ (ignore-errors
+ (when (or (file-exists-p org-persist-directory) (org-persist--save-index))
+ (let ((file (org-file-name-concat org-persist-directory (plist-get collection :persist-file)))
+ (data (mapcar (lambda (c) (cons c (org-persist-write:generic c collection)))
+ (plist-get collection :container))))
+ (org-persist--write-elisp-file file data)
+ (or ignore-return (org-persist-read container associated))))))))
(defun org-persist-write-all (&optional associated)
"Save all the persistent data.
@@ -1226,7 +1228,7 @@ (defun org-persist--refresh-gc-lock ()
(when (< (- (float-time (cdr record)) (float-time (current-time)))
org-persist-gc-lock-expiry)
(push record new-alist)))
- (org-persist--write-elisp-file file new-alist)))
+ (ignore-errors (org-persist--write-elisp-file file new-alist))))
(defun org-persist--gc-orphan-p ()
"Return non-nil, when orphan files should be garbage-collected.
@@ -1234,7 +1236,7 @@ (defun org-persist--gc-orphan-p ()
(let* ((file (org-file-name-concat org-persist-directory org-persist-gc-lock-file))
(alist (when (file-exists-p file) (org-persist--read-elisp-file file))))
(setq alist (org-assoc-delete-all before-init-time alist))
- (org-persist--write-elisp-file file alist)
+ (ignore-errors (org-persist--write-elisp-file file alist))
;; Only GC orphan files when there are no active sessions.
(not alist)))
--
2.47.1
prev parent reply other threads:[~2024-12-24 9:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 21:30 [BUG] "Invalid search bound (wrong side of point)" [9.8-pre (release_9.7.16-169-ge87ecf @ ~/.emacs.d/org-mode-git/lisp/)] Paul Stansell
2024-12-23 17:16 ` Ihor Radchenko
2024-12-23 18:02 ` Paul Stansell
2024-12-23 18:08 ` Ihor Radchenko
2024-12-23 23:33 ` Paul Stansell
2024-12-24 9:00 ` Ihor Radchenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wmfpihfh.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=paulstansell@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).