mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
event_queue: Replace sequential queue IDs with UUIDs.
This prevents ID conflicts when resharding between multiple Tornado shards. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e38f9f038a
commit
31b4be3b9b
@@ -6,6 +6,7 @@ import os
|
|||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
import uuid
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
@@ -428,8 +429,6 @@ realm_clients_all_streams: Dict[int, List[ClientDescriptor]] = {}
|
|||||||
# that is about to be deleted
|
# that is about to be deleted
|
||||||
gc_hooks: List[Callable[[int, ClientDescriptor, bool], None]] = []
|
gc_hooks: List[Callable[[int, ClientDescriptor, bool], None]] = []
|
||||||
|
|
||||||
next_queue_id = 0
|
|
||||||
|
|
||||||
|
|
||||||
def clear_client_event_queues_for_testing() -> None:
|
def clear_client_event_queues_for_testing() -> None:
|
||||||
assert settings.TEST_SUITE
|
assert settings.TEST_SUITE
|
||||||
@@ -437,8 +436,6 @@ def clear_client_event_queues_for_testing() -> None:
|
|||||||
user_clients.clear()
|
user_clients.clear()
|
||||||
realm_clients_all_streams.clear()
|
realm_clients_all_streams.clear()
|
||||||
gc_hooks.clear()
|
gc_hooks.clear()
|
||||||
global next_queue_id
|
|
||||||
next_queue_id = 0
|
|
||||||
|
|
||||||
|
|
||||||
def add_client_gc_hook(hook: Callable[[int, ClientDescriptor, bool], None]) -> None:
|
def add_client_gc_hook(hook: Callable[[int, ClientDescriptor, bool], None]) -> None:
|
||||||
@@ -467,9 +464,7 @@ def add_to_client_dicts(client: ClientDescriptor) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def allocate_client_descriptor(new_queue_data: MutableMapping[str, Any]) -> ClientDescriptor:
|
def allocate_client_descriptor(new_queue_data: MutableMapping[str, Any]) -> ClientDescriptor:
|
||||||
global next_queue_id
|
queue_id = str(uuid.uuid4())
|
||||||
queue_id = str(settings.SERVER_GENERATION) + ":" + str(next_queue_id)
|
|
||||||
next_queue_id += 1
|
|
||||||
new_queue_data["event_queue"] = EventQueue(queue_id).to_dict()
|
new_queue_data["event_queue"] = EventQueue(queue_id).to_dict()
|
||||||
client = ClientDescriptor.from_dict(new_queue_data)
|
client = ClientDescriptor.from_dict(new_queue_data)
|
||||||
clients[queue_id] = client
|
clients[queue_id] = client
|
||||||
|
|||||||
Reference in New Issue
Block a user