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

fix hession maven scope and addConnectionEventProcessor concurrency problems #321

Merged
merged 25 commits into from
Apr 20, 2023

Conversation

chuailiwu
Copy link
Collaborator

No description provided.

@chuailiwu chuailiwu requested a review from OrezzerO April 10, 2023 12:37
@chuailiwu chuailiwu linked an issue Apr 10, 2023 that may be closed by this pull request
@OrezzerO
Copy link
Collaborator

OrezzerO commented Apr 11, 2023

If user do not need hessian,then he/she can not remove hessian from maven. I think it maybe unreasonable.

@chuailiwu chuailiwu closed this Apr 11, 2023
@chuailiwu
Copy link
Collaborator Author

If user do not need hessian,then he/she can not remove hessian from maven. I think it maybe unreasonable.

I don't think so, if user need another serialization protocol, it is ok, but not necessary to delete it.

@chuailiwu chuailiwu reopened this Apr 11, 2023
@chuailiwu chuailiwu changed the title fix hession maven scope fix hession maven scope and addConnectionEventProcessor concurrency problems Apr 12, 2023
@OrezzerO
Copy link
Collaborator

If user do not need hessian,then he/she can not remove hessian from maven. I think it maybe unreasonable.

I don't think so, if user need another serialization protocol, it is ok, but not necessary to delete it.

OK, it's ok to keep hessian in dependencies.

public class ConnectionEventListenerTest {

@Test
public void addConnectionEventProcessorConcurrentTest() throws InterruptedException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This unit test can not reproduce the bug.

  1. new Thread(thread).start() : Thread is started in order. So, rpcClient.addConnectionEventProcessor(ConnectionEventType.CONNECT, (remoteAddress, connection) -> {}); may called in order. We can add a CountDownLatch before addConnectionEventProcessor method, so addConnectionEventProcessor can be concurrency.
  2. fail() method is called in sub thread . We can not see it in main thread.
  3. ArrayList maybe thread safe for add method.

Copy link
Collaborator Author

@chuailiwu chuailiwu Apr 17, 2023

Choose a reason for hiding this comment

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

look at issue "Steps to reproduce"
#309

Copy link
Collaborator

Choose a reason for hiding this comment

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

When it change 'CopyOnWriteArrayList' to 'ArrayList', this unit test cannot throw any Exception.So I say this unit test can not reproduce the bug. Please pay attention to it. @chuailiwu @EvenLjj

Copy link
Collaborator Author

@chuailiwu chuailiwu Apr 21, 2023

Choose a reason for hiding this comment

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

This unit test indeed can not reproduce the bug, even I add a CyclicBarrier to control all threads run in same time.
But the fix is right, there is a concurrency issue here.
image
If you get the list size, you will find it smaller than it shoud be when using ArrayList.
Improve UT:#324

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. I tried use arrayList to reproduce the bug, but failed when there is only add operation. When I add remove operation in ut, it can reproduce similar problem.

Now the question become how user trigger the bug. It may be user is traversing the list, at the same time , he add processor to the list. Is it possible? or we can do something else to forbid it ? (I think it is not right to add processor when other processors are working on connections.It may cause different behavior in different connections. )

@chuailiwu chuailiwu merged commit 40edbd8 into sofastack:master Apr 20, 2023
This was referenced Apr 20, 2023
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.

Bolt can not run without hessian
3 participants