mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 13:48:05 +01:00
Ignore failures to update cache after a read
This commit is contained in:
@@ -1310,7 +1310,11 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
Optional<Account> account = resolveFromRedis.get();
|
||||
if (account.isEmpty()) {
|
||||
account = resolveFromAccounts.get();
|
||||
account.ifPresent(this::redisSet);
|
||||
try {
|
||||
account.ifPresent(this::redisSet);
|
||||
} catch (RedisException e) {
|
||||
logger.warn("Failed to cache retrieved account", e);
|
||||
}
|
||||
}
|
||||
return account;
|
||||
});
|
||||
@@ -1328,7 +1332,12 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
.map(accountFromRedis -> CompletableFuture.completedFuture(maybeAccountFromRedis))
|
||||
.orElseGet(() -> resolveFromAccounts.get()
|
||||
.thenCompose(maybeAccountFromAccounts -> maybeAccountFromAccounts
|
||||
.map(account -> redisSetAsync(account).thenApply(ignored -> maybeAccountFromAccounts))
|
||||
.map(account -> redisSetAsync(account)
|
||||
.exceptionally(ExceptionUtils.exceptionallyHandler(RedisException.class, e -> {
|
||||
logger.warn("Failed to cache retrieved account", e);
|
||||
return null;
|
||||
}))
|
||||
.thenApply(ignored -> maybeAccountFromAccounts))
|
||||
.orElseGet(() -> CompletableFuture.completedFuture(maybeAccountFromAccounts)))))
|
||||
.whenComplete((ignored, throwable) -> sample.stop(overallTimer));
|
||||
}
|
||||
@@ -1343,7 +1352,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
logger.warn("Deserialization error", e);
|
||||
return Optional.empty();
|
||||
} catch (RedisException e) {
|
||||
logger.warn("Redis failure", e);
|
||||
logger.warn("Failed fetching account from cache by secondary key", e);
|
||||
return Optional.empty();
|
||||
}
|
||||
});
|
||||
@@ -1375,7 +1384,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
|
||||
return parseAccountJson(json, uuid);
|
||||
} catch (final RedisException e) {
|
||||
logger.warn("Redis failure", e);
|
||||
logger.warn("Failed to retrieve account from cache", e);
|
||||
return Optional.empty();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.micrometer.core.instrument.Metrics;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisClusterClient;
|
||||
import org.whispersystems.textsecuregcm.util.ExceptionUtils;
|
||||
import org.whispersystems.textsecuregcm.util.ResilienceUtil;
|
||||
import org.whispersystems.textsecuregcm.util.SystemMapper;
|
||||
import org.whispersystems.textsecuregcm.util.Util;
|
||||
@@ -114,7 +115,11 @@ public class ProfilesManager {
|
||||
|
||||
if (profile.isEmpty()) {
|
||||
profile = profiles.get(uuid, version);
|
||||
profile.ifPresent(versionedProfile -> redisSet(uuid, versionedProfile));
|
||||
try {
|
||||
profile.ifPresent(versionedProfile -> redisSet(uuid, versionedProfile));
|
||||
} catch (RedisException e) {
|
||||
logger.warn("Failed to cache retrieved profile", e);
|
||||
}
|
||||
}
|
||||
|
||||
return profile;
|
||||
@@ -126,7 +131,12 @@ public class ProfilesManager {
|
||||
.map(versionedProfile -> CompletableFuture.completedFuture(maybeVersionedProfile))
|
||||
.orElseGet(() -> profiles.getAsync(uuid, version)
|
||||
.thenCompose(maybeVersionedProfileFromDynamo -> maybeVersionedProfileFromDynamo
|
||||
.map(profile -> redisSetAsync(uuid, profile).thenApply(ignored -> maybeVersionedProfileFromDynamo))
|
||||
.map(profile -> redisSetAsync(uuid, profile)
|
||||
.exceptionally(ExceptionUtils.exceptionallyHandler(RedisException.class, e -> {
|
||||
logger.warn("Failed to cache retrieved profile", e);
|
||||
return null;
|
||||
}))
|
||||
.thenApply(ignored -> maybeVersionedProfileFromDynamo))
|
||||
.orElseGet(() -> CompletableFuture.completedFuture(maybeVersionedProfileFromDynamo)))));
|
||||
}
|
||||
|
||||
@@ -161,7 +171,7 @@ public class ProfilesManager {
|
||||
|
||||
return parseProfileJson(json);
|
||||
} catch (RedisException e) {
|
||||
logger.warn("Redis exception", e);
|
||||
logger.warn("Failed to retrieve profile from cache", e);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user