Skip to content

Conversation

@oknet
Copy link
Member

@oknet oknet commented Jun 22, 2017

The request transform would be applied to POST and/or PUT request.
The server_vc should be established (writeable) before request transform start.
The CheckConnect is created by connect_s,
It will callback NET_EVENT_OPEN to HttpSM if server_vc is WRITE_READY,
Otherwise NET_EVENT_OPEN_FAILED is callbacked.

…st transform start.

The request transform would be applied to POST and/or PUT request.
The server_vc should be established (writeable) before request transform start.
The CheckConnect is created by connect_s,
  It will callback NET_EVENT_OPEN to HttpSM if server_vc is WRITE_READY,
  Otherwise NET_EVENT_OPEN_FAILED is callbacked.
@oknet oknet added the HTTP label Jun 22, 2017
@oknet oknet added this to the 8.0.0 milestone Jun 22, 2017
@oknet oknet added the Backport Marked for backport for an LTS patch release label Jun 22, 2017
@oknet oknet modified the milestones: 7.1.0, 8.0.0 Jun 22, 2017
@oknet
Copy link
Member Author

oknet commented Jun 22, 2017

This PR revert some code changed by commit 35d492a.

@oknet oknet requested a review from shinrich June 22, 2017 11:04
@oknet oknet self-assigned this Jun 22, 2017
@oknet
Copy link
Member Author

oknet commented Jun 22, 2017

@shinrich I think there is a mistaken in the commit 35d492a.

The POST / PUT retry can not working on connection failed. ATS should get a established connection by connect_s() first before request transform start.

@oknet
Copy link
Member Author

oknet commented Jun 22, 2017

@zwoop This is a 7.1.0 candidate.

@SolidWallOfCode
Copy link
Member

What is the issue if the transform begins before the origin is writeable? Does it cause the buffer to fill up, or is content discarded on a retry? Is the computation expense of the transform too much when requests fail frequently?

@oknet
Copy link
Member Author

oknet commented Jun 23, 2017

@SolidWallOfCode

The request transform starts after NET_EVENT_OPEN is received. Currently, the NET_EVENT_OPEN is callbacked by connect_re() but it doesnt mean the connection is ready to send request to server.

If the connection is not ready and the server request header sent out:

  • The EVENT_ERROR will callback to HttpSM if NetHandler get an error on write().
  • The EVENT_*_TIMEOUT will callback to HttpSM if connect is timeout

If ATS receives these above events, it will trigger the retry mechanism and chain_abort_all() will discard the data of transform

With the connect_s(), the EVENT_ERROR and EVENT_*_TIMEOUT are converted to NET_EVENT_OPEN_FAILED. The NET_EVENT_OPEN is ignored and the WRITE_READY is converted to NET_EVENT_OPEN.

With the connect_s(), the EVENT_ERROR and EVENT_*_TIMEOUT are converted to NET_EVENT_OPEN_FAILED. The NET_EVENT_OPEN is ignored then it callbacks NET_EVENT_OPEN after receiving the WRITE_READY.

When ATS receives NET_EVENT_OPEN_FAILED, it will also trigger the retry mechanism but the request transform is not started yet.

@oknet oknet requested review from SolidWallOfCode and zwoop June 23, 2017 08:14
@oknet
Copy link
Member Author

oknet commented Jun 24, 2017

According to the email send from @keesspoelstra , if the the server connection retry mechanism enabled on POST and/or PUT request, ATS may crash on assert.

The retry will obviously decrease by this PR for POST and/or PUT request.
And the retry should be done before request transform starts.

@zwoop

@SolidWallOfCode
Copy link
Member

Overall it seems reasonable. The question I have is, why use connect_re at all? Why not skip the method check and always use connect_s?

Copy link
Member

@shinrich shinrich left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. The previous commit I made because it appeared that post/put would never make it to the else case. But if you explicitly push them to the else, then the extra timeout logic makes sense.

@zwoop
Copy link
Contributor

zwoop commented Jun 26, 2017

Should we land this?

@bryancall
Copy link
Contributor

Looks good. 👍

@zwoop zwoop merged commit 91724db into apache:master Jun 27, 2017
@oknet
Copy link
Member Author

oknet commented Jun 28, 2017

@SolidWallOfCode

Because different from connect_s, connect_re sends request to OS directly and only check WRITE_COMPLETE event while connect_s checks both WRITE_READY and WRITE_COMPLETE, which I believe connect_re has better performance.

@zwoop
Copy link
Contributor

zwoop commented Jun 29, 2017

Cherry-picked to 7.1.x

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

Labels

Backport Marked for backport for an LTS patch release HTTP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants