Skip to content

refactor(redis): the credential-requirements probe lock and the backup lease release with GET-then-DELETE #4252

Open

Description

@AndriiPasternak31

Problem

Two releases outside SingleFlightLock still compare and delete in two client commands:

  • services/credential_requirements_service.py:895 _release_probe_lock (credreq:probe:{agent})
  • services/db_backup_service.py:356 _release_lease (the backup leader lease)

Each one does lock_token_matches(client.get(key), token) and then client.delete(key). If our lease lapses between the GET and the DELETE, and another worker wins SET NX in that window, the DELETE removes the other worker's lease. Two holders then run at once.

trinity#4028 (PR #4251) removes this shape from SingleFlightLock. With it, its renew and release are one Lua script each, and the scripts live in one place in redis_breaker_util (LEASE_RELEASE_LUA, KEYS[1] = key, ARGV[1] = token). These two releases are outside that issue's scope.

What must be true

  • Neither release can delete a lease held under another token, including when that token arrives between a client-side read and the delete.
  • They use the shared lease script, or the reason they can't is written down where the code is.
  • Tested against an emulator that executes the script text, with a successor winning inside a client-side GET. tests/unit/_ent695_lua.py has one.

Activity

  1. added
    priority-p3
    type-refactor
    theme-reliability
    complexity-low
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowpriority-p3theme-reliabilitytype-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions