1060: ingest stuck when adding another data source during ingest

This commit is contained in:
Raman 2018-10-05 10:21:15 -04:00
parent 05b4298576
commit bfd8ed8325
2 changed files with 14 additions and 11 deletions

View File

@ -22,6 +22,7 @@ import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -627,7 +628,7 @@ public final class ImageGalleryController {
*/ */
abstract void cleanup(boolean success); abstract void cleanup(boolean success);
abstract void processFile(final AbstractFile f, DrawableDB.DrawableTransaction tr, CaseDbTransaction caseDBTransaction) throws TskCoreException; abstract void processFile(final AbstractFile f, DrawableDB.DrawableTransaction tr, CaseDbTransaction caseDBTransaction) throws TskCoreException, SQLException;
/** /**
* Gets a list of files to process. * Gets a list of files to process.
@ -690,7 +691,7 @@ public final class ImageGalleryController {
// pass true so that groupmanager is notified of the changes // pass true so that groupmanager is notified of the changes
taskDB.commitTransaction(drawableDbTransaction, true); taskDB.commitTransaction(drawableDbTransaction, true);
} catch (TskCoreException ex) { } catch (Exception ex) { // Exception Firewall - catch ALL exceptions, including Runtime exceptions, to make sure we rollback transaction and release locks in case of any error.
if (null != drawableDbTransaction) { if (null != drawableDbTransaction) {
taskDB.rollbackTransaction(drawableDbTransaction); taskDB.rollbackTransaction(drawableDbTransaction);
} }
@ -751,7 +752,7 @@ public final class ImageGalleryController {
} }
@Override @Override
void processFile(AbstractFile f, DrawableDB.DrawableTransaction tr, CaseDbTransaction caseDbTransaction) throws TskCoreException { void processFile(AbstractFile f, DrawableDB.DrawableTransaction tr, CaseDbTransaction caseDbTransaction) throws TskCoreException, SQLException {
final boolean known = f.getKnown() == TskData.FileKnown.KNOWN; final boolean known = f.getKnown() == TskData.FileKnown.KNOWN;
if (known) { if (known) {
@ -804,7 +805,7 @@ public final class ImageGalleryController {
} }
@Override @Override
void processFile(final AbstractFile f, DrawableDB.DrawableTransaction tr, CaseDbTransaction caseDBTransaction) { void processFile(final AbstractFile f, DrawableDB.DrawableTransaction tr, CaseDbTransaction caseDBTransaction) throws TskCoreException, SQLException {
taskDB.insertFile(DrawableFile.create(f, false, false), tr, caseDBTransaction); taskDB.insertFile(DrawableFile.create(f, false, false), tr, caseDBTransaction);
} }

View File

@ -271,7 +271,7 @@ public final class DrawableDB {
insertGroup(cat.getDisplayName(), DrawableAttribute.CATEGORY, caseDbTransaction); insertGroup(cat.getDisplayName(), DrawableAttribute.CATEGORY, caseDbTransaction);
} }
caseDbTransaction.commit(); caseDbTransaction.commit();
} catch (TskCoreException ex) { } catch (Exception ex) { // Exception Firewall - catch ALL exceptions, including Runtime exceptions, to make sure we rollback transaction and release locks in case of any error.
if (null != caseDbTransaction) { if (null != caseDbTransaction) {
try { try {
caseDbTransaction.rollback(); caseDbTransaction.rollback();
@ -804,7 +804,7 @@ public final class DrawableDB {
caseDbTransaction.commit(); caseDbTransaction.commit();
commitTransaction(trans, true); commitTransaction(trans, true);
} catch (TskCoreException ex) { } catch (Exception ex) { // Exception Firewall - catch ALL exceptions, including Runtime exceptions, to make sure we rollback transaction and release locks in case of any error.
if (null != caseDbTransaction) { if (null != caseDbTransaction) {
try { try {
caseDbTransaction.rollback(); caseDbTransaction.rollback();
@ -820,11 +820,11 @@ public final class DrawableDB {
} }
public void insertFile(DrawableFile f, DrawableTransaction tr, CaseDbTransaction caseDbTransaction) { public void insertFile(DrawableFile f, DrawableTransaction tr, CaseDbTransaction caseDbTransaction) throws TskCoreException, SQLException {
insertOrUpdateFile(f, tr, insertFileStmt, caseDbTransaction); insertOrUpdateFile(f, tr, insertFileStmt, caseDbTransaction);
} }
public void updateFile(DrawableFile f, DrawableTransaction tr, CaseDbTransaction caseDbTransaction) { public void updateFile(DrawableFile f, DrawableTransaction tr, CaseDbTransaction caseDbTransaction) throws TskCoreException, SQLException {
insertOrUpdateFile(f, tr, updateFileStmt, caseDbTransaction); insertOrUpdateFile(f, tr, updateFileStmt, caseDbTransaction);
} }
@ -958,7 +958,7 @@ public final class DrawableDB {
* @param tr a transaction to use, must not be null * @param tr a transaction to use, must not be null
* @param stmt the statement that does the actual inserting * @param stmt the statement that does the actual inserting
*/ */
private void insertOrUpdateFile(DrawableFile f, @Nonnull DrawableTransaction tr, @Nonnull PreparedStatement stmt, @Nonnull CaseDbTransaction caseDbTransaction) { private void insertOrUpdateFile(DrawableFile f, @Nonnull DrawableTransaction tr, @Nonnull PreparedStatement stmt, @Nonnull CaseDbTransaction caseDbTransaction) throws TskCoreException, SQLException {
if (tr.isClosed()) { if (tr.isClosed()) {
throw new IllegalArgumentException("can't update database with closed transaction"); throw new IllegalArgumentException("can't update database with closed transaction");
@ -1058,6 +1058,7 @@ public final class DrawableDB {
*/ */
if (Case.isCaseOpen()) { if (Case.isCaseOpen()) {
logger.log(Level.SEVERE, "failed to insert/update file" + f.getContentPathSafe(), ex); //NON-NLS logger.log(Level.SEVERE, "failed to insert/update file" + f.getContentPathSafe(), ex); //NON-NLS
throw ex;
} }
} finally { } finally {
@ -1380,7 +1381,7 @@ public final class DrawableDB {
* @param groupBy Type of the grouping (CATEGORY, MAKE, etc.) * @param groupBy Type of the grouping (CATEGORY, MAKE, etc.)
* @param caseDbTransaction transaction to use for CaseDB insert/updates * @param caseDbTransaction transaction to use for CaseDB insert/updates
*/ */
private void insertGroup(final String value, DrawableAttribute<?> groupBy, CaseDbTransaction caseDbTransaction) { private void insertGroup(final String value, DrawableAttribute<?> groupBy, CaseDbTransaction caseDbTransaction) throws TskCoreException {
insertGroup(0, value, groupBy, caseDbTransaction); insertGroup(0, value, groupBy, caseDbTransaction);
} }
@ -1392,7 +1393,7 @@ public final class DrawableDB {
* @param groupBy Type of the grouping (CATEGORY, MAKE, etc.) * @param groupBy Type of the grouping (CATEGORY, MAKE, etc.)
* @param caseDbTransaction transaction to use for CaseDB insert/updates * @param caseDbTransaction transaction to use for CaseDB insert/updates
*/ */
private void insertGroup(long ds_obj_id, final String value, DrawableAttribute<?> groupBy, CaseDbTransaction caseDbTransaction) { private void insertGroup(long ds_obj_id, final String value, DrawableAttribute<?> groupBy, CaseDbTransaction caseDbTransaction) throws TskCoreException {
// don't waste DB round trip if we recently added it // don't waste DB round trip if we recently added it
String cacheKey = Long.toString(ds_obj_id) + "_" + value + "_" + groupBy.getDisplayName(); String cacheKey = Long.toString(ds_obj_id) + "_" + value + "_" + groupBy.getDisplayName();
if (groupCache.getIfPresent(cacheKey) != null) if (groupCache.getIfPresent(cacheKey) != null)
@ -1411,6 +1412,7 @@ public final class DrawableDB {
// Don't need to report it if the case was closed // Don't need to report it if the case was closed
if (Case.isCaseOpen()) { if (Case.isCaseOpen()) {
logger.log(Level.SEVERE, "Unable to insert group", ex); //NON-NLS logger.log(Level.SEVERE, "Unable to insert group", ex); //NON-NLS
throw ex;
} }
} }
} }