Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
zilencer: Lock the RemoteZulipServer row when inserting data.
Alex Vandiverc6ae3e72429b
diff --git a/zilencer/views.py b/zilencer/views.pyindex c2035f01622..0b7f5be0a9b 100644--- a/zilencer/views.py+++ b/zilencer/views.py@@ -617,6 +617,7 @@ class InstallationCountDataForAnalytics(BaseModel):@typed_endpointdef remote_server_post_analytics(request: HttpRequest,server: RemoteZulipServer,@@ -627,6 +628,10 @@ def remote_server_post_analytics(realms: Optional[Json[List[RealmDataForAnalytics]]] = None,version: Optional[Json[str]] = None,) -> HttpResponse:+ # Lock the server, preventing this from racing with other+ # duplicate submissions of the data+ server = RemoteZulipServer.objects.select_for_update().get(id=server.id)+if version is not None:version = version[0 : RemoteZulipServer.VERSION_MAX_LENGTH]if version != server.last_version: