Skip to content

Conversation

@scw00
Copy link
Member

@scw00 scw00 commented Jun 13, 2017

ua_buffer_reader should be released in deallocate_redirect_postdata_buffers

Otherwise, we will never append block in mbuf. The max_read_avail (in read_from net) will check every readers in this mbuf and find out this reader. But we've not consumed data in this reader.

So if the buffer is full, the request will be blocked until timeout.

@mingzym
Copy link
Member

mingzym commented Jun 13, 2017

[approve ci]

1 similar comment
@zwoop
Copy link
Contributor

zwoop commented Jun 13, 2017

[approve ci]

@zwoop
Copy link
Contributor

zwoop commented Jun 13, 2017

Interesting. This seems pretty serious, is this a 7.1.0 candidate? @oknet ?

@zwoop zwoop added this to the 8.0.0 milestone Jun 13, 2017
@scw00
Copy link
Member Author

scw00 commented Jun 17, 2017

Considering this problem
1 The client send several post bytes to ats. We alloc the post buf and clone reader from tunnel's read_buffer, then tunnel and post buf consume data and return to eventsytem.

2 The client send left data and fill buffer, but tunnel dealloc post buf without consuming if the length of data is larger than HttpConfig::m_master.post_copy_size, then setup next read.

3 The read check the data block was full and still have data which not conuming(see write_avail in read_from_net), it will disable read and return directly. Then the vc will be lost until timeout.

@zwoop
Copy link
Contributor

zwoop commented Jun 21, 2017

@oknet What's the decision / thought on 7.1.0 or not? We need it ?

@zwoop
Copy link
Contributor

zwoop commented Jun 21, 2017

I've put this on the docs.trafficserver / ci.trafficserver machines, for testing.

active = false;
this->deallocate_buffers();
this->deallocate_redirect_postdata_buffers();
this->deallocate_buffers();
Copy link
Member

Choose a reason for hiding this comment

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

You should check all the calls to deallocate_redirect_postdata_buffers(); and always call the deallocate_buffers(); after it.

HttpSM::tunnel_handler_cache_fill, HttpSM::tunnel_handler_100_continue, HttpSM::tunnel_handler_push, etc ...

Copy link
Contributor

@bryancall bryancall Jun 27, 2017

Choose a reason for hiding this comment

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

@oknet If we should always call deallocate_redirect_postdata_buffers() before deallocate_buffers() then should the HttpTunnel class handle this itself?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, @scw00 has done it in the last commit. The comment is only for the first commit.

@scw00
Copy link
Member Author

scw00 commented Jun 26, 2017

Hmm, I think we should assign ua_reader_buffer to nullptr when we free the ua_reader_buffer's mbuf.

oknet
oknet previously approved these changes Jun 26, 2017
@oknet
Copy link
Member

oknet commented Jun 26, 2017

[approve ci]

@zwoop
Copy link
Contributor

zwoop commented Jun 27, 2017

@oknet @scw00 what's the word on this PR? 7.1.0 ?

@scw00
Copy link
Member Author

scw00 commented Jun 27, 2017

@zwoop This is a 7.1.0 candidate.

@zwoop
Copy link
Contributor

zwoop commented Jun 27, 2017

Ready to land this ?

}

if (postbuf->ua_buffer_reader != nullptr) {
postbuf->ua_buffer_reader->consume(postbuf->ua_buffer_reader->read_avail());
Copy link
Contributor

@bryancall bryancall Jun 27, 2017

Choose a reason for hiding this comment

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

This seems like a very error prone interface to clean up the IOBufferReader

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, The reader will be cleaned if mbuf freed in deallocate_buffer

Copy link
Member Author

Choose a reason for hiding this comment

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

So, we don't need to consider the order of deallocate_buffer.

@scw00
Copy link
Member Author

scw00 commented Jun 28, 2017

Attach a golang test script

package main

import(
  "net"
  "log"
  "time"
  "fmt"
)

func main() {
  conn, err := net.Dial("tcp", "127.0.0.1:8080")
  if err != nil {
    log.Fatal(err)
  }

  data := "POST HTTP://www.scw.com/ HTTP/1.1\r\n" +
    "Content-Length: 400000\r\n\r\n"
  conn.Write([]byte(data))
  data1 := make([]byte, 153)
  time.Sleep(1 * time.Second)
  conn.Write(data1)
  data2 := make([]byte, 400000 - 153)
  conn.Write(data2)

  data3 := make([]byte, 40000)
  conn.Read(data3)
  fmt.Println(string(data3))
  time.Sleep(3 * time.Second)
}

ink_assert(producer.vc != nullptr);
if (postbuf && postbuf->ua_buffer_reader && postbuf->ua_buffer_reader->mbuf == producer.read_buffer) {
postbuf->ua_buffer_reader = nullptr;
}
Copy link
Member

Choose a reason for hiding this comment

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

Set the postbuf->ua_buffer_reader to nullptr If the ATS free the producer.read_buffer.
To block any access to the postbuf->ua_buffer_reader in deallocate_redirect_postdata_buffers .

@scw00
Copy link
Member Author

scw00 commented Jun 28, 2017

Config

CONFIG proxy.config.http.number_of_redirections INT 3

@scw00
Copy link
Member Author

scw00 commented Jul 1, 2017

Could I merge this pr ?

@zwoop
Copy link
Contributor

zwoop commented Jul 3, 2017

@bryancall Ping? Should we merge this, and cherry-pick to 7.1.0? you had some concerns.

@scw00
Copy link
Member Author

scw00 commented Jul 16, 2017

Hi @bryancall , any idea for this PR ? We can use the golang script for a test. ATS will hang up the vc when enable post redirection.

@zwoop
Copy link
Contributor

zwoop commented Jul 19, 2017

Ping @bryancall @scw00 and @oknet on this. What's the word? This might be too late now for 7.0.0, but do we want it for 7.1.1 ?

@bryancall bryancall merged commit 86d7385 into apache:master Jul 20, 2017
@bryancall bryancall modified the milestones: 7.1.1, 8.0.0 Jul 20, 2017
@zwoop zwoop modified the milestones: 7.1.1, 7.1.0, 8.0.0 Jul 25, 2017
@zwoop
Copy link
Contributor

zwoop commented Jul 25, 2017

Cherry-picked to 7.1.x

@ranxuxin001
Copy link

I've read lots of pr about post data redirection request. Can I think that GET request redirection is not affected, please?

@oknet
Copy link
Member

oknet commented Dec 6, 2017

@ranxuxin yes, the buffer is used to replay the post payload while the request is redirected to the new server.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants