Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: Losing .zsh_history
On Thu, Oct 06, 2022 at 10:40:04AM +0100, Peter Stephenson wrote:
> Deliberately deleting the previous history in this thread (tee hee)
> because I want to get a higher level picture...
>
> We seem to be homing in on cases where the shell is involved in
> misbehaviour but doesn't get enough information or warning that
> something's up that it can do anything about it. Is that fair, or is
> there some aspect that might give it a head's up that writing history
> could be dangerous?
With the discussion and the available my hypothesis of whats
happening:
On an unjournaled ext4 (on an SSD; with "discard" option)
1) System starts shutdown
2) Shell is told to terminate.
3) Shell writes new history into separate file.
This is cached by the disk, the disk drivers or the fs layer.
4) Shell moves new history over old one.
This is cached by the disk, the disk drivers or the fs layer.
5) Because the filesystem is not journaled, the changes from
the previous step are written to disk in random order.
6) Power loss occurs while the new directory entries have already
been written to disk, but the new file contents have not.
(The box is attached to a switchable multi socket adapter.)
This wouldn't be the fault of the shell. Still, why did this
happen to the history files twice, but not to the browser config
files which are also written at shutdown? Is there anything the
shell could do to prevent this or make it less likely? More
fsync()s?
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
Messages sorted by:
Reverse Date,
Date,
Thread,
Author