From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13900 invoked from network); 19 Mar 2023 16:53:57 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Mar 2023 16:53:57 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1679244837; b=In4fIZNDRkDjeB+Xnw7avvpgnU0pZtruTIYp90RgeD6PR+4kHaLI2fgSMoQOI/ZACIneynGFLV cQ0KN/0GbAiuq+ukm6EfHF+0t4niSC/a8P+NbsbJ+XTDq/xe6dAZ+ugS9eGnHTwO7kaNHEWHSH U3mRPZuiWjsn6Bqjd4Q87hiZXjQXuw4ZZFXL6UPYgKDoA3k3ggOMzVwXc/b/4Saan0xWM4tuMu sZnuYnRP7HUxNbbDNBcaTCsF0QmX8a209I7D3reC1hDDX/LnRWYzQZQgbjEQtBr8Rf7Yo9/A6u +ik8lZ5lB3D9O+oC1fGYk+ef8Io5KJ/KJvC4ku5gy1Tcfg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f49.google.com) smtp.remote-ip=209.85.208.49; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1679244837; bh=YFdO71PYt1Wk6bWfe3ZCnnUb2S+W5v8p2/o4QdhANF8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=ZUPJA4JKLVwTeq87xjYDffMjHRrSA+AIz4f4QNXhECivV5aw4NklcU6Bxf8Xw9K+uXOKpBxEw+ /IZCw2E4ZQLfPAbtiyN9O1xGjwJYkpCB7pmulETKY5aM6NjQ/5eaeklyVQCgT38SbWfQV9Nfij HAZzEE/w/VXxlWYQIMtf+x5/FtyL0OlT2OrCC4kqawvqSRRNGq+Lgi1E4TW0ixCjjPVDpRsOJI 6A7txHd0e169K20GywGoA5mGWZuPwd1RrzhV1iEUNLjUv9mIXZ4o4y+ZgnJsABM2G1U0enWiQg we9ahYadw3mE7R5j/oMy23PFY2JboDQYmE5i2pDGlLv3Xw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=3tn1Km5yuqjj7LroH/kgM2XI19SJhohgRMLAGT6Ak6k=; b=YikLMZuiwNFh0d0IEc1NGP8vlX Fn+co2yMO643FgJrZ4R6nMAIOyd/tUJf4k0mMq4SsbBnLU6fnVUvEpl66zW2pIibmG5MmjJwHka4I 2eneAlpjlLIJtsNVFC2fiJwbbM+dsd7Qw9YBCSKzPCqOzmHjNpWpEmzncrLrSZOg1lGsaXQDt9Amn crq1QF12HQc525H0LxnzASGKnC0uaBdWbtf9rt5id6kfRYo1ZjQ9CjvC8voF140ofuzjfoQxrq8wd rRyeSGVmaFOGRzc35iA23ZrE0WQd+qeli8TjzlqPkimt3Mu0c7VbDVcAosUjKyPQTOXSOm1ZBTkV8 2jBNURzw==; Received: by zero.zsh.org with local id 1pdwI7-000PyI-Qm; Sun, 19 Mar 2023 16:53:55 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f49.google.com) smtp.remote-ip=209.85.208.49; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ed1-f49.google.com ([209.85.208.49]:34606) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pdwHW-000PGY-92; Sun, 19 Mar 2023 16:53:19 +0000 Received: by mail-ed1-f49.google.com with SMTP id b20so5341695edd.1 for ; Sun, 19 Mar 2023 09:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; t=1679244797; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3tn1Km5yuqjj7LroH/kgM2XI19SJhohgRMLAGT6Ak6k=; b=ml8wPzLMU87re0uDI7U3ohTWvpYRNPtE7baQOPaw3zVt+YYokSzU5JbnlbK6XsTZsf 7WgcT4kviHiXKUqpFvtPlfHd+xGQqO7tBDebOJav+yCW1UWCYW3unbx7EkjpyugyiJId 2Zxq6t62ONgMdbuWho1bsmEAdefe0XAfz1Km+hKXz1ikSQmEXbVXoxtmdbOOuOCe8FB0 atDVv3UQ8m86fIhY6oXxxzWj/cAGDvXTLKZam8knwukoVgHR5d2mmDUZlAaVKWGrYhvq m0FfTrDrVTixpWbgJJRIwby2AH39JZD0Wj6Ij4H3rv+K7lBr+NJc2tyLJTzf2jbldFCO cemA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679244797; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3tn1Km5yuqjj7LroH/kgM2XI19SJhohgRMLAGT6Ak6k=; b=i6hAlFReSKEY7GU/+pTIz/NmcAgJgmTqhkHQzKI19CGbgBHnbTvZqx7H38yCzLmR5+ MTp3bedU8QqYj00kGg7hONin+b5bC5yCkqLfOSUm/wq9XOLC/713waiaMsQXQ1b6BF+h WYtZWpDkgZtA5C6U9e0b8iHz5E1c6UNMBcHeI9zBMHfYNum1teabCfxkuRliZKyQr4WI lYQeRBYiWwCN6OemTU5l1r4ZA9B90reNwMJAQSLG1dWhZT2BFplPtZ+9n2YctIs08GWw Z7AWtS9XkzT80XzdYUafSbXUKl7R0m7/BEwAS3OapH6LC7IadXqLnkNy19o+wac+Ujbt 0nuQ== X-Gm-Message-State: AO0yUKWRTjV8RCtv9he6Pt1KVIN+t9VJeWReSP5Js1o15dpwH4UukT/9 4C9a5qGaC+MDk3OKIcqDg41ceRvl4Yfk90xPBdF9GA== X-Google-Smtp-Source: AK7set+mAhGiixc81qpNeJCRzX9pmZzHhOC0H47AI+StxpRfUBUa0164UaqiF3EByCnBj7vGO484GbDGBykvEwCXL8c= X-Received: by 2002:a50:aa96:0:b0:4f9:f4f7:9e8f with SMTP id q22-20020a50aa96000000b004f9f4f79e8fmr4575557edc.2.1679244797622; Sun, 19 Mar 2023 09:53:17 -0700 (PDT) MIME-Version: 1.0 References: <33a75d10-d765-3d79-a179-943c57659111@protonmail.ch> In-Reply-To: <33a75d10-d765-3d79-a179-943c57659111@protonmail.ch> From: Bart Schaefer Date: Sun, 19 Mar 2023 09:53:06 -0700 Message-ID: Subject: Re: The HIST_EXPIRE_DUPS_FIRST might corrupt and wipe partially history file if many shells exit at the same time To: Piotr Karbowski Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 28973 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Sun, Mar 19, 2023 at 4:56=E2=80=AFAM Piotr Karbowski wrote: > > 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. > > +SAVEHIST=3D'96000' > +setopt hist_expire_dups_first > > 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? There is a locking mechanism. A couple of things may be happening: 1) Your home directory (or ZDOTDIR) is on a remote filesystem with asynchronous mounting, so the locking mechanism doesn't always work. You haven't described your system configuration in any detail, but from what you have said this one seems unlikely. 2) The locking mechanism doesn't work for some other reason. Make sure the HIST_SAVE_BY_COPY option is set (it's the default but check anyway). 3) When exiting a session (or particularly when rebooting), there may be a limited amount of time for the processes to clean up and exit before they are killed. With the combination of options you have, each shell must re-read the history file to merge it with its local history before writing it back. With multiple shells and tens of thousands of lines of history, this might take longer than all the shells are allowed to stay alive. Try putting something in your .zlogout file that writes a timestamp to a file (different for each shell, e.g., use $$ in the filename). Since .zlogout runs after history is saved, if you find any of those files to be missing, that's a clue that #3 is happening. You could also look to see if a ".zsh_history.new" file is left behind.