Skip to content
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

HPCC-19323 Poll() to handle EINTR consistently #10973

Merged
merged 1 commit into from May 11, 2018

Conversation

mckellyln
Copy link
Contributor

Add EINTR handling in a few places where poll() could return < 0

Signed-off-by: Mark Kelly mark.kelly@lexisnexisrisk.com

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Testing:

Full QA suite passes as expected

@hpcc-jirabot
Copy link

@mckellyln
Copy link
Contributor Author

mckellyln commented Mar 16, 2018

@jakesmith please review.

@@ -1279,7 +1279,12 @@ bool CSocket::connect_timeout( unsigned timeout, bool noexception)
else if (rc<0)
{
err = ERRNO();
LOGERR2(err,2,"::select/poll");
if (err != JSE_INTR)
Copy link
Member

Choose a reason for hiding this comment

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

Would it useful if EINTR event is logged as well? Do we expect them/often?

@@ -1413,8 +1418,11 @@ void CSocket::connect_wait(unsigned timems)
if (rc<0)
{
err = ERRNO();
LOGERR2(err,2,"::select/poll");
break;
if (err != JSE_INTR)
Copy link
Member

Choose a reason for hiding this comment

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

Would it useful if EINTR event is logged as well? Do we expect them/often?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say generally EINTR events are not worth logging as the code should handle them properly - but then there are some other places in the code where EINTR is logged.

sock->errclose();
isopen = false;
if (!oneshot)
connectimedout = true; // to force same behavior as before
Copy link
Member

Choose a reason for hiding this comment

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

I may be missing something.. how is this same behaviour as before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before it would loop until timed out and then connectimedout would be true. If we break out here early then set it to true to have same return behaviour.

Copy link
Member

Choose a reason for hiding this comment

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

I could understand the change I think if it was:

    if (oneshot) 
        connecttimedout = true;

but with oneshot == false, it's supposed to loop and retry pre_connect afaics.

isopen = false;
if (!oneshot)
connectimedout = true; // to force same behavior as before
break;
Copy link
Member

Choose a reason for hiding this comment

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

Is it right to unconditional break out here?
The other if oneshot is false code looks like it's designed to handle the error and try again (as long as within the timeout period).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Debatable, but we poll()ed for timeout duration and if poll() failed with something other than EINTR then hard to see why to keep trying until timeout.

Copy link
Member

Choose a reason for hiding this comment

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

right, there's no way ::select might have exited before the timeout given to it?

And if not, isn't this just as true (if not more so) when oneshot==true, i.e. shouldn't it set connectimedout = true above either way?

I think the comment '// to force same behavior as before' should be removed or change. It won't be helpful to anyone reading the code. Could instead comment why that is' existing because it must be here because waited 'timeout' in ::select above.

@jakesmith
Copy link
Member

@mckellyln - a couple of questions.

@mckellyln
Copy link
Contributor Author

@jakesmith thanks, I replied with some answers/comments.

@jakesmith
Copy link
Member

@mckellyln - forgot to tag.

@mckellyln
Copy link
Contributor Author

@jakesmith rebased to latest master and removed the comment (// to force same behavior)
My point is that if oneshot is true then connectimedout would not become true, so if there was an error the routine would return NULL instead of throwing and I am trying to keep the same return behavior as that.
The other point about returning before the timeout is reached is more complicated. If the select() or poll() returned > 0 and the getsockopt() returned an error then in some cases yes we should continue to loop, as it does. But if the select() or poll() returns an error (-1) then I don't think we need to continue looping until the timeout is reached.

@jakesmith
Copy link
Member

@mckellyln - it looks fine, can't see any issues.

@richardkchapman - ready to merge.

@richardkchapman
Copy link
Member

@mckellyln Please squash

Signed-off-by: Mark Kelly <mark.kelly@lexisnexisrisk.com>
@mckellyln
Copy link
Contributor Author

@richardkchapman rebased and squashed

@HPCCSmoketest
Copy link
Contributor

Automated Smoketest: ✅
OS: centos 7.2.1511 (Linux 3.10.0-327.28.3.el7.x86_64)
Sha: 7212f11
Build: success
Install hpccsystems-platform-community_6.5.0-trunk0.el7.x86_64.rpm
HPCC Start: OK

Unit tests result:

Test total passed failed errors timeout
unittest 88 88 0 0 0
wutoolTest(Dali) 19 19 0 0 0
wutoolTest(Cassandra) 19 19 0 0 0

Regression test result:

phase total pass fail
setup (hthor) 11 11 0
setup (thor) 11 11 0
setup (roxie) 11 11 0
test (hthor) 784 784 0
test (thor) 715 715 0
test (roxie) 828 828 0

HPCC Stop: OK
HPCC Uninstall: OK
Time stats:

Prep time Build time Package time Install time Start time Test time Stop time Summary
33 sec (00:00:33) 171 sec (00:02:51) 59 sec (00:00:59) 7 sec (00:00:07) 28 sec (00:00:28) 1185 sec (00:19:45) 19 sec (00:00:19) 1502 sec (00:25:02)

@richardkchapman richardkchapman merged commit c7f6673 into hpcc-systems:master May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants