Skip to content

[HIGH] Distributed lock TTL expires during long Stellar operations #27

Description

@DeFiVC

Description

The distributed lock in src/utils/lock.ts:13-19 uses PX ttlMs with a 10s default TTL. Stellar contract invocations involve Horizon load, simulation, and submission — easily exceeding 10s. When TTL expires, Redis auto-releases the lock, and a concurrent request acquires it, defeating double-claim/double-mint protection.

No lock renewal/heartbeat mechanism exists.

Impact

Mutual exclusion is lost for any operation exceeding 10s. Critical for reward claiming and credential minting which call external Stellar APIs.

File

src/utils/lock.ts:13-19
Called by: src/modules/rewards/reward.service.ts:93, src/modules/credentials/credential.service.ts:30

Suggested Fix

Increase the default TTL (e.g., 30s) and implement a heartbeat/renewal mechanism that extends the TTL while the lock holder is still working.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workinghigh

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions