Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

The HIST_EXPIRE_DUPS_FIRST might corrupt and wipe partially history file if many shells exit at the same time



Hi,

Recently I went ahead and enabled HIST_EXPIRE_DUPS_FIRST on my systems
in order to get the most out of zsh_history. It worked great however I
on two separated ocasions had a large chunk of my history file being
lost. I narrowed it down to HIST_EXPIRE_DUPS_FIRST

They way I can reproduce it sometimes is if multiple zsh shells exit at
the very same time. It happens when I terminate tmux session that have
10+ zsh instances,or when I just reboot my system while I have dozens of
urxvt instances open. This leads to all of the zsh instances to exit and
do it's magic. This however happens only if I intentionally litter my
.zsh_history to make the zsh actually want to run this logic. meaning
the steps to reproduce would be:

- Exit multiple zsh instances at the very same time.
- Have .zsh_history big enough (HISTSIZE, SAVEHIST) so it trigger this
logic.

I had it happen to me (outside of trying to reproduce it) twice, on one
system as root, on another as non-root user.

Before I reported it I checked all the other things that could lead to
this corruption, and I found a single user reporting the very same
problem year and half ago on stackoverflow[1], he does indeed have
histexpiredupsfirst enabled.

The relevant configuration change that I did to enable this (among few
other)

      HISTSIZE='128000'
     -SAVEHIST='128000'
     +SAVEHIST='96000'
     +setopt hist_expire_dups_first
      setopt hist_ignore_dups
     +setopt hist_ignore_all_dups
     +setopt hist_find_no_dups
     +setopt hist_save_no_dups

I have disabled this feature since due those corruptions. Would love to
get back to it though, perhaps adding some locking mechanism would help
here?

[1]
https://stackoverflow.com/questions/69434630/closing-multiple-iterm2-tabs-makes-zsh-history-lose-most-of-the-history

-- Piotr.





Messages sorted by: Reverse Date, Date, Thread, Author