Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *Storage) Update(ctx context.Context, sandboxID string, updateFunc func(
}

// Execute transaction
err = s.redisClient.Set(ctx, key, newData, redis.KeepTTL).Err()
err = s.redisClient.Set(ctx, key, newData, 0).Err()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting TTL to 0 means no expiration. Both Add() (line 29) and now Update() store keys without expiration, but the comment on line 28 says "with max expiration little bit longer than max instance length to prevent leaking". This means sandbox data will persist indefinitely in Redis unless explicitly removed via Remove(). If the cleanup logic fails, this could cause memory leaks. Consider either: (1) setting an actual TTL value (e.g., based on max instance lifetime), or (2) updating the comment to reflect that Redis is not being used as a TTL-based cache for sandboxes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve TTL when updating sandbox entry

Using Set(..., 0) explicitly removes any existing TTL on the key. If sandbox entries ever have expirations set (e.g., via EXPIRE elsewhere or from prior versions), this update makes them persistent after any write, so they will never expire and can leak. The previous redis.KeepTTL preserved those expirations. Consider keeping TTLs (or reapplying the current TTL) when updating so updates don’t disable expiry for keys that have one.

Useful? React with 👍 / 👎.

if err != nil {
return sandbox.Sandbox{}, err
}
Expand Down
Loading