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

Incorrect connector implementation #86

Closed
emil14 opened this issue Sep 18, 2022 · 2 comments
Closed

Incorrect connector implementation #86

emil14 opened this issue Sep 18, 2022 · 2 comments

Comments

@emil14
Copy link
Collaborator

emil14 commented Sep 18, 2022

Current implementation of connector that uses semaphores instead of buffers has bug that leads to unnecessary blocks.

Example:

  • let fastest be sender and slow1, slow2 and fast (order is important) are receivers (semaphore's buffer is empty, it's cap is 3)
  • suppose fastest sends a message and slow1, slow2 and fast receives it (semaphore's buffer is full)
  • new message from fastest arrives - fast already did the job and ready for new data, but slow1 and slow2 are still busy (semaphore's buffer is 2)
  • a new go-routine spawned to send new message to first receiver which is slow1 although it can't receive it yet (semaphore's buffer is 3 again)
  • fast receiver didn't receive the message although it could handle it
@emil14
Copy link
Collaborator Author

emil14 commented Sep 24, 2022

The big problem

  1. We spawn a go-routines when messages arrives - so we need to restrict their count via semaphore which is not a complete solution and will behave like a buffer (and it's better to use buffers as buffers and move calculation of buffer size to compiler)
  2. We can't spawn a go-routine per 1-1 connection because message once read will never arrive to another inport
  3. Both buffer and semaphore solution allow unnecessary blocking

@emil14
Copy link
Collaborator Author

emil14 commented Sep 26, 2022

Fixed via round-robin-like-queue-based algorithm

See ("Describe connector algorithm" task in Project)

@emil14 emil14 closed this as completed Sep 26, 2022
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

No branches or pull requests

1 participant