Skip to content

Conversation

@xoiss
Copy link
Contributor

@xoiss xoiss commented Jun 23, 2019

When I call zookeeper_close() while there is a pending multi request, I expect the request completes with ZCLOSING status.

But with the existing code I actually get the following:

  • the program exits with SIGABRT from assert(entry) in deserialize_multi()
  • and even if I remove this assertion and just break the enclosing loop, the returned status is ZOK but not ZCLOSING

So, there are two defects with processing calls to zookeeper_close() for pending multi requests: improper assertion in implementation and invalid status in confirmation.

Proposed changes remove these defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2891

@xoiss
Copy link
Contributor Author

xoiss commented Jun 23, 2019

Hello!

This is a reworked/updated/improved PR.

The previous one: #360

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Thos change makes sense to me.

I do not have so much experience with c client, so I can't say we are covering all of the aspects of this problem.

As said in another PR we should add a test to demonstrate the problem and verify that we have fixed it.

I will let other reviewers tell their opinion

Thanks

@xoiss xoiss force-pushed the ZOOKEEPER-2891 branch from dd81c39 to 2053f56 Compare July 2, 2019 13:38
@xoiss
Copy link
Contributor Author

xoiss commented Jul 2, 2019

add a test to demonstrate the problem and verify that we have fixed it

Done!

I have provided two tests:

  • testCloseWhileMultiInProgressFromMain
  • testCloseWhileMultiInProgressFromCompletion

The reason to have namely two tests is about the same as for ZOOKEEPER-2894 (see #1000). So, it's just two subcases of the same problem.

Note: Right now, the first test of two is temporarily disabled because it requires fixes from ZOOKEEPER-2894. When it's merged, I'll rebase this PR and enable this test.

Ok, BEFORE this patch both tests fail with src/zookeeper.c:2033: deserialize_multi: Assertion 'entry' failed (for the first test, assuming ZOOKEEPER-2894 is already merged, otherwise it fails with completion lost).

And after the patch both tests pass successfully (again, for the first test, assuming ZOOKEEPER-2894 is already merged).


Can you explain why this is the right point to exit the loop and the method?

What is the alternative??
Please, read this: https://issues.apache.org/jira/browse/ZOOKEEPER-2891
I have revised it again now, and indeed, I don't have more detailed explanation.
The best is try to reproduce this under debugger. You may use unit-tests published here.
If you still have questions, please, formulate more specific question, or a use-case (scenario) that I can reproduce.

To my eyes, it is cleaner to have rc_hint == ZOK as a conditional on the while statement or perhaps a return rc down a few lines where it is set on error.

If we put rc_hint == ZOK directly into the while-conditional-expression then we have to put there also (1) assignment of entry and (2) analyzing the value assigned to entry -- i.e., two code lines: completion_list_t *entry = dequeue_completion(clist); and if (entry == NULL). Note also that entry is a local variable of the while-loop-body, and C99 does not allow local variable declarations right in the while-expression.
So, due to this, it's better to keep things at there original places. I understand that having additional loop-termination point is not good enough, but sometimes it's a kinda tradeoff. I wish to keep things as close to the code-before-patch as possible, to minimize the diff.

Could we also return immediately from the method is rc_hint is not 0?

Currently 'yes', because there is nothing between the while-loop-body-end and the final return statement. But there is no lifetime warranty that nothing would be put here between them.
Actually, I prefer break here because it performs the minimum of the necessary work -- I'm talking about the "Necessity and Sufficiency" -- here return is sufficient, but much more than necessary.

@xoiss xoiss force-pushed the ZOOKEEPER-2891 branch from 2053f56 to a266fa8 Compare July 2, 2019 16:21
@xoiss
Copy link
Contributor Author

xoiss commented Jul 2, 2019

rebased on 4a5d596
ZOOKEEPER-3389: Zookeeper does not export all required packages in OSGi (for Curator)

@xoiss xoiss force-pushed the ZOOKEEPER-2891 branch 2 times, most recently from 1711b07 to e2b1cd7 Compare July 11, 2019 08:20
@xoiss
Copy link
Contributor Author

xoiss commented Jul 11, 2019

  1. Rebased on the result of merging ZOOKEEPER-2894
  2. Enabled testCloseWhileMultiInProgressFromMain that required ZOOKEEPER-2894

@xoiss
Copy link
Contributor Author

xoiss commented Jul 11, 2019

@phunt @anmolnar @eolivelli @hanm

Hello!

It looks, I'm ready with this patch too.
So, you may revise it.

But I have three questions:

  1. How can I see the results of ZooKeeper C Client unit-tests run? Are the unit-tests run indeed? I suspect, No, because I don't see them in the log: https://travis-ci.org/apache/zookeeper/jobs/557205041#L1
  2. What happened with Jenkins? It's not listed in the precommit checks.
  3. Last time UTs run by Jenkins failed to pass testCloseWhileMultiInProgressFromCompletion with strange error probably related to function-stack-frame overflow. I didn't succeed in reproducing it on my desktop. And now I just can't see if the problem still exists. This is the last report I'm talking:
     [exec]      [exec] Zookeeper_operations::testCloseWhileMultiInProgressFromCompletionMakefile:1909: recipe for target 'run-check' failed
     [exec]      [exec] *** stack smashing detected ***: ./zktest-st terminated

https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/4058/console

Thank you!

@xoiss xoiss force-pushed the ZOOKEEPER-2891 branch 2 times, most recently from bc321e7 to 707aa4e Compare July 29, 2019 13:12
@xoiss
Copy link
Contributor Author

xoiss commented Jul 29, 2019

Rebased on
commit c056703
Author: Patrick Hunt phunt@apache.org 2019-07-12 08:32:42
Committer: Enrico Olivelli eolivelli@apache.org 2019-07-13 09:45:14
ZOOKEEPER-3441: OWASP is flagging jackson-databind-2.9.9.jar for CVE-…

@xoiss xoiss force-pushed the ZOOKEEPER-2891 branch 2 times, most recently from 14185de to 1e47602 Compare July 29, 2019 14:41
@xoiss
Copy link
Contributor Author

xoiss commented Jul 29, 2019

Resolved "stack smashing detected" in Zookeeper_operations::testCloseWhileMultiInProgressFromCompletionMakefile

// the reason was locally allocated zoo_op_result_t

Now it works fine.


What happened with junit tests?
Some of them failed, and due to this cppunit-test do not start in Jenkins.
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/4083/consoleFull

@phunt @anmolnar @eolivelli @hanm

@xoiss
Copy link
Contributor Author

xoiss commented Jul 30, 2019

... hmmm, maybe it's better to wait for #1030

asfgit pushed a commit that referenced this pull request Aug 1, 2019
This is a backport of #717 to `branch-3.4`

For some reason it was NOT merged to `branch-3.4`, but only to `branch-3.5` and `master`:
- 4bd32be
- b1fd480

Here, it's almost a cherry-pick of the original patch, but slightly adopted to specific of `branch-3.4`.
Namely, `cleanup_failed_multi()` and `deserialize_multi()` do not have the first parameter `zhandle_t *zh`.

----

I wish to backport this also to use it as the base for my #999

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Andor Molnár <andor@apache.org>, Michael Han <hanm@apache.org>

Closes #1030 from xoiss/ZOOKEEPER-1636
@anmolnar
Copy link
Contributor

anmolnar commented Aug 2, 2019

@xoiss #1030 merged. Please rebase this one.

@xoiss
Copy link
Contributor Author

xoiss commented Aug 2, 2019

@xoiss #1030 merged. Please rebase this one.

rebased


Hello!

As it turned out, #1030, #717 (ZOOKEEPER-1636) is 100% enough to close ZOOKEEPER-2891 also.

And as soon as #1030, #717 cover the more common case (general "unsuccessful status", but not only ZCLOSING), and #717 is already in the master -- surely, I would prefer to withdraw my solution in this PR in flavour of that one in #1030 #717.

// Many thanks to @mkedwards for his idea given in #717 !

Hence, there are two unit-tests proposed in this PR. If you wish, we can merge them into branch-3.4, branch-3.5 and master. If it's necessary, I can open a dedicated PR for them. What do you think?

// I've edited this PR. Namely, I've removed patches to the Client code, but left only two unit-tests. So, this PR now contains only unit-tests.

@xoiss
Copy link
Contributor Author

xoiss commented Aug 5, 2019

^ up

@phunt @anmolnar @eolivelli @hanm

asfgit pushed a commit that referenced this pull request Aug 5, 2019
When I call `zookeeper_close()` while there is a pending multi request, I expect the request completes with `ZCLOSING` status.

But with the existing code I actually get the following:
* the program exits with `SIGABRT` from `assert(entry)` in `deserialize_multi()`
* and even if I remove this assertion and just break the enclosing loop, the returned status is `ZOK` but not `ZCLOSING`

So, there are two defects with processing calls to `zookeeper_close()` for pending multi requests: improper assertion in implementation and invalid status in confirmation.

Proposed changes remove these defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2891

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Michael Han <hanm@apache.org>

Closes #999 from xoiss/ZOOKEEPER-2891
@hanm
Copy link
Contributor

hanm commented Aug 6, 2019

merged to 3.4. Please close the pr @xoiss

@anmolnar
Copy link
Contributor

anmolnar commented Aug 6, 2019

I can close it. Thanks @hanm @xoiss !

@anmolnar anmolnar closed this Aug 6, 2019
@xoiss
Copy link
Contributor Author

xoiss commented Aug 6, 2019

Thank you!

But, why not to cherry pick these to branch-3.5 and master also?

@anmolnar @hanm

@anmolnar
Copy link
Contributor

anmolnar commented Aug 6, 2019

@xoiss I haven't noticed that this one targets 3.4, sorry. The usual way of contributions is to create patch for master first that we can cherry-pick to other branches, not the other way around. Let me take care of this.

asfgit pushed a commit that referenced this pull request Aug 6, 2019
When I call `zookeeper_close()` while there is a pending multi request, I expect the request completes with `ZCLOSING` status.

But with the existing code I actually get the following:
* the program exits with `SIGABRT` from `assert(entry)` in `deserialize_multi()`
* and even if I remove this assertion and just break the enclosing loop, the returned status is `ZOK` but not `ZCLOSING`

So, there are two defects with processing calls to `zookeeper_close()` for pending multi requests: improper assertion in implementation and invalid status in confirmation.

Proposed changes remove these defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2891

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Michael Han <hanm@apache.org>

Closes #999 from xoiss/ZOOKEEPER-2891
@anmolnar
Copy link
Contributor

anmolnar commented Aug 6, 2019

Cherry-picked to master and 3.5 branches.

mapr-devops pushed a commit to mapr/zookeeper that referenced this pull request Aug 6, 2019
When I call `zookeeper_close()` while there is a pending multi request, I expect the request completes with `ZCLOSING` status.

But with the existing code I actually get the following:
* the program exits with `SIGABRT` from `assert(entry)` in `deserialize_multi()`
* and even if I remove this assertion and just break the enclosing loop, the returned status is `ZOK` but not `ZCLOSING`

So, there are two defects with processing calls to `zookeeper_close()` for pending multi requests: improper assertion in implementation and invalid status in confirmation.

Proposed changes remove these defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2891

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Michael Han <hanm@apache.org>

Closes apache#999 from xoiss/ZOOKEEPER-2891
@xoiss
Copy link
Contributor Author

xoiss commented Aug 8, 2019

... is to create patch for master first ...

Yes, I've got it.


Ok, with this commit, it's the whole amount of patches I had.
Thank you a lot friends!!

@anmolnar
Copy link
Contributor

anmolnar commented Aug 8, 2019

@xoiss Thanks for the contribution.

stickyhipp pushed a commit to stickyhipp/zookeeper that referenced this pull request Aug 19, 2020
When I call `zookeeper_close()` while there is a pending multi request, I expect the request completes with `ZCLOSING` status.

But with the existing code I actually get the following:
* the program exits with `SIGABRT` from `assert(entry)` in `deserialize_multi()`
* and even if I remove this assertion and just break the enclosing loop, the returned status is `ZOK` but not `ZCLOSING`

So, there are two defects with processing calls to `zookeeper_close()` for pending multi requests: improper assertion in implementation and invalid status in confirmation.

Proposed changes remove these defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2891

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Michael Han <hanm@apache.org>

Closes apache#999 from xoiss/ZOOKEEPER-2891
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
When I call `zookeeper_close()` while there is a pending multi request, I expect the request completes with `ZCLOSING` status.

But with the existing code I actually get the following:
* the program exits with `SIGABRT` from `assert(entry)` in `deserialize_multi()`
* and even if I remove this assertion and just break the enclosing loop, the returned status is `ZOK` but not `ZCLOSING`

So, there are two defects with processing calls to `zookeeper_close()` for pending multi requests: improper assertion in implementation and invalid status in confirmation.

Proposed changes remove these defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2891

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Michael Han <hanm@apache.org>

Closes apache#999 from xoiss/ZOOKEEPER-2891
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Sep 3, 2022
When I call `zookeeper_close()` while there is a pending multi request, I expect the request completes with `ZCLOSING` status.

But with the existing code I actually get the following:
* the program exits with `SIGABRT` from `assert(entry)` in `deserialize_multi()`
* and even if I remove this assertion and just break the enclosing loop, the returned status is `ZOK` but not `ZCLOSING`

So, there are two defects with processing calls to `zookeeper_close()` for pending multi requests: improper assertion in implementation and invalid status in confirmation.

Proposed changes remove these defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2891

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Michael Han <hanm@apache.org>

Closes apache#999 from xoiss/ZOOKEEPER-2891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants