Skip to content

Commit 54a5e05

Browse files
author
Doug Rohrer
committed
WIP getting this test to fail again in the right way
1 parent 486ea75 commit 54a5e05

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
%% -------------------------------------------------------------------
2+
%%
3+
%% Copyright (c) 2015 Basho Technologies, Inc.
4+
%%
5+
%% This file is provided to you under the Apache License,
6+
%% Version 2.0 (the "License"); you may not use this file
7+
%% except in compliance with the License. You may obtain
8+
%% a copy of the License at
9+
%%
10+
%% http://www.apache.org/licenses/LICENSE-2.0
11+
%%
12+
%% Unless required by applicable law or agreed to in writing,
13+
%% software distributed under the License is distributed on an
14+
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
%% KIND, either express or implied. See the License for the
16+
%% specific language governing permissions and limitations
17+
%% under the License.
18+
%%
19+
%%-------------------------------------------------------------------
20+
21+
-module(riak_core_vnode_manager_intercepts).
22+
-include("intercept.hrl").
23+
%% API
24+
-compile(export_all).
25+
-define(M, riak_core_vnode_manager_orig).
26+
27+
return_dead_process_pid_from_get_vnode_pid(Index, VNodeMod = riak_pipe_vnode) ->
28+
%% ?I_INFO("Intercepting riak_core_vnode_master:get_vnode_pid"),
29+
random:seed(os:timestamp()),
30+
case random:uniform(100) of
31+
7 ->
32+
%% Simulate what happens when a VNode completes handoff between get_vnode_pid
33+
%% and the fold attempting to start - other attempts to intercept and slow
34+
%% certain parts of Riak to invoke the particular race condition were unsuccessful
35+
?I_INFO("Replaced VNode with spawned function in get_vnode_pid"),
36+
VNodePid = spawn(fun() ->
37+
ok
38+
end),
39+
MonRef = erlang:monitor(process, VNodePid),
40+
receive
41+
{'DOWN', MonRef, process, VNodePid, _Reason} -> ok
42+
end,
43+
{ok, VNodePid};
44+
_ ->
45+
?M:get_vnode_pid_orig(Index, VNodeMod)
46+
end;
47+
return_dead_process_pid_from_get_vnode_pid(Index, VNodeMod) ->
48+
?M:get_vnode_pid_orig(Index, VNodeMod).

tests/pipe_verify_handoff_blocking.erl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,9 @@ queue_filler(Node, Pipe, Inputs, Count) ->
177177
receive
178178
{stop, Owner} -> Owner ! {done, Count}
179179
after 0 ->
180-
{{value, I}, Q} = queue:out(Inputs),
181-
case rpc:call(Node, riak_pipe, queue_work, [Pipe, I], 40000) of
182-
ok ->
183-
lager:info("Received response from queue_work"),
184-
queue_filler(Node, Pipe, queue:in(I, Q), Count+1);
185-
_ ->
186-
lager:info("Timed out waiting for response from queue_work"),
187-
queue_filler(Node, Pipe, queue:in(I, Q), Count+1)
188-
end
180+
{{value, I}, Q} = queue:out(Inputs),
181+
ok = rpc:call(Node, riak_pipe, queue_work, [Pipe, I]),
182+
queue_filler(Node, Pipe, queue:in(I, Q), Count+1)
189183
end.
190184

191185
%% @doc tell all fillers to stop and collect and sum their send counts

0 commit comments

Comments
 (0)