mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 06:26:47 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46aefc0cbe | ||
|
|
9d4f9b4c12 | ||
|
|
3591e6bebd | ||
|
|
e12ba6b15b | ||
|
|
744b05244d | ||
|
|
c22b8fafa6 |
No files matched your search
@@ -37,7 +37,7 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<aws.sdk2.version>2.29.48</aws.sdk2.version>
|
||||
<aws.sdk2.version>2.31.7</aws.sdk2.version>
|
||||
<braintree.version>3.37.0</braintree.version>
|
||||
<commons-csv.version>1.12.0</commons-csv.version>
|
||||
<commons-io.version>2.18.0</commons-io.version>
|
||||
|
||||
+4
-3
@@ -56,6 +56,9 @@ public class MessagesDynamoDb extends AbstractDynamoDbStore {
|
||||
@VisibleForTesting
|
||||
static final String LOCAL_INDEX_MESSAGE_UUID_KEY_SORT = "U";
|
||||
|
||||
@VisibleForTesting
|
||||
static final int MAY_HAVE_URGENT_MESSAGES_QUERY_LIMIT = 20;
|
||||
|
||||
private static final String KEY_TTL = "E";
|
||||
private static final String KEY_ENVELOPE_BYTES = "EB";
|
||||
|
||||
@@ -67,8 +70,6 @@ public class MessagesDynamoDb extends AbstractDynamoDbStore {
|
||||
private final ExecutorService messageDeletionExecutor;
|
||||
private final Scheduler messageDeletionScheduler;
|
||||
|
||||
private static final CompletableFuture<?>[] EMPTY_FUTURE_ARRAY = new CompletableFuture<?>[0];
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MessagesDynamoDb.class);
|
||||
|
||||
public MessagesDynamoDb(DynamoDbClient dynamoDb, DynamoDbAsyncClient dynamoDbAsyncClient, String tableName,
|
||||
@@ -126,7 +127,7 @@ public class MessagesDynamoDb extends AbstractDynamoDbStore {
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> mayHaveUrgentMessages(final UUID accountIdentifier, final Device device) {
|
||||
return Flux.from(load(accountIdentifier, device, null))
|
||||
return Flux.from(load(accountIdentifier, device, MAY_HAVE_URGENT_MESSAGES_QUERY_LIMIT))
|
||||
.any(MessageProtos.Envelope::getUrgent)
|
||||
.toFuture();
|
||||
}
|
||||
|
||||
+12
-1
@@ -16,7 +16,9 @@ import org.whispersystems.textsecuregcm.storage.MessagesManager;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.util.function.Tuples;
|
||||
import reactor.util.retry.Retry;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public class NotifyIdleDevicesCommand extends AbstractSinglePassCrawlAccountsCommand {
|
||||
@@ -79,7 +81,16 @@ public class NotifyIdleDevicesCommand extends AbstractSinglePassCrawlAccountsCom
|
||||
.doOnNext(ignored -> DEVICE_INSPECTED_COUNTER.increment())
|
||||
.flatMap(accountAndDevice -> Mono.fromFuture(() ->
|
||||
idleWakeupEligibilityChecker.isDeviceEligible(accountAndDevice.getT1(), accountAndDevice.getT2()))
|
||||
.mapNotNull(eligible -> eligible ? accountAndDevice : null),
|
||||
.mapNotNull(eligible -> eligible ? accountAndDevice : null)
|
||||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(1)))
|
||||
.onErrorResume(throwable -> {
|
||||
log.warn("Failed to check eligibility for {}:{}",
|
||||
accountAndDevice.getT1().getIdentifier(IdentityType.ACI),
|
||||
accountAndDevice.getT2().getId(),
|
||||
throwable);
|
||||
|
||||
return Mono.empty();
|
||||
}),
|
||||
maxConcurrency)
|
||||
.flatMap(accountAndDevice -> {
|
||||
final Account account = accountAndDevice.getT1();
|
||||
|
||||
+2
@@ -20,6 +20,7 @@ import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.util.retry.Retry;
|
||||
|
||||
public class RemoveExpiredAccountsCommand extends AbstractSinglePassCrawlAccountsCommand {
|
||||
|
||||
@@ -70,6 +71,7 @@ public class RemoveExpiredAccountsCommand extends AbstractSinglePassCrawlAccount
|
||||
|
||||
return deleteAccountMono
|
||||
.doOnSuccess(ignored -> deletedAccountCounter.increment())
|
||||
.retryWhen(Retry.backoff(8, Duration.ofSeconds(1)).maxBackoff(Duration.ofSeconds(4)))
|
||||
.onErrorResume(throwable -> {
|
||||
log.warn("Failed to delete account {}", expiredAccount.getUuid(), throwable);
|
||||
return Mono.empty();
|
||||
|
||||
+2
@@ -22,6 +22,7 @@ import org.whispersystems.textsecuregcm.backup.ExpiredBackup;
|
||||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
import reactor.util.retry.Retry;
|
||||
|
||||
public class RemoveExpiredBackupsCommand extends AbstractCommandWithDependencies {
|
||||
|
||||
@@ -119,6 +120,7 @@ public class RemoveExpiredBackupsCommand extends AbstractCommandWithDependencies
|
||||
}
|
||||
|
||||
return mono
|
||||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(1)))
|
||||
.doOnSuccess(ignored -> {
|
||||
logger.trace("Successfully expired {} for {}",
|
||||
expiredBackup.expirationType(),
|
||||
|
||||
+11
-9
@@ -5,9 +5,18 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.workers;
|
||||
|
||||
import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import io.micrometer.core.instrument.Counter;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -16,15 +25,7 @@ import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||
import org.whispersystems.textsecuregcm.util.Util;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name;
|
||||
import reactor.util.retry.Retry;
|
||||
|
||||
public class RemoveExpiredUsernameHoldsCommand extends AbstractSinglePassCrawlAccountsCommand {
|
||||
|
||||
@@ -91,6 +92,7 @@ public class RemoveExpiredUsernameHoldsCommand extends AbstractSinglePassCrawlAc
|
||||
"expiredHolds", String.valueOf(holdsToRemove > 0))
|
||||
.increment();
|
||||
return purgeMono
|
||||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(1)))
|
||||
.doOnSuccess(ignored -> deletedHoldsCounter.increment(holdsToRemove))
|
||||
.onErrorResume(throwable -> {
|
||||
log.warn("Failed to purge {} expired holds on account {}", holdsToRemove, account.getUuid());
|
||||
|
||||
+21
-5
@@ -313,11 +313,14 @@ class MessagesDynamoDbTest {
|
||||
|
||||
assertThat(messagesDynamoDb.mayHaveUrgentMessages(destinationUuid, destinationDevice).join()).isFalse();
|
||||
|
||||
// used as the stable sort key, and the urgent message should be sorted last
|
||||
int serverTimestamp = 1;
|
||||
{
|
||||
final MessageProtos.Envelope nonUrgentMessage = MessageProtos.Envelope.newBuilder()
|
||||
.setUrgent(false)
|
||||
.setServerGuid(UUID.randomUUID().toString())
|
||||
.setDestinationServiceId(UUID.randomUUID().toString())
|
||||
.setDestinationServiceId(destinationUuid.toString())
|
||||
.setServerTimestamp(serverTimestamp++)
|
||||
.build();
|
||||
|
||||
messagesDynamoDb.store(List.of(nonUrgentMessage), destinationUuid, destinationDevice);
|
||||
@@ -326,13 +329,26 @@ class MessagesDynamoDbTest {
|
||||
assertThat(messagesDynamoDb.mayHaveUrgentMessages(destinationUuid, destinationDevice).join()).isFalse();
|
||||
|
||||
{
|
||||
final MessageProtos.Envelope urgentMessage = MessageProtos.Envelope.newBuilder()
|
||||
final List<MessageProtos.Envelope> messages = new ArrayList<>();
|
||||
// store more non-urgent messages
|
||||
for (int i = 0; i < MessagesDynamoDb.MAY_HAVE_URGENT_MESSAGES_QUERY_LIMIT * 5; i++) {
|
||||
messages.add(MessageProtos.Envelope.newBuilder()
|
||||
.setUrgent(false)
|
||||
.setServerGuid(UUID.randomUUID().toString())
|
||||
.setDestinationServiceId(destinationUuid.toString())
|
||||
.setServerTimestamp(serverTimestamp++)
|
||||
.build());
|
||||
}
|
||||
|
||||
// and one urgent message
|
||||
messages.add(MessageProtos.Envelope.newBuilder()
|
||||
.setUrgent(true)
|
||||
.setServerGuid(UUID.randomUUID().toString())
|
||||
.setDestinationServiceId(UUID.randomUUID().toString())
|
||||
.build();
|
||||
.setDestinationServiceId(destinationUuid.toString())
|
||||
.setServerTimestamp(serverTimestamp++)
|
||||
.build());
|
||||
|
||||
messagesDynamoDb.store(List.of(urgentMessage), destinationUuid, destinationDevice);
|
||||
messagesDynamoDb.store(messages, destinationUuid, destinationDevice);
|
||||
}
|
||||
|
||||
assertThat(messagesDynamoDb.mayHaveUrgentMessages(destinationUuid, destinationDevice).join()).isTrue();
|
||||
|
||||
Reference in new issue
Block a user