Supports the ability to connect to a shared session on a replica
LeonidVas opened this issue · 4 comments
Now in case of a master switching, we must to re-identify on the new master. Seems like it would be convenient to connect to every instance in a replicaset, identify, and not have to think about identifying in case of master changing.
Looks like it might be possible to implement this by using temporary spaces.
The task requires research to obtain information about its feasibility and complexity.
I don't see too big problems with the identify handling (we will need an additional temporary space + handle it on ro->rw switch), but this approach would complicate a disconnect behavior too much (omit the complexity of implementation of different behaviors).
Suppose we have a master and a replica instance. An user of the queue already identify on it. Such situations are possible:
- The user disconnects from the master instance.
- The user lost connection with the master instance.
- 1 + replica->master switch.
- 2 + replica->master switch.
We can define behavior for these cases, but I don't see an obvious one. In the same time the current implementation is simple for these cases (just wait for queue.cfg.ttr).
In any case, the user will always have an additional code for routing and a master discovery. I don't see much benefit from the fact that the user will can to omit a call queue.identify() in addition to the code.
So my opinion:
This is not a very useful feature that logically competes with queue.cfg.ttr:
Lines 460 to 461 in 2dd5948
It will not just overcomplicate our code and also make it difficult for the user (and developers) to understand the module behavior.
In a nutshell:
It will be a counterintuitive behavior of disconnect in case of multiple sessions.
We discussed in with Oleg in a chat. The short summary: I don't mind to throw it out at least until we'll see another case, where it is needed (except a binding to the queue on top of a connection pool with master discovery). The binding may be implemented without this feature.
The chat log (in Russian)
|
Александр Туренко (12.08.2022 16:21): |
|
Александр Туренко (12.08.2022 16:21): |
|
Олег Жуковец (12.08.2022 16:23): |
|
Александр Туренко (12.08.2022 16:23): |
|
Александр Туренко (12.08.2022 16:24): |
|
Александр Туренко (12.08.2022 16:24): |
|
Александр Туренко (12.08.2022 16:27): |
|
Александр Туренко (12.08.2022 16:28): |
|
Александр Туренко (12.08.2022 16:29): |
|
Олег Жуковец (12.08.2022 17:26):
На мастере почему-то отключилась-разорвалась сессия, но на реплике она есть. Отменять задачу или ставить ей TTL в этом случае сходу выглядит странно - сессия то жива, пусть и на реплике.
А если рвётся соединение с мастером, но есть куча queue.identify(uuid) на других инстансах? Будет неожиданно получить возвращение задачи по TTL после того как удастся соединиться с новым или старым мастером. Хотя в этом плане я не особо спорю, определить какое-то поведение действительно можно. Но это всё рассуждение о поведении на уровне роутера-пула соединений-топологии. Т.е. на уровне queue закладываем некоторую логику роутера и нарушаем разделение ответственности.
Сейчас же для пользователя всё просто: есть сессия на rw-инстансе, и есть |
|
Александр Туренко (12.08.2022 17:31): |
|
Олег Жуковец (12.08.2022 17:32): |
|
Олег Жуковец (12.08.2022 17:36): |
|
Александр Туренко (12.08.2022 17:43): |
|
Олег Жуковец (12.08.2022 18:02): |
|
Александр Туренко (12.08.2022 18:09): |
So, after talking with Oleg, I agree that adding the ability to have several connections in replicaset only complicates the logic and does not add convenience to the client.