Subject: bug#75209: 30.0.93; Emacs reader failed to read data in "/home/nlj/.cache/org-persist/gc-lock.eld"

From: "N. Jackson" <[email-masked]>
Date: Sat, 15 Mar 2025 17:38:24 +0000

At 16:05 +0000 on Saturday 2025-03-15, Ihor Radchenko wrote:
>
> The attached diff does it. Need to test.
>
> diff --git a/lisp/org-persist.el b/lisp/org-persist.el
> index a639699d93..c0a0dd53d6 100644
> --- a/lisp/org-persist.el
> +++ b/lisp/org-persist.el
> @@ -474,7 +474,7 @@ (defun org-persist--write-elisp-file
>    ;;
>    ;; To read more about this, see the comments in Emacs's fileio.c, in
>    ;; particular the large comment block in init_fileio.
> -  (let ((write-region-inhibit-fsync t)
> +  (let ((write-region-inhibit-fsync nil)
>          ;; We set UTF-8 here and in `org-persist--read-elisp-file'
>          ;; to avoid the overhead from `find-auto-coding'.
>          (coding-system-for-write 'emacs-internal)

I will test this diff and report back.

By the way, the previous diff (for the atomic write juggle for
Windows systems) results in errors like these:

Error running timer `org-persist--refresh-gc-lock': (file-already-exists "File already exists" "/tmp/org-persist-1p8805")
Error running timer `org-persist--refresh-gc-lock': (file-already-exists "File already exists" "/tmp/org-persist-CkTLDc")
Error running timer `org-persist--refresh-gc-lock': (file-already-exists "File already exists" "/tmp/org-persist-K9qMAt")
Error running timer `org-persist--refresh-gc-lock': (file-already-exists "File already exists" "/tmp/org-persist-ho8aMe")
Error running timer `org-persist--refresh-gc-lock': (file-already-exists "File already exists" "/tmp/org-persist-2Kz2sK")

I think you need the 'overwrite flag in the call to rename-file.
I.e.:

      (let ((tmp-file-2 (make-temp-file "org-persist-")))
        ;; Just renaming may still not be atomic on Windows, so we do
        ;; a bit more complex juggle.
        (rename-file file tmp-file-2 'overwrite)
        (rename-file tmp-file file 'overwrite)
        (delete-file tmp-file-2)))