You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Main issue:
We rely on the idea of rest_api being a singleton service to maintain our distributed lock. This will cause issues when the number of services increases.
Side issue:
The Redis operation that is used in our system has nothing to do with our API request:
For read & write to queue done by a background process.
(Added) To acquire a mutually exclusive lock.
Using Redis on asyncio will add unnecessary overhead and overscribe the event loop shared by Prisma queries.
Changes 🏗️
Migrate distributed lock from rest_api to Redis.
Switch Redis to synchronous client.
Cleanup on connection retry logic on db.py and redis.py (newly introduced).
Remove InMemoryEventQueue and make integration test use Redis queue.
Testing 🔍
Note
Only for the new autogpt platform, currently in autogpt_platform/
Create from scratch and execute an agent with at least 3 blocks
Import an agent from file upload, and confirm it executes correctly
Upload agent to marketplace
Import an agent from marketplace and confirm it executes correctly
Edit an agent from monitor, and confirm it executes correctly
Sensitive information exposure: The PR introduces Redis connection details in autogpt_platform/backend/backend/data/redis.py. While environment variables are used, there's a risk of exposing default values (e.g., "password" for Redis password) if the environment variables are not properly set.
⚡ Key issues to review
Error Handling The connect() and disconnect() functions use logged_retry without proper error handling or maximum retry limit.
Error Handling The RedisEventQueue methods lack proper error handling for Redis connection issues.
Potential Deadlock The synchronized context manager acquires a lock but doesn't handle potential exceptions, which could lead to a lock not being released.
Pwuts
changed the title
feat(platform): Make Redis connection Sync + Use Redis as Distributed Lock
feat(backend): Make Redis connection Sync + Use Redis as Distributed Lock
Sep 30, 2024
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Main issue:
We rely on the idea of rest_api being a singleton service to maintain our distributed lock. This will cause issues when the number of services increases.
Side issue:
The Redis operation that is used in our system has nothing to do with our API request:
Using Redis on asyncio will add unnecessary overhead and overscribe the event loop shared by Prisma queries.
Changes 🏗️
Testing 🔍
Note
Only for the new autogpt platform, currently in autogpt_platform/