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
#7476 fix logic and syntax of queue fully_acked method #7524
Conversation
Thanks @original-brownbear for looking into this. The fix for the For the Also, won't that break this condition here where a new head page will be then considered fully acked and immediately transformed into a tail page? logstash/logstash-core/src/main/java/org/logstash/ackedqueue/Queue.java Lines 335 to 340 in b3b9e60
|
@colinsurprenant npnp :)
I'd go with yes on this one, because "nothing is unacknowledged" must mean "fully acknowledged".
Counter question :) Why does an empty page fail the free space check wrapping that logic?
if (! this.headPage.hasSpace(data.length)) { |
Interesting - yeah empty set algebra is weird. So both "all elements are acknowledged" and "all elements are unacknowledged" would be true at the same time on an empty set. Maybe we should probably rename that method to reflect the initial intention of looking for all elements on a non empty queue?
I'll let you look into this - seems important to figure before merging. |
+1 in general, it would be less confusing. What I really don't like about it is that we have to negate every call to it we make at the moment, which really messes up the git history. Not sure we want to do that while we fix a bug?
Yea we aren't asking if all elements are unacknowledged anywhere in our code, this seems like a metaphysics question. If we would ask both questions, we should probably just throw on a call to this method for an empty page and gate all use cases by a |
Agree. Can I then suggest you change the for the
Oh, totally :P it was just to illustrate the empty set algebra metaphysical confusion. |
But then we add 2 synchronized Ruby to Java calls + we don't have any empty check implemented in the Queue. Do we really want to add another method to |
I am just pointing out the potential problem of changing the semantic of |
I don't think we want to do that, at least with my understanding of PQ. If the PQ says that "there is nothing else to process", shouldn't that mean that all reads from the Queue were acknowledged? Otherwise restarting LS may lead to repeated processing (not that it will in practice probably), but that's what this change would make possible as an accidental side effect of changing pipeline code. |
Oh, I meant to somehow move the check |
@colinsurprenant Yes, but would have to then lock over the two operations since they're not atomic: Plus, you'd have to add a new Also our count methods are currently not neither synchronized nor atomic public long getAckedCount() {
return headPage.ackedSeqNums.cardinality() + tailPages.stream()
.mapToLong(page -> page.ackedSeqNums.cardinality())
.sum();
}
public long getUnackedCount() {
long headPageCount = (headPage.getElementCount() - headPage.ackedSeqNums.cardinality());
long tailPagesCount = tailPages.stream()
.mapToLong(page -> (page.getElementCount() - page.ackedSeqNums.cardinality())).sum();
return headPageCount + tailPagesCount;
} and hence not correct when called without holding I don't think I can do this kind of thing (count calls in a concurrent situation) without a bunch of potential issues. |
Ok. But adding the check into |
@colinsurprenant idk man :), we only use that function in 4 production code spots. Do we really want to add more tech debt here, when we already have a bug that resulted from undocumented/inconsistent behavior? |
@colinsurprenant also note that all tests still pass + one more that reproduced a bug. Maybe you can suggest some tests we could add to rule out potential problems you see? Better to invest the time into that compared to investing it into hacks? |
We don't really have deadlines for code in most cases. If a change is not ready when a release is cut, then that change can go into the next release. |
again my concern is to minimize the risk of introducing a change that could potentially have a unwanted side-effect. We have essentially 3 choices:
I am ok with any of these. Since you introduced this PR I'll let you choose what you prefer. |
@jordansissel so how does that tie in with the specific issue here? I mean if something fixes a failing test, but passes all tests and we have no deadline it seems wrong to add tech debt instead of it on the grounds of avoiding the risk of introducing bugs? |
sure let's do this, as I asked above, what tests would prove this? |
oh, and BTW, passing tests is only an indication and not a proof that a code change is correct. |
@colinsurprenant I don't think we'll achieve algorithmic prove in this code, tests will have to do? :D |
Not sure - haven't looked into that really. Do you want to do it? |
happy to, but I need an actionable goal, I'd like to avoid this one going stale like #6998 sorry :) |
not sure what is missing here? I will try to recap my concern: you are changing the behaviour of |
Yes but I need some clear cut scenario you want to see a test for/verified to work. Otherwise I'll have to take a guess here and we'll keep going in circles if I'm wrong :( |
@original-brownbear I think there is a misunderstanding on our respective roles here. You took the initiative to write this code to propose a fix. As the reviewer I am pointing at a possible issue. I am expecting you will try to receive that comment as something constructive toward improving that code and look into it and possibly propose solutions. I don't think you need any more clear cut scenarios and I am sure you can apply the same level of initiative to work toward improving this. If I knew exactly what the problem was, how to solve it and what tests are missing I would have said it already. For me to get to that point would require I spend more time digging into this. Since this is your code change proposal I am expecting you will move it forward while trying to honestly consider any reviewer comment that are made here. As I said there are many ways this can move forward, be it a temp fix with possible tech debt, a bigger refactor, further investigation into a potential extra bug in the free space method, etc. There is no right or wrong. |
@colinsurprenant I get you point really :) but look:
So is there even an actionable bug/issue here at all, if there isn't one how would I prove there isn't? |
Okay. I'll circle back to try and move this to some closure at some point. |
@suyograo fixed just the syntax and removed the test and will assign @colinsurprenant to the actual issue then as discussed. |
LGTM - this will solve the first part of #7568. |
Fixes #7476
wrapped_acked_queue.rb