File 5274-Fix-sticky-sync-locks.patch of Package erlang
From cad25ed4ca03d87713b865d9a50cef28e3460bbe Mon Sep 17 00:00:00 2001
From: Dan Gudmundsson <dgud@erlang.org>
Date: Wed, 8 Feb 2023 17:06:14 +0100
Subject: [PATCH 4/4] Fix sticky sync locks
Needs to mark all sticky locks as sticky.
Tests failed for the first lock.
---
lib/mnesia/src/mnesia_locker.erl | 2 ++
lib/mnesia/test/mnesia_isolation_test.erl | 5 -----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/mnesia/src/mnesia_locker.erl b/lib/mnesia/src/mnesia_locker.erl
index 66f08580fa..d8ac39b393 100644
--- a/lib/mnesia/src/mnesia_locker.erl
+++ b/lib/mnesia/src/mnesia_locker.erl
@@ -761,12 +761,14 @@ do_sticky_lock(Tid, Store, {Tab, Key} = Oid, Lock) ->
exit({aborted, Reason});
{?MODULE, N, not_stuck} ->
not_stuck(Tid, Store, Tab, Key, Oid, Lock, N),
+ ?ets_insert(Store, {sticky, true}),
dirty_sticky_lock(Tab, Key, [N], Lock);
{mnesia_down, Node} ->
EMsg = {aborted, {node_not_running, Node}},
flush_remaining([N], Node, EMsg);
{?MODULE, N, {stuck_elsewhere, _N2}} ->
stuck_elsewhere(Tid, Store, Tab, Key, Oid, Lock),
+ ?ets_insert(Store, {sticky, true}),
dirty_sticky_lock(Tab, Key, [N], Lock)
end.
diff --git a/lib/mnesia/test/mnesia_isolation_test.erl b/lib/mnesia/test/mnesia_isolation_test.erl
index b3f5e96e4b..9f427dbaa6 100644
--- a/lib/mnesia/test/mnesia_isolation_test.erl
+++ b/lib/mnesia/test/mnesia_isolation_test.erl
@@ -630,11 +630,6 @@ sticky_sync(Config) when is_list(Config) ->
%% Fill 1000 dc records. At the end all dc records should have value 1.
{Time, ok} = timer:tc(fun() -> lists:foreach(TestFun, lists:seq(1,200)) end),
- io:format("200 trans done in ~p ~n",[Time div (1000000)]),
- case (Time div (1000000)) < 20 of
- true -> lists:foreach(TestFun, lists:seq(201,1000));
- false -> ignore %% Some virtual test machines are really slow..
- end,
io:format("Written, check content~n",[]),
All = fun() -> mnesia:select(dc, [ {{dc, '_', 0}, [] ,['$_']} ]) end,
?match({atomic, []}, rpc:call(N1, mnesia, sync_transaction, [All])),
--
2.35.3