Skip to content

Set HttpSM::tunnel_handler_post to handle write event for outputing HTTP 408 response. - #1583

Merged
oknet merged 1 commit into
apache:masterfrom
oknet:i1583
Mar 30, 2017
Merged

oknet merged 1 commit into
apache:masterfrom
oknet:i1583

Conversation

@oknet

@oknet oknet commented Mar 15, 2017 •

Copy link
Copy Markdown
Member

If POST transform plugin does not finished before the ua_session timeouted, the producer will received a TIMEOUT event and callback producer_handler (HttpSM::tunnel_handler_post_ua).

The HttpSM::tunnel_handler_post_ua will send a 408 response to client.
The ua_session will received TIMEOUT event again in the next second because it does not reset the ua_session's timeout.

The TIMEOUT event will be sent to HttpSM default handler because we did not save VIO returned by do_io_write to ua_entry->write_vio.

The default handler is HttpSM::state_request_wait_for_transform_read and the TIMEOUT event is unexpected, then ink_release_asserti(0) at L1333 (at the end of HttpSM::state_common_wait_for_transform_read).

@oknet oknet self-assigned this Mar 15, 2017
@oknet oknet added the HTTP label Mar 15, 2017
@oknet oknet added this to the 7.2.0 milestone Mar 15, 2017
@zwoop

zwoop commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

This sounds like a 7.1.0 candidate?

@oknet

oknet commented Mar 15, 2017

Copy link
Copy Markdown
Member Author

@zwoop yes, 7.1.x is ok.

@oknet
oknet requested a review from zwoop March 15, 2017 15:45
@zwoop

zwoop commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

This is running on Docs.

@zwoop zwoop modified the milestones: 7.1.0, 7.2.0 Mar 15, 2017
@zwoop zwoop mentioned this pull request Mar 17, 2017
@maskit

maskit commented Mar 22, 2017

Copy link
Copy Markdown
Member

I might be able to reproduce the issue, but only with H2. I couldn't reproduce it with H1.

What I did are:

  • Add sleep(5) into consume() of PostBuffer plugin
  • Set proxy.config.http.transaction_no_activity_timeout_in and proxy.config.http.transaction_active_timeout_in very small (2~5 sec)
  • Apply the change on this PR
  • Run ATS with the modified PostBuffer plugin
  • Send a big POST request with curl

The patch fixes an abort issue but ATS still aborts. (Fails at another assert.)

Fatal: HttpSM.cc:2725: failed assertion `post_transform_info.entry->in_tunnel == true`
2017-03-22 16:14:23.623562 traffic_server[68093:3635467] Fatal: HttpSM.cc:2725: failed assertion `post_transform_info.entry->in_tunnel == true`
(lldb) bt
* thread #14: tid = 0x37790b, 0x00007fffd5191dd6 libsystem_kernel.dylib`__pthread_kill + 10, name = '[ET_NET 11]', stop reason = signal SIGABRT
  * frame #0: 0x00007fffd5191dd6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fffd527d787 libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fffd50f7420 libsystem_c.dylib`abort + 129
    frame #3: 0x000000000002abd0 libtsutil.7.dylib`ink_abort(message_format="%s:%d: failed assertion `%s`") + 368 at ink_error.cc:99
    frame #4: 0x0000000000027a0f libtsutil.7.dylib`::_ink_assert(expression="post_transform_info.entry->in_tunnel == true", file="HttpSM.cc", line=2725) + 47 at ink_assert.cc:37
    frame #5: 0x000000010014ca3e traffic_server`HttpSM::tunnel_handler_post_or_put(this=0x0000000005cfd9b0, p=0x0000000005cfef00) + 174 at HttpSM.cc:2725
    frame #6: 0x000000010013fa06 traffic_server`HttpSM::tunnel_handler_post(this=0x0000000005cfd9b0, event=103, data=0x0000000003e2ded0) + 1062 at HttpSM.cc:2790
    frame #7: 0x0000000100137708 traffic_server`HttpSM::main_handler(this=0x0000000005cfd9b0, event=103, data=0x0000000003e2ded0) + 776 at HttpSM.cc:2682
    frame #8: 0x000000010001ef60 traffic_server`Continuation::handleEvent(this=0x0000000005cfd9b0, event=103, data=0x0000000003e2ded0) + 112 at I_Continuation.h:153
    frame #9: 0x00000001001be69f traffic_server`Http2Stream::main_event_handler(this=0x0000000003e2db40, event=103, edata=0x0000000000b46aa0) + 1903 at Http2Stream.cc:88
    frame #10: 0x000000010001ef60 traffic_server`Continuation::handleEvent(this=0x0000000003e2db40, event=103, data=0x0000000000b46aa0) + 112 at I_Continuation.h:153
    frame #11: 0x0000000100375a15 traffic_server`EThread::process_event(this=0x0000000002d0c000, e=0x0000000000b46aa0, calling_code=103) + 405 at UnixEThread.cc:143
    frame #12: 0x00000001003761dc traffic_server`EThread::execute(this=0x0000000002d0c000) + 972 at UnixEThread.cc:240
    frame #13: 0x0000000100374f57 traffic_server`spawn_thread_internal(a=0x00000000037000c0) + 103 at Thread.cc:84
    frame #14: 0x00007fffd527aaab libsystem_pthread.dylib`_pthread_body + 180
    frame #15: 0x00007fffd527a9f7 libsystem_pthread.dylib`_pthread_start + 286
    frame #16: 0x00007fffd527a1fd libsystem_pthread.dylib`thread_start + 13

@oknet

oknet commented Mar 22, 2017

Copy link
Copy Markdown
Member Author

@zwoop @SolidWallOfCode
In HttpSM::tunnel_handler_post(), calling tunnel_handler_post_or_put(p) before vc_table.cleanup_all() and tunnel.chain_abort_all(p) to avoid assert that @maskit met.

@maskit

maskit commented Mar 23, 2017

Copy link
Copy Markdown
Member

@oknet The assert has gone. At least it works with H2. Thanks.

Comment thread proxy/http/HttpSM.cc Outdated

if (event != HTTP_TUNNEL_EVENT_DONE) {
if ((event == VC_EVENT_WRITE_COMPLETE) || (event == VC_EVENT_EOS)) {
if ((event == VC_EVENT_WRITE_COMPLETE) || (event == VC_EVENT_EOS) || (event == VC_EVENT_ERROR) ||

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@shinrich and I discussed this a bit. It's a big ugly to have these two long conditionals that are identical but not obviously so. What I would recommend is adding an inline function like isTxnTerminalEvent that covers EOS, ERROR, INACTIVITY_TIMEOUT and INACTIVITY_TIMEOUT and have

if (event == VC_EVENT_WRITE_COMPLETE || isEventTxTerminal(event)) {

which would be easier to understand and easier to see the set of events are the same here and on line 2784. Our opinion is this would be useful in no small number of other places in the code as well and help prevent problems like this in the future.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can rewrite it to switch-case :

switch (event) {
case VC_EVENT_WRITE_COMPLETE:
case VC_EVENT_EOS:
case VC_EVENT_ERROR:
case VC_EVENT_INACTIVITY_TIMEOUT:
case VC_EVENT_ACTIVE_TIMEOUT:
    // do something 
    break;
default:
    break;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

switch case is much ATS style than any others, more clear for Human reading.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should add the inline function to make sure that the same condition is used under the same context, and to clarify the condition we expect.

The switch case style is more readable than current style though, it doesn't tell us what the case is.

…TTP 408 response.

If POST transform plugin does not finished before the ua_session
timeouted, the producer will received a TIMEOUT event and callback
producer_handler (HttpSM::tunnel_handler_post_ua).

The HttpSM::tunnel_handler_post_ua will send a 408 response to client.
The ua_session will received TIMEOUT event again in the next second
because it does not reset the ua_session's timeout.

The TIMEOUT event will be sent to HttpSM default handler because we did
not save VIO returned by do_io_write to ua_entry->write_vio.

The default handler is HttpSM::state_request_wait_for_transform_read and
the TIMEOUT event is unexpected, then ink_release_asserti(0) at L1333
(at the end of HttpSM::state_common_wait_for_transform_read).

In HttpSM::tunnel_handler_post(), calling tunnel_handler_post_or_put(p)
before vc_table.cleanup_all() and tunnel.chain_abort_all(p).
@atsci

atsci commented Mar 24, 2017

Copy link
Copy Markdown

@atsci

atsci commented Mar 24, 2017

Copy link
Copy Markdown

@atsci

atsci commented Mar 24, 2017

Copy link
Copy Markdown

@atsci

atsci commented Mar 24, 2017

Copy link
Copy Markdown

@atsci

atsci commented Mar 24, 2017

Copy link
Copy Markdown

@atsci

atsci commented Mar 24, 2017

Copy link
Copy Markdown

@atsci

atsci commented Mar 24, 2017

Copy link
Copy Markdown

@zwoop

zwoop commented Mar 29, 2017

Copy link
Copy Markdown
Contributor

I've been running with this on docs for a few days, with no problem. It does not seem to address the threads running at 100% CPU at times though. But assuming this fixes another problem, it seems safe and fine.

@zwoop zwoop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants