aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--erts/emulator/beam/erl_db_catree.c26
-rw-r--r--lib/stdlib/test/ets_SUITE.erl12
2 files changed, 31 insertions, 7 deletions
diff --git a/erts/emulator/beam/erl_db_catree.c b/erts/emulator/beam/erl_db_catree.c
index 5069e1e531..c3bebefbdf 100644
--- a/erts/emulator/beam/erl_db_catree.c
+++ b/erts/emulator/beam/erl_db_catree.c
@@ -630,6 +630,31 @@ static TreeDbTerm* join_trees(TreeDbTerm *left_root_param,
}
}
+#ifdef DEBUG
+# define FORCE_RANDOM_SPLIT_JOIN
+#endif
+#ifdef FORCE_RANDOM_SPLIT_JOIN
+static int dbg_fastrand(void)
+{
+ static int g_seed = 648835;
+ g_seed = (214013*g_seed+2531011);
+ return (g_seed>>16)&0x7FFF;
+}
+
+static void dbg_maybe_force_splitjoin(DbTableCATreeNode* base_node)
+{
+ switch (dbg_fastrand() % 8) {
+ case 1:
+ base_node->u.base.lock_statistics = 1+ERL_DB_CATREE_HIGH_CONTENTION_LIMIT;
+ break;
+ case 2:
+ base_node->u.base.lock_statistics = -1+ERL_DB_CATREE_LOW_CONTENTION_LIMIT;
+ break;
+ }
+}
+#else
+# define dbg_maybe_force_splitjoin(N)
+#endif /* FORCE_RANDOM_SPLIT_JOIN */
static ERTS_INLINE
int try_wlock_base_node(DbTableCATreeBaseNode *base_node)
@@ -676,6 +701,7 @@ void wunlock_adapt_base_node(DbTableCATree* tb,
DbTableCATreeNode* parent,
int current_level)
{
+ dbg_maybe_force_splitjoin(base_node);
if (base_node->u.base.lock_statistics > ERL_DB_CATREE_HIGH_CONTENTION_LIMIT
&& current_level < ERL_DB_CATREE_MAX_ROUTE_NODE_LAYER_HEIGHT) {
split_catree(tb, base_node, parent);
diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl
index de7c647610..367c7533b4 100644
--- a/lib/stdlib/test/ets_SUITE.erl
+++ b/lib/stdlib/test/ets_SUITE.erl
@@ -7394,16 +7394,14 @@ stimulate_contention(Tid) ->
stim_inserter_loop(T, RState, Num),
Num = ets:info(T, size),
erts_debug:set_internal_state(ets_force_split, {T, false}),
- Stats1 = ets:info(T,stats),
ets:match_delete(T, {'$1','$1','$1'}),
case ets:info(T,stats) of
- Stats1 ->
- io:format("stimulated ordered_set: ~p\n", [Stats1]);
- Stats2 ->
+ {0, _, _} ->
io:format("Houston, we got a testability problem.\n"
- "Someone seems to have implemented join-on-delete\n"
- "~p =/= ~p\n", [Stats1, Stats2]),
- ct:fail("Join on delete?")
+ "Someone seems to have implemented join-on-delete\n", []),
+ ct:fail("Join on delete?");
+ Stats ->
+ io:format("stimulated ordered_set: ~p\n", [Stats])
end.
stim_inserter_loop(_, _, 0) ->