diff --git a/plugins/endpoints/plugin.py b/plugins/endpoints/plugin.py index 03118454..04a64d77 100644 --- a/plugins/endpoints/plugin.py +++ b/plugins/endpoints/plugin.py @@ -1140,17 +1140,13 @@ class EndpointsPlugin(BasePlugin): incoming_fps = set(incoming.keys()) - # SAFETY: Row-level locking to prevent concurrent update races. - # MySQL uses FOR UPDATE on the SELECT below (line 1157). - # PostgreSQL would use pg_advisory_xact_lock here, but MySQL achieves - # the same result via row-level locks + UNIQUE constraint on fingerprint. - # SAFETY: Memory limit check - prevent loading massive inventories # Query exactly MAX rows, then check if more exist (off-by-one fix) + # Concurrency protection: UNIQUE constraint on (assetid, app_fingerprint) + # handles race conditions without explicit row locks current_apps = (EndpointApplication.query .filter_by(assetid=assetid) .limit(MAX_APPS_PER_ENDPOINT) - .with_for_update() # SAFETY: Row-level locking prevents concurrent races .all()) if len(current_apps) >= MAX_APPS_PER_ENDPOINT: