Skip to content

Commit

Permalink
Improve logging for catalog errors
Browse files Browse the repository at this point in the history
pr-link: #11727
change-id: cid-a83e08d7c28a950e7c6618c7515c2a10681a7942
  • Loading branch information
gpang committed Jul 8, 2020
1 parent ecbdbde commit b8cca5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Expand Up @@ -16,6 +16,8 @@
import com.google.common.base.MoreObjects;

import javax.annotation.Nullable;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -47,7 +49,11 @@ public DatabaseInfo(String location, String ownerName, PrincipalType ownerType,
mOwnerName = ownerName;
mOwnerType = ownerType;
mComment = comment;
mParameters = params;
if (params == null) {
mParameters = Collections.emptyMap();
} else {
mParameters = params;
}
}

/**
Expand Down
Expand Up @@ -129,6 +129,8 @@ public SyncStatus attachDatabase(JournalContext journalContext, String udbType,
} catch (Exception e) {
// Failed to connect to and sync the udb.
syncError = true;
// log the error and stack
LOG.error(String.format("Sync (during attach) failed for db '%s'.", dbName), e);
throw new IOException(String
.format("Failed to connect underDb for Alluxio db '%s': %s", dbName,
e.getMessage()), e);
Expand All @@ -153,6 +155,11 @@ public SyncStatus syncDatabase(JournalContext journalContext, String dbName) thr
try (LockResource l = getDbLock(dbName)) {
Database db = getDatabaseByName(dbName);
return db.sync(journalContext);
} catch (Exception e) {
// log the error and stack
LOG.error(String.format("Sync failed for db '%s'.", dbName), e);
throw new IOException(
String.format("Sync failed for db '%s'. error: %s", dbName, e.getMessage()), e);
}
}

Expand Down Expand Up @@ -209,7 +216,7 @@ public List<String> getAllDatabases() throws IOException {
* @param dbName database name
* @return a database object
*/
public alluxio.grpc.table.Database getDatabase(String dbName) throws IOException {
public alluxio.grpc.table.Database getDatabase(String dbName) throws IOException {
Database db = getDatabaseByName(dbName);
DatabaseInfo dbInfo = db.getDatabaseInfo();

Expand Down

0 comments on commit b8cca5b

Please sign in to comment.