zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <dominik.vogt@gmx.de>
To: zsh-users@zsh.org
Subject: Re: Bug: Losing .zsh_history
Date: Thu, 6 Oct 2022 11:52:45 +0100	[thread overview]
Message-ID: <Yz6zfTHGw4mdiGRP@localhost> (raw)
In-Reply-To: <1099768997.2262545.1665049204679@mail.virginmedia.com>

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


  reply	other threads:[~2022-10-06 10:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 19:55 Dominik Vogt
2022-10-05 20:01 ` Eric Cook
2022-10-05 20:20   ` Dominik Vogt
2022-10-05 21:05     ` Wesley
2022-10-05 21:24       ` Dominik Vogt
2022-10-05 22:31         ` Bart Schaefer
2022-10-05 23:03           ` Dominik Vogt
2022-10-06  4:34             ` Bart Schaefer
2022-10-06  9:40               ` Peter Stephenson
2022-10-06 10:52                 ` Dominik Vogt [this message]
2022-10-06 10:30               ` Dominik Vogt
2022-10-05 20:26 ` Dominik Vogt
2022-10-05 22:16 ` Bart Schaefer
2022-10-05 22:32   ` Dominik Vogt
2022-10-06 10:31   ` Dominik Vogt
2022-10-07 11:45 ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yz6zfTHGw4mdiGRP@localhost \
    --to=dominik.vogt@gmx.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).