Repository navigation
quic: update writedesiredsize on maxdataframe #65306
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,6 +379,16 @@ class Http3ApplicationImpl final : public Session::Application { | |
| nghttp3_conn_unblock_stream(*this, stream->id()); | ||
| } | ||
|
|
||
| void ExtendMaxData(uint64_t max_data) override { | ||
| Debug(&session(), | ||
| "HTTP/3 application extending max data to %" PRIu64, | ||
| max_data); | ||
| for (auto& [id, stream] : session().streams()) { | ||
| stream->UpdateWriteDesiredSize(); // the stream might be blocked | ||
| // on js side, is unblock stream also required? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you looking for an answer to this in this PR or is this more of a follow up?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it is more like a hint, where to look, if we experience other stalls. Currently, the test indicate that unblock in this pattern is not required. |
||
| } | ||
| } | ||
|
|
||
| void CollectSessionTicketAppData( | ||
| SessionTicket::AppData* app_data) const override { | ||
| uint8_t buf[kSessionTicketAppDataSize]; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about a non-H3 test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above, I am not able to trigger sth. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Flags: --experimental-quic --experimental-stream-iter --no-warnings | ||
|
|
||
| // Test: Quic maxdata updates on http/3 | ||
| // Client sends a body that precisely fills the session window size, | ||
| // and verifies that it is data transfer is not stalled. | ||
|
|
||
| import { hasQuic, skip } from '../common/index.mjs'; | ||
| import { readFile } from 'node:fs/promises'; | ||
| import { setTimeout as sleep } from 'node:timers/promises'; | ||
|
|
||
| if (!hasQuic) { | ||
| skip('QUIC is not enabled'); | ||
| } | ||
| const { listen, connect } = await import('node:quic'); | ||
| const { createPrivateKey } = await import('node:crypto'); | ||
| const { drainableProtocol } = await import('stream/iter'); | ||
|
|
||
| const keys = 'test/fixtures/keys'; | ||
| const key = createPrivateKey(await readFile(`${keys}/agent1-key.pem`)); | ||
| const cert = await readFile(`${keys}/agent1-cert.pem`); | ||
|
|
||
| const WINDOW = 4096; | ||
| // Fills the window exactly: | ||
| // considers all framing including some initial session capsules | ||
| const BODY = WINDOW - 38; | ||
|
|
||
| let letServerRead; | ||
| const serverMayRead = new Promise((resolve) => { letServerRead = resolve; }); | ||
|
|
||
| const endpoint = await listen((session) => { | ||
| session.onstream = async (stream) => { | ||
| await serverMayRead; | ||
| // eslint-disable-next-line no-unused-vars | ||
| for await (const _ of stream) { /* reading extends the window */ } | ||
| }; | ||
| }, { | ||
| sni: { '*': { keys: [key], certs: [cert] } }, | ||
| transportParams: { | ||
| initialMaxStreamDataBidiRemote: 1024 * 1024, // Make sure maxstreamdata does not block | ||
| initialMaxData: WINDOW, | ||
| }, | ||
| onheaders() { this.sendHeaders({ ':status': '200' }); }, | ||
| }); | ||
|
|
||
| const session = await connect(endpoint.address, { | ||
| servername: 'localhost', | ||
| verifyPeer: 'manual', | ||
| }); | ||
| await session.opened; | ||
|
|
||
| // Budget well above the window, so the window is what stops the writer. | ||
| const stream = await session.createBidirectionalStream({ budget: 1024 * 1024 }); | ||
| stream.sendHeaders({ | ||
| ':method': 'POST', | ||
| ':path': '/', | ||
| ':scheme': 'https', | ||
| ':authority': 'localhost', | ||
| }, { terminal: false }); | ||
|
|
||
| const writer = stream.writer; | ||
| writer.writeSync(new Uint8Array(BODY)); | ||
|
|
||
| // Long enough for every byte to be acked. The peer acks as data arrives, | ||
| // whether or not its application has read any of it, so by now the window is | ||
| // exhausted, the send buffer is empty, and no further ACK can arrive. | ||
| await sleep(500); | ||
|
|
||
| const watchdog = setTimeout(() => { | ||
| console.error('STALLED: no drain after MAX_STREAM_DATA'); | ||
| process.exit(1); | ||
| }, 5000); | ||
| letServerRead(); // Extend the window, with no ack attached | ||
| await writer[drainableProtocol](); | ||
|
|
||
| clearTimeout(watchdog); | ||
| process.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to update the stream size here like you do in
http3.cc?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Waiting of the upstream update took a long time, so it is hard to remember. I remember, that I had this change and that the mechanics of http/3 and non http/3 was different. I will try to write a test for this case, and see if it is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it, at least with the test, I could not provoke it. I copied the test for http/3, added an alpn, and used the full window size as we have no framing in non http/3. I think the difference is that no lib is inbetween and another trigger is causing, that writeDesiredSize is updated. But I am pretty sure, I have looked more into it when I wrote the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it may be the full window size is not the correct trigger. Do we have other traffic I need to include? I ask @pimterry , who provided the initial test for the related streammaxdata bug.