Skip to content

Commit

Permalink
fix(redis-lua): compatibility with dragonfly and lua 5.4 (#65825)
Browse files Browse the repository at this point in the history
Because there is no way to have a full high availability Redis (cluster,
sentinel) compatible with Sentry yet. As an alternative Dragonfly DB can
be used.

This PR fix the `math.randomseed` that take integers but Sentry send
`float`.
In lua 5.1 it doesn't seem to be an issue but with lua 5.4 in Dragonfly
DB.

An other small difference is `redis.log` that don't exist but it's used
one time, so I replace it by a `print`.

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.

Signed-off-by: Anthony ARNAUD <github@anthony-arnaud.fr>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
  • Loading branch information
aarnaud and loewenheim authored Nov 8, 2024
1 parent ea4100d commit 0b9d9f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/sentry/scripts/digests/digests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ local configuration_argument_parser = object_argument_parser({
{"ttl", argument_parser(tonumber)},
{"timestamp", argument_parser(tonumber)},
}, function (configuration)
math.randomseed(configuration.timestamp)
math.randomseed(math.floor(configuration.timestamp))

function configuration:get_schedule_waiting_key()
return string.format('%s:s:w', self.namespace)
Expand Down
6 changes: 5 additions & 1 deletion src/sentry/scripts/similarity/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ This is modeled as two data structures:
-- greater. This is wrapped in `pcall` so that we can continue to support older
-- Redis versions while using this feature if it's available.
if not pcall(redis.replicate_commands) then
redis.log(redis.LOG_DEBUG, 'Could not enable script effects replication.')
if redis.log == nil then
print('Could not enable script effects replication.')
else
redis.log(redis.LOG_DEBUG, 'Could not enable script effects replication.')
end
end


Expand Down

0 comments on commit 0b9d9f8

Please sign in to comment.