Debug logging for TestIncrementalCoreBackup Windows failures

This commit is contained in:
Jason Gerlowski 2021-02-08 14:07:42 -05:00
parent cede9723fa
commit ed2eebfa4d
4 changed files with 22 additions and 2 deletions

View File

@ -90,7 +90,11 @@ public class BackupCmd implements OverseerCollectionMessageHandler.Cmd {
try (BackupRepository repository = cc.newBackupRepository(repo)) { try (BackupRepository repository = cc.newBackupRepository(repo)) {
// Backup location // Backup location
if (log.isDebugEnabled()) {
log.debug("Backup location received by overseer is: {}", message.getStr(CoreAdminParams.BACKUP_LOCATION));
}
URI location = repository.createURI(message.getStr(CoreAdminParams.BACKUP_LOCATION)); URI location = repository.createURI(message.getStr(CoreAdminParams.BACKUP_LOCATION));
log.debug("Resolved backup URI in overseer is: {}", location);
final URI backupPath = createAndValidateBackupPath(repository, incremental, location, backupName, collectionName); final URI backupPath = createAndValidateBackupPath(repository, incremental, location, backupName, collectionName);
BackupManager backupMgr = (incremental) ? BackupManager backupMgr = (incremental) ?
@ -146,6 +150,7 @@ public class BackupCmd implements OverseerCollectionMessageHandler.Cmd {
private URI createAndValidateBackupPath(BackupRepository repository, boolean incremental, URI location, String backupName, String collection) throws IOException{ private URI createAndValidateBackupPath(BackupRepository repository, boolean incremental, URI location, String backupName, String collection) throws IOException{
final URI backupNamePath = repository.resolve(location, backupName); final URI backupNamePath = repository.resolve(location, backupName);
log.debug("Location {} and backup-name {} combine to make path {}", location, backupName, backupNamePath);
if ( (!incremental) && repository.exists(backupNamePath)) { if ( (!incremental) && repository.exists(backupNamePath)) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "The backup directory already exists: " + backupNamePath); throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "The backup directory already exists: " + backupNamePath);

View File

@ -19,6 +19,7 @@ package org.apache.solr.core.backup.repository;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.invoke.MethodHandles;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.FileVisitResult; import java.nio.file.FileVisitResult;
@ -42,6 +43,8 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.DirectoryFactory; import org.apache.solr.core.DirectoryFactory;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* A concrete implementation of {@linkplain BackupRepository} interface supporting backup/restore of Solr indexes to a * A concrete implementation of {@linkplain BackupRepository} interface supporting backup/restore of Solr indexes to a
@ -49,6 +52,8 @@ import com.google.common.base.Preconditions;
* interface e.g. NFS). * interface e.g. NFS).
*/ */
public class LocalFileSystemRepository implements BackupRepository { public class LocalFileSystemRepository implements BackupRepository {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private NamedList config = null; private NamedList config = null;
@ -66,23 +71,26 @@ public class LocalFileSystemRepository implements BackupRepository {
@Override @Override
public URI createURI(String location) { public URI createURI(String location) {
Objects.requireNonNull(location); Objects.requireNonNull(location);
log.debug("Creating URI from location: {}", location);
URI result = null; URI result = null;
try { try {
result = new URI(location); result = new URI(location);
if (!result.isAbsolute()) { if (!result.isAbsolute()) {
result = Paths.get(location).toUri(); result = Paths.get(result).toUri();
} }
} catch (URISyntaxException ex) { } catch (URISyntaxException ex) {
result = Paths.get(location).toUri(); result = Paths.get(location).toUri();
} }
log.debug("Created URI is: {}", result);
return result; return result;
} }
@Override @Override
public URI resolve(URI baseUri, String... pathComponents) { public URI resolve(URI baseUri, String... pathComponents) {
Preconditions.checkArgument(pathComponents.length > 0); Preconditions.checkArgument(pathComponents.length > 0);
log.debug("Resolving URI from base: {}", baseUri);
Path result = Paths.get(baseUri); Path result = Paths.get(baseUri);
for (int i = 0; i < pathComponents.length; i++) { for (int i = 0; i < pathComponents.length; i++) {
@ -95,6 +103,9 @@ public class LocalFileSystemRepository implements BackupRepository {
} }
if (log.isDebugEnabled()) {
log.debug("Resolved URI is: {}", result.toUri());
}
return result.toUri(); return result.toUri();
} }
@ -125,6 +136,7 @@ public class LocalFileSystemRepository implements BackupRepository {
@Override @Override
public boolean exists(URI path) throws IOException { public boolean exists(URI path) throws IOException {
log.debug("Checking whether URI exists: {}", path);
return Files.exists(Paths.get(path)); return Files.exists(Paths.get(path));
} }

View File

@ -1028,11 +1028,12 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
+ " parameter or as a default repository property or as a cluster property."); + " parameter or as a default repository property or as a cluster property.");
} }
} }
log.debug("Provided backup location is: {}", location);
boolean incremental = req.getParams().getBool(CoreAdminParams.BACKUP_INCREMENTAL, true); boolean incremental = req.getParams().getBool(CoreAdminParams.BACKUP_INCREMENTAL, true);
// Check if the specified location is valid for this repository. // Check if the specified location is valid for this repository.
final URI uri = repository.createURI(location); final URI uri = repository.createURI(location);
log.debug("Provided backup location uri is: {}", uri);
try { try {
if (!repository.exists(uri)) { if (!repository.exists(uri)) {
throw new SolrException(ErrorCode.SERVER_ERROR, "specified location " + uri + " does not exist."); throw new SolrException(ErrorCode.SERVER_ERROR, "specified location " + uri + " does not exist.");

View File

@ -27,6 +27,7 @@ import org.apache.solr.core.backup.ShardBackupMetadata;
import org.apache.solr.core.backup.repository.BackupRepository; import org.apache.solr.core.backup.repository.BackupRepository;
import org.apache.solr.handler.admin.CoreAdminHandler; import org.apache.solr.handler.admin.CoreAdminHandler;
import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.LogLevel;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -37,6 +38,7 @@ import java.net.URI;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
@LogLevel("org.apache.solr.cloud.api.collections.BackupCmd=DEBUG;org.apache.solr.handler.admin.BackupCoreOp=DEBUG;org.apache.solr.core.backup.repository.LocalFileSystemRepository=DEBUG")
public class TestIncrementalCoreBackup extends SolrTestCaseJ4 { public class TestIncrementalCoreBackup extends SolrTestCaseJ4 {
@Before // unique core per test @Before // unique core per test
public void coreInit() throws Exception { public void coreInit() throws Exception {