Skip to content

Commit

Permalink
Merge pull request #32690 from vespa-engine/mpolden/include-cause
Browse files Browse the repository at this point in the history
Include the last exception thrown as cause of the timeout exception
  • Loading branch information
freva authored Oct 28, 2024
2 parents c09878f + e8a47a9 commit 9ba27aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@ public String timesUsed() {
}

/**
* @param exceptionMessage exception message for the exception that will be thrown if there is no time left
* @param message exception message for the exception that will be thrown if there is no time left
* @param cause the last exception thrown while waiting for the operation to complete
* @throws UncheckedTimeoutException if this has no time left
*/
public void assertNotTimedOut(Supplier<String> exceptionMessage) {
public void assertNotTimedOut(Supplier<String> message, Exception cause) {
if (hasTimeLeft()) return;
throw new UncheckedTimeoutException(exceptionMessage.get());
throw new UncheckedTimeoutException(message.get(), cause);
}

public void assertNotTimedOut(Supplier<String> message) {
assertNotTimedOut(message, null);
}

private static class Measurement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import com.yahoo.config.provision.ActivationContext;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationLockException;
import com.yahoo.config.provision.ApplicationMutex;
import com.yahoo.config.provision.ApplicationTransaction;
import com.yahoo.config.provision.HostFilter;
import com.yahoo.config.provision.HostSpec;
import com.yahoo.config.provision.ApplicationMutex;
import com.yahoo.config.provision.Provisioner;
import com.yahoo.config.provision.TransientException;
import com.yahoo.transaction.NestedTransaction;
Expand All @@ -26,6 +26,7 @@
import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.session.SessionRepository;
import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.yolean.Exceptions;
import com.yahoo.yolean.concurrent.Memoized;

import java.time.Clock;
Expand All @@ -38,7 +39,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.yahoo.vespa.config.server.application.ConfigConvergenceChecker.ServiceListResponse;
import static com.yahoo.vespa.config.server.session.Session.Status.DELETE;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining;
Expand Down Expand Up @@ -275,8 +275,8 @@ private static void waitForResourcesOrTimeout(PrepareParams params, Session sess
while (true) {
params.getTimeoutBudget().assertNotTimedOut(
() -> "Timeout exceeded while waiting for application resources of '" + session.getApplicationId() + "'" +
Optional.ofNullable(lastException.get()).map(e -> ". Last exception: " + e.getMessage()).orElse(""));

Optional.ofNullable(lastException.get()).map(e -> ". Last exception: " + Exceptions.toMessageString(e)).orElse(""),
lastException.get());
try (ApplicationMutex lock = provisioner.get().lock(session.getApplicationId())) {
// Call to activate to make sure that everything is ready, but do not commit the transaction
ApplicationTransaction transaction = new ApplicationTransaction(lock, new NestedTransaction());
Expand Down

0 comments on commit 9ba27aa

Please sign in to comment.