Skip to content

fix: resolve lock TTL, bad_seq detection, cache TTL, and FK cascade issues - #447

Merged
DeFiVC merged 1 commit into
ChainLearnOfficial:mainfrom
kris-nana:fix/issues-237-238-239-240
Aug 31, 2026
Merged

fix: resolve lock TTL, bad_seq detection, cache TTL, and FK cascade issues#447
DeFiVC merged 1 commit into
ChainLearnOfficial:mainfrom
kris-nana:fix/issues-237-238-239-240

Conversation

@kris-nana

Copy link
Copy Markdown
Contributor

Overview

This PR implements fixes for four medium-priority bugs affecting caching, error handling, database schema, and distributed locking.

Issues Resolved

Closes #237
Closes #238
Closes #239
Closes #240

Changes Implemented

1. Issue #239: Reward History Cache TTL

File: src/modules/rewards/reward.service.ts

  • Increased reward history cache TTL from 30s to 300s
  • Aligns with user profile cache duration
  • Improves cache hit rate for rarely-changing data

2. Issue #240: FK Cascade

Files: src/database/schema.ts, src/database/migrations/0020_quiz_generated_for_cascade.sql

  • Added onDelete cascade to generatedFor foreign key
  • Created database migration
  • Ensures consistency with other user-referencing FKs

3. Issue #237: Lock TTL

Files: src/utils/lock.ts, src/modules/rewards/reward.service.ts

  • Increased default lock TTL from 30s to 60s
  • Stellar operations use explicit 90s TTL
  • Prevents lock expiration during network congestion

4. Issue #238: Bad Seq Detection

Files: src/stellar/transactions.ts, src/modules/rewards/reward.service.ts

  • Added robust isBadSeqError helper function
  • Checks HTTP response structure in addition to string matching
  • Ensures compatibility across SDK versions

Testing

  • All files compile without errors
  • No breaking changes
  • Database migration is idempotent

Deployment

  1. Run migration before deploying code
  2. All changes are backwards compatible
  3. No API changes required

…ssues

- Increase lock TTL from 30s to 60s default, 90s for Stellar operations
- Add robust bad_seq error detection with HTTP response checking
- Increase reward history cache TTL from 30s to 300s
- Add onDelete cascade to quizzes.generatedFor FK with migration

This commit addresses:
- Lock TTL too short for Stellar transactions (ChainLearnOfficial#237)
- Fragile bad_seq string matching (ChainLearnOfficial#238)
- Reward history cache TTL only 30s (ChainLearnOfficial#239)
- Missing onDelete cascade on generatedFor FK (ChainLearnOfficial#240)
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@kris-nana Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@DeFiVC
DeFiVC merged commit 358600a into ChainLearnOfficial:main Aug 31, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants