this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ident: have redis caching dir only log on 'write', not error (#809)

This changes the behavior when the redis caching directory successfully
resolves an identity, but fails to persist to the cache. The prior
behavior was to return an error to the calling code. With this PR, the
library will log the error, but return the (successful) resolution
result.

This helps services ride out intermittent failures (packet
loss/corruption) or brief downtimes with caches (eg, redis restarts or
machine reboots).

The only downside I can think of with this is that the cache being
entirely down doesn't get noticed earlier? The package does confirm the
connection to redis at startup, so it shouldn't be possible for a
mis-configuration or non-existent backend to silently default to "always
resolving".

authored by

bnewbold and committed by
GitHub
8badabdd 532f3c72

+6 -15
+6 -15
atproto/identity/redisdir/redis_directory.go
··· 4 4 "context" 5 5 "errors" 6 6 "fmt" 7 + "log/slog" 7 8 "sync" 8 9 "time" 9 10 ··· 116 117 TTL: d.ErrTTL, 117 118 }) 118 119 if err != nil { 119 - he.DID = nil 120 - he.Err = fmt.Errorf("identity cache write failed: %w", err) 121 - return he 120 + slog.Error("identity cache write failed", "cache", "handle", "err", err) 122 121 } 123 122 return he 124 123 } ··· 141 140 TTL: d.HitTTL, 142 141 }) 143 142 if err != nil { 144 - he.DID = nil 145 - he.Err = fmt.Errorf("identity cache write failed: %w", err) 146 - return he 143 + slog.Error("identity cache write failed", "cache", "did", "did", ident.DID, "err", err) 147 144 } 148 145 err = d.handleCache.Set(&cache.Item{ 149 146 Ctx: ctx, ··· 152 149 TTL: d.HitTTL, 153 150 }) 154 151 if err != nil { 155 - he.DID = nil 156 - he.Err = fmt.Errorf("identity cache write failed: %w", err) 157 - return he 152 + slog.Error("identity cache write failed", "cache", "handle", "did", ident.DID, "err", err) 158 153 } 159 154 return he 160 155 } ··· 250 245 TTL: d.HitTTL, 251 246 }) 252 247 if err != nil { 253 - entry.Identity = nil 254 - entry.Err = fmt.Errorf("identity cache write failed: %w", err) 255 - return entry 248 + slog.Error("identity cache write failed", "cache", "did", "did", did, "err", err) 256 249 } 257 250 if he != nil { 258 251 err = d.handleCache.Set(&cache.Item{ ··· 262 255 TTL: d.HitTTL, 263 256 }) 264 257 if err != nil { 265 - entry.Identity = nil 266 - entry.Err = fmt.Errorf("identity cache write failed: %w", err) 267 - return entry 258 + slog.Error("identity cache write failed", "cache", "handle", "did", did, "err", err) 268 259 } 269 260 } 270 261 return entry