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

KAFKA-5054 : synchronized all the methods #5873

Closed
wants to merge 1 commit into from

Conversation

lijubjohn
Copy link
Contributor

This avoids inconsistent results while querying or storing the underlying storage

@lijubjohn lijubjohn changed the title synchronized all the methods KAFKA-5054 : synchronized all the methods Nov 2, 2018
Copy link
Contributor

@viktorsomogyi viktorsomogyi left a comment

Choose a reason for hiding this comment

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

@lijubjohn if you don't mind I reviewed it: it looks fine.
To be a bit more elaborate: from a bit higher level though I think it that while this is a good tactical fix we might want to measure performance impact (if these are frequently used methods) and maybe come up with a better design where synchronization is implicit such as immutable LoggedStateChange classes which would make sure that logging and storing the change are done atomicly.

@mjsax mjsax added the streams label Nov 6, 2018
@mjsax
Copy link
Member

mjsax commented Nov 6, 2018

Thanks for the PR @lijubjohn -- I was reading the ticket, but I am not sure if I fully understand the issue to be honest. The ticket mentions IQ and that putIfAbsent and delete do two operation -- however, IQ only allows read access anyway, and thus I don't understand.

@dguy You created the original ticket. Can you help out here?

Also, for IQ we actually synchronized store access state store level (ie, RocksDBStore and InMemoryKeyValueStore already.

@guozhangwang
Copy link
Contributor

@mjsax @lijubjohn I think here is the issue @dguy reported:

Consider the putIfAbsent call:

        final byte[] previous = get(key);  // 1
        if (previous == null) {                    // 2
            put(key, value);
        }
        return previous;

It is possible that a concurrent get call is triggered between 1 and 2. The IQ query will return none while at the end it the key will have some values instead; similar situations for delete.

But thinking about this, this could be just treated as "the IQ get call was triggered before the putIfAbsent", since we do not guarantee strict time-ordering for such concurrent operations anyways. So I think we do not necessarily need to fix the JIRA.

@guozhangwang
Copy link
Contributor

@mjsax if you agree we can close the JIRA as not a bug.

@mjsax
Copy link
Member

mjsax commented Nov 17, 2018

I agree with this. The result must be the same as an serial execution (not specified with one), and this seems to be guaranteed as you pointed out.

@guozhangwang
Copy link
Contributor

Hi @lijubjohn as discussed about I'm going to close the ticket as not a bug. Please feel free to pick up other tickets from https://issues.apache.org/jira/issues/?jql=project%20%3D%20KAFKA%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20streams%20ORDER%20BY%20priority%20DESC

thanks for your contributions again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants