zsh-users
 help / color / mirror / code / Atom feed
* The HIST_EXPIRE_DUPS_FIRST might corrupt and wipe partially history file if many shells exit at the same time
@ 2023-03-19 11:56 Piotr Karbowski
  2023-03-19 16:53 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Piotr Karbowski @ 2023-03-19 11:56 UTC (permalink / raw)
  To: zsh-users

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-19 21:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-19 11:56 The HIST_EXPIRE_DUPS_FIRST might corrupt and wipe partially history file if many shells exit at the same time Piotr Karbowski
2023-03-19 16:53 ` Bart Schaefer
2023-03-19 18:38   ` Piotr Karbowski
2023-03-19 21:01     ` Bart Schaefer
2023-03-19 21:17       ` Piotr Karbowski
2023-03-19 21:34         ` Bart Schaefer
2023-03-19 21:53           ` Piotr Karbowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).