File 0739-stdlib-Make-ets-tab2file-always-truncate-file.patch of Package erlang

From 4b2efb65d862a6c3c9e5b834c3a157ce007ee8af Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Mon, 15 May 2023 16:02:43 +0200
Subject: [PATCH] stdlib: Make ets:tab2file always truncate file

to avoid {repaired, ...} returned from disk_log:open
if raced by concurrent file creator.
---
 lib/kernel/doc/src/disk_log.xml | 4 ++--
 lib/stdlib/src/ets.erl          | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/kernel/doc/src/disk_log.xml b/lib/kernel/doc/src/disk_log.xml
index 46ed711906..275d050fe8 100644
--- a/lib/kernel/doc/src/disk_log.xml
+++ b/lib/kernel/doc/src/disk_log.xml
@@ -780,8 +780,8 @@
               no automatic repair is attempted. Instead, the
               tuple <c>{error, {need_repair, <anno>Log</anno>}}</c> is returned if an
               attempt is made to open a corrupt log file. 
-              If <c>truncate</c> is specified, the log file becomes
-              truncated, creating an empty log. Defaults to
+              If <c>truncate</c> is specified, the log file becomes truncated,
+	      creating an empty log, regardless of previous content. Defaults to
               <c>true</c>, which has no effect on logs opened in 
               read-only mode.
               </p>
diff --git a/lib/stdlib/src/ets.erl b/lib/stdlib/src/ets.erl
index 979a75b231..0f1c160322 100644
--- a/lib/stdlib/src/ets.erl
+++ b/lib/stdlib/src/ets.erl
@@ -812,7 +812,8 @@ tab2file(Table, File, Options) ->
 	    _ -> throw(eaccess)
 	end,
 	Name = make_ref(),
-	case disk_log:open([{name, Name}, {file, File}]) of
+	case disk_log:open([{name, Name}, {file, File},
+                            {repair, truncate}]) of
 	    {ok, Name} ->
 		ok;
 	    {error, Reason} ->
-- 
2.35.3

openSUSE Build Service is sponsored by