Subject: bug#33005: 27.0.50; Data loss with Gnus registry

From: Eric Abrahamsen <[email-masked]>
Date: Tue, 26 Nov 2019 10:45:03 -0800

On 11/26/19 17:32 PM, Michael Heerdegen wrote:
> Eric Abrahamsen <[email-masked]> writes:
>
>> Well damn. And we're coming up on Emacs 27.1, too... I've never seen
>> this before -- would you mind sending all your registry-related config
>> (off-list, if necessary), and anything else you might think is relevant,
>> and I'll try to reproduce?
>
> Ok, I debugged it.  FWIW I recently learned that "I'll try to reproduce"
> has a meaning that I didn't expect: you need to say "I'll try to
> reproduce it" or else Stallman might show up and laugh at you (it
> happened to me).

Who knew such dangers lurked on this list?!

> Ok: I have only (gnus-registry-initialize) in my init file.  And this is
> already broken:
>
> "gnus-registry.el" initializes gnus-registry-db like this:
>
>   (defvar gnus-registry-db (gnus-registry-make-db)
>     "The article registry by Message ID.  See `registry-db'.")
>
> and in `gnus-registry-load' the
>
>   (null (eieio-object-p gnus-registry-db))
>
> always fails so unless you call `gnus-registry-load' with the force arg
> you always start with an empty db.

Oh I see, when the file is loaded the variable is already initialized to
an (unloaded) registry object, so it never actually loads/reads its
persistence file.

Except that it certainly seems to! I've never seen this cause a problem,
and no one calls `gnus-registry-load' with the FORCE argument, so if
this was an issue, it seems like it would fail for everyone
immediately...

In fact, I don't know the defvar is initialized to anything at all.
For eieio-persistent objects, you're not supposed to make-instance
yourself, you're supposed to use `eieio-persistent-read' (which is what
loading is supposed to do).

Dunno why it works, though...