Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hunt BOSH interleave requests issue #869

Merged
merged 11 commits into from
Oct 19, 2016

Conversation

michalwski
Copy link
Contributor

Proposed changes include:

  • fix for wrong deferred rid processing when there was a response delivered to the hendler which send bigger rid then expected
  • fix for missing xmlns:stream attr in <body> when stream features arrives in their own message
  • PopEr tests for message sending/receiving over BOSH

Detailed description of the deferred rids processing.

Assume expected rid has value X
This bug happens when MongooseIM processes a request with rid X+1 before X and there is a pending response to the client. In this situation Mongoose puts the request into deferred list which is expected. Also it sends the pending response to the client using this deferred connection which results in adding the X+1 rid to cached responses list (used to track retransmissions). Later when the deferred rid X+1 is process because the prev arrived, MongooseIM treats it as a retransmission (because the rid X+1 is on the cached responses list). Because of that the main rid is not updated correctly and expects X+1 whereas it should expect now X+2. As a result the end the session is terminated upon receiving rid X+3

@michalwski michalwski force-pushed the hunt-bosh-interleave-requests-issue branch 2 times, most recently from ad81d64 to 773fe12 Compare September 12, 2016 10:21
@Nyco Nyco changed the title Hunt bosh interleave requests issue Hunt BOSH interleave requests issue Sep 12, 2016
@michalwski michalwski force-pushed the hunt-bosh-interleave-requests-issue branch from 7a1a27f to 1c1b2c1 Compare September 13, 2016 09:23
@michalwski michalwski force-pushed the hunt-bosh-interleave-requests-issue branch from 1c1b2c1 to 1e8cf1d Compare September 29, 2016 11:33
-export([test/1, sample/0, prop/1]).

-export([initial_state/1, command/1, precondition/2, postcondition/3,
next_state/3]).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 14 has a tab at column 0.

-export([ct_config_giver/1]).

-record(state, {carol,
geralt,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 27 has a tab at column 0.

?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),
?TRAPEXIT(
begin
{History,State,Result} = run_commands(?MODULE, Cmds),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 43

escalus_client:stop(Client).

initial_state(Pid) ->
#state{carol = undefined,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 63 has a tab at column 0.

?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),
?TRAPEXIT(
begin
{History,State,Result} = run_commands(?MODULE, Cmds),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 43


initial_state(Pid) ->
#state{carol = undefined,
geralt = undefined,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 64 has a tab at column 0.

maybe_stop_client(State#state.geralt),
?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",
[History,State,Result]),
aggregate(command_names(Cmds), Result =:= ok))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 48 has a tab at column 0.

maybe_stop_client(State#state.carol),
maybe_stop_client(State#state.geralt),
?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",
[History,State,Result]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 47 has a tab at column 0.

?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),
?TRAPEXIT(
begin
{History,State,Result} = run_commands(?MODULE, Cmds),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 43 has a tab at column 0.

prop(Config) ->
Pid = spawn_link(?MODULE, ct_config_giver, [Config]),
?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),
?TRAPEXIT(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 41 has a tab at column 0.

RMsgs = [exml_query:path(E, [{element, <<"body">>}, cdata])
|| E <- Stanzas],
SortedMsgs = lists:sort([Msg || {_, Msg} <- Msgs]),
ct:pal("waiting for: ~p~nreceived: ~p", [SortedMsgs, RMsgs]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Remove the debug call to ct:pal/2 on line 171.

{History,State,Result} = run_commands(?MODULE, Cmds),
maybe_stop_client(State#state.carol),
maybe_stop_client(State#state.geralt),
?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 46 has a tab at column 0.


prop(Config) ->
Pid = spawn_link(?MODULE, ct_config_giver, [Config]),
?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 40 has a tab at column 0.

Pid = spawn_link(?MODULE, ct_config_giver, [Config]),
?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),
?TRAPEXIT(
begin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 42 has a tab at column 0.

?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",
[History,State,Result]),
aggregate(command_names(Cmds), Result =:= ok))
end)).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 49 has a tab at column 0.

maybe_stop_client(State#state.carol),
maybe_stop_client(State#state.geralt),
?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",
[History,State,Result]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 47

maybe_stop_client(State#state.carol),
maybe_stop_client(State#state.geralt),
?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",
[History,State,Result]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 47

?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),
?TRAPEXIT(
begin
{History,State,Result} = run_commands(?MODULE, Cmds),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 43

maybe_stop_client(State#state.carol),
maybe_stop_client(State#state.geralt),
?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",
[History,State,Result]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 47

maybe_stop_client(State#state.carol),
maybe_stop_client(State#state.geralt),
?WHENFAIL(ct:pal(error, "History: ~p~nState: ~p\nResult: ~p~n",
[History,State,Result]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 47

?FORALL(Cmds, commands(?MODULE, initial_state(Pid)),
?TRAPEXIT(
begin
{History,State,Result} = run_commands(?MODULE, Cmds),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 43

@michalwski michalwski force-pushed the hunt-bosh-interleave-requests-issue branch 2 times, most recently from 0a12e4c to 7219d3f Compare September 29, 2016 11:45
RMsgs = [exml_query:path(E, [{element, <<"body">>}, cdata])
|| E <- Stanzas],
SortedMsgs = lists:sort([Msg || {_, Msg} <- Msgs]),
ct:pal("waiting for: ~p~nreceived: ~p", [SortedMsgs, RMsgs]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Remove the debug call to ct:pal/2 on line 167.

@michalwski michalwski force-pushed the hunt-bosh-interleave-requests-issue branch from 7219d3f to 0cbd01d Compare September 29, 2016 11:48
@bartekgorny
Copy link
Collaborator

Should b7ca3b5 message reference PR 869 (this one)? Currently it references 868, which doesn't seem relevant.

@michalwski
Copy link
Contributor Author

Should b7ca3b5 message reference PR 869 (this one)? Currently it references 868, which doesn't seem relevant.

Yes, good catch!

in some rare cases it is possible that stream:features arrive without
the stream tag. In this case the xmlns:stream was not added
which confused expath and probably other parsers
it is not possible to guarantee order of msgs received from BOSH
is 100% tests
@michalwski michalwski force-pushed the hunt-bosh-interleave-requests-issue branch from efdd38a to 9a7ca19 Compare October 17, 2016 10:51
The fix is only half line of code.
Cached responses should be resent only if there is a handler,
otherwise the RID is not incremented correctly when new request arrives
and the session is terminated incorrectly.
See PR #869 for more details about the bug.
@michalwski michalwski force-pushed the hunt-bosh-interleave-requests-issue branch from 9a7ca19 to 9609812 Compare October 17, 2016 10:53
@bartekgorny bartekgorny merged commit 4d9e5c7 into master Oct 19, 2016
@bartekgorny bartekgorny deleted the hunt-bosh-interleave-requests-issue branch October 19, 2016 12:19
@michalwski michalwski mentioned this pull request Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants