| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
cc @nodejs/crypto |
Sorry, something went wrong.
|
@bnoordhuis : let's review it anyway, even without @EricTheOne's feedback the fix that it does is still relevant |
Sorry, something went wrong.
There was a problem hiding this comment.
Totally a noob question. Why are we not implementing this with an array instead of this complex enqueue and dequeue logic?
Sorry, something went wrong.
There was a problem hiding this comment.
Is queue supposed to be accessed directly from outside of the class?
Should it be prefixed or not?
Sorry, something went wrong.
There was a problem hiding this comment.
@thefourtheye because I'd like to avoid lookup cost when removing elements from it
@ChALkeR Should be prefixed, thanks.
Sorry, something went wrong.
There was a problem hiding this comment.
@indutny I am trying to understand this better. Theoretically, there will be no lookup in a queue, the first-in will be dequeued, right? If we are going to arbitrarily remove, then why not a Map?
Sorry, something went wrong.
There was a problem hiding this comment.
@thefourtheye there is no promise of FIFO here, and I like linked lists pretty much :)
Sorry, something went wrong.
There was a problem hiding this comment.
@ChALkeR fixed
Sorry, something went wrong.
|
cc @trevnorris @shigeki @bnoordhuis @chrisdickinson maybe? Let's land this thing! |
Sorry, something went wrong.
|
@indutny this really seems to fix the original issue - no more segfaults and no more runaway memory allocations, thank you very much! I've been running my server for a while, and found a few errors which I haven't seen before: TypeError: Cannot read property 'start' of null
at TLSSocket._start (_tls_wrap.js:550:15)
at TLSSocket.<anonymous> (_tls_wrap.js:542:12)
at TLSSocket.g (events.js:260:16)
at emitNone (events.js:72:20)
at TLSSocket.emit (events.js:166:7)
at Socket.<anonymous> (_tls_wrap.js:432:12)
at Socket.g (events.js:260:16)
at emitNone (events.js:67:13)
at Socket.emit (events.js:166:7)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1029:10)
TypeError: Cannot read property 'start' of null
at TLSSocket._start (_tls_wrap.js:550:15)
at TLSSocket.<anonymous> (_tls_wrap.js:542:12)
at TLSSocket.g (events.js:260:16)
at emitNone (events.js:72:20)
TypeError: immediate._onImmediate is not a function
at processImmediate (timers.js:371:17)
at doNTCallback0 (node.js:408:9)
at process._tickCallback (node.js:337:13)
at Socket.<anonymous> (_stream_wrap.js:41:20)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:145:16)
at Socket.Readable.push (_stream_readable.js:109:10)
at TCP.onread (net.js:519:20)
TypeError: immediate._onImmediate is not a function
at processImmediate (timers.js:371:17)
at doNTCallback0 (node.js:408:9)
at process._tickCallback (node.js:337:13)
Error: read EINVAL
at exports._errnoException (util.js:838:11)
at StreamWrap.Socket._read (net.js:391:21)
at StreamWrap.Readable.read (_stream_readable.js:324:10)
at StreamWrap.Socket.read (net.js:280:43)
at StreamWrap.Socket (net.js:166:12)
at new StreamWrap (_stream_wrap.js:51:10)
at new TLSSocket (_tls_wrap.js:233:12)
at Object.exports.connect (_tls_wrap.js:913:16)
Maybe it's in my code, but I don't see it in the stack traces. The patch was applied over master (0f68377) |
Sorry, something went wrong.
There was a problem hiding this comment.
Can we const these, as we don't reassign anything to them?
Sorry, something went wrong.
There was a problem hiding this comment.
Sure.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
|
Patch looks good. I'd have to give it a closer look, but don't let that hold up merging it if more devs sign off before then. |
Sorry, something went wrong.
|
Fixed the first problem, please take a look @EricTheOne |
Sorry, something went wrong.
|
@indutny thanks, the original onImmediate issue seemed to be due to my code (passed a function() instead of function in to setImmediate). TypeError: Cannot read property 'finishShutdown' of null
at Immediate._onImmediate (_stream_wrap.js:86:19)
at processImmediate [as _immediateCallback] (timers.js:371:17)
Seems to be due to _handle being null in _stream_wrap.js: StreamWrap.prototype.shutdown = function shutdown(req) {
const self = this;
this.stream.end(function() {
// Ensure that write was dispatched
setImmediate(function() {
self._handle.finishShutdown(req, 0);
});
});
return 0;
};
|
Sorry, something went wrong.
|
@indutny two more issues found, in addition to finishShutdown error: ../deps/uv/src/unix/stream.c:1489: uv_read_start: Assertion `((stream)->io_watcher.fd) >= 0' failed. Error: read EINVAL
at exports._errnoException (util.js:839:11)
at StreamWrap.Socket._read (net.js:392:21)
at StreamWrap.Readable.read (_stream_readable.js:325:10)
at StreamWrap.Socket.read (net.js:281:43)
at StreamWrap.Socket (net.js:167:12)
at new StreamWrap (_stream_wrap.js:52:10)
at new TLSSocket (_tls_wrap.js:234:12)
at Object.exports.connect (_tls_wrap.js:938:16)
...
By far the most frequent is the finishShutdown error, second to it is EINVAL, and last is the assertion. |
Sorry, something went wrong.
|
@indutny is there any more info I can extract to help with the above three issues? |
Sorry, something went wrong.
|
Fixed finishShutdown error, looking at the rest. |
Sorry, something went wrong.
|
@EricTheOne hopefully fixed the last ones two, thank you for reporting them! Please give it a try ;) |
Sorry, something went wrong.
|
@indutny this is excellent news! I applied the pull request over v2.3.1 and ran the server twice. The first thing to notice is that the server behaves much better:
We're very close to resolving this, however two issues still appear:
They happen at roughly the same time (less than 20 seconds apart) and then the server crashes. I use multiple processes so the errors may come from different child processes. I may have a clue - visually inspecting the logs, it seems that the two errors and a memory leak appear on reconnects. Especially I notice a lot of reconnects due to timeouts. I generally dispose of the sockets and create new ones. There is no kernel socket leak. |
Sorry, something went wrong.
|
@EricTheOne may I ask you to provide a fresh stack trace for EINVAL? (Maybe both of read/write?) |
Sorry, something went wrong.
|
@EricTheOne pushed one more fix, hope it helps |
Sorry, something went wrong.
|
@indutny with some more testing I found another issue (causing a crash). Not related to the latest commit (cb4a005): ../src/node_crypto.cc:2283: node::crypto::CheckResult node::crypto::CheckWhitelistedServerCert(X509_STORE_CTX*): Assertion `(root_cert) != (nullptr)' failed. |
Sorry, something went wrong.
|
@EricTheOne Could you try the latest HEAD of master? I bleave it was fixed in #2064. |
Sorry, something went wrong.
|
@shigeki thanks, checking now, so far seems stable |
Sorry, something went wrong.
|
@shigeki @indutny #2064 indeed fixes the assertion, thanks. @indutny I have reduced the rate of reconnects on the server, and neither of the two errors happen even without cb4a005. It seems like cause was either a race condition or incorrect handling of edge cases. From my point of view this work solves the original issues and does not introduce new ones, hence I'd like to see it merged. |
Sorry, something went wrong.
|
cc @trevnorris please do one more pass over it. @shigeki may I ask you to take a look too? |
Sorry, something went wrong.
Queued write requests should be invoked on handle close, otherwise the "consumer" might be already destroyed when the write callbacks of the "consumed" handle will be invoked. Fix: nodejs#1696
Sorry, something went wrong.
There was a problem hiding this comment.
nit: throw in a comment on why the setImmediate() is necessary. future proofing for new devs. :)
Sorry, something went wrong.
There was a problem hiding this comment.
Actually, let's drop it out, and revert it back only in case of any troubles. I no longer think that it might be reasonable. (@EricTheOne: I hope you don't mind)
Sorry, something went wrong.
There was a problem hiding this comment.
@indutny I don't understand the code enough to comment on the code level, but I'll retest the final version and let you know if anything new comes up.
btw just to further my understanding, why would setImmediate be resolving possible troubles there?
Sorry, something went wrong.
|
Left comments about cosmetic stuff, but LGTM. |
Sorry, something went wrong.
Queued write requests should be invoked on handle close, otherwise the "consumer" might be already destroyed when the write callbacks of the "consumed" handle will be invoked. Same applies to the shutdown requests. Make sure to "move" away socket from server to not break the `connections` counter in `net.js`. Otherwise it might not call `close` callback, or call it too early. Fix: #1696 PR-URL: #1910 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
|
Landed in 9180140, thank you! (Decided to squash everything into one commit, because I forgot what this hotfixes belonged too) |
Sorry, something went wrong.
|
@indutny thanks, I'll retest with master as soon as possible. |
Sorry, something went wrong.
Queued write requests should be invoked on handle close, otherwise the "consumer" might be already destroyed when the write callbacks of the "consumed" handle will be invoked. Same applies to the shutdown requests. Make sure to "move" away socket from server to not break the `connections` counter in `net.js`. Otherwise it might not call `close` callback, or call it too early. Fix: nodejs#1696 PR-URL: nodejs#1910 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
| Back | FazBrowse Home | New Git URL |
Queued write requests should be invoked on handle close, otherwise the
"consumer" might be already destroyed when the write callbacks of the
"consumed" handle will be invoked.
Fix: #1696
cc @EricTheOne