public void setBackgroundException(DbException e) { if (backgroundException == null) { backgroundException = e; TraceSystem t = getTraceSystem(); if (t != null) { t.getTrace(Trace.DATABASE).error(e, "flush"); } } }
private synchronized void closeFiles() { try { if (mvStore != null) { mvStore.closeImmediately(); } if (pageStore != null) { pageStore.close(); pageStore = null; } } catch (DbException e) { trace.error(e, "close"); } }
private synchronized void closeAllSessionsException(Session except) { Session[] all = userSessions.toArray(new Session[userSessions.size()]); for (Session s : all) { if (s != except) { try { // must roll back, otherwise the session is removed and // the transaction log that contains its uncommitted // operations as well s.rollback(); s.close(); } catch (DbException e) { trace.error(e, "disconnecting session #{0}", s.getId()); } } } }
private void closeOld() { while (true) { CloseWatcher w = CloseWatcher.pollUnclosed(); if (w == null) { break; } try { w.getCloseable().close(); } catch (Exception e) { trace.error(e, "closing session"); } // there was an unclosed object - // keep the stack trace from now on keepOpenStackTrace = true; String s = w.getOpenStackTrace(); Exception ex = DbException .get(ErrorCode.TRACE_CONNECTION_NOT_CLOSED); trace.error(ex, s); } }
trace.error(e, "could not close the database");
/** * Redo a delete in a table. * * @param tableId the object id of the table * @param key the key of the row to delete */ void redoDelete(int tableId, long key) { Index index = metaObjects.get(tableId); PageDataIndex scan = (PageDataIndex) index; Row row = scan.getRowWithKey(key); if (row == null || row.getKey() != key) { trace.error(null, "Entry not found: " + key + " found instead: " + row + " - ignoring"); return; } redo(tableId, row, false); }
private void sendClose() { if (session == null) { return; } // TODO result sets: no reset possible for larger remote result sets try { synchronized (session) { session.traceOperation("RESULT_CLOSE", id); transfer.writeInt(SessionRemote.RESULT_CLOSE).writeInt(id); } } catch (IOException e) { trace.error(e, "close"); } finally { transfer = null; session = null; } }
public void setLogMode(int log) { if (log < 0 || log > 2) { throw DbException.getInvalidValueException("LOG", log); } if (pageStore != null) { if (log != PageStore.LOG_MODE_SYNC || pageStore.getLogMode() != PageStore.LOG_MODE_SYNC) { // write the log mode in the trace file when enabling or // disabling a dangerous mode trace.error(null, "log {0}", log); } this.logMode = log; pageStore.setLogMode(log); } if (mvStore != null) { this.logMode = log; } }
private void removeOrphanedLobs() { // remove all session variables and temporary lobs if (!persistent) { return; } boolean lobStorageIsUsed = infoSchema.findTableOrView( systemSession, LobStorageBackend.LOB_DATA_TABLE) != null; lobStorageIsUsed |= mvStore != null; if (!lobStorageIsUsed) { return; } try { getLobStorage(); lobStorage.removeAllForTable( LobStorageFrontend.TABLE_ID_SESSION_VARIABLE); } catch (DbException e) { trace.error(e, "close"); } }
/** * Log an exception and convert it to a SQL exception if required. * * @param ex the exception * @return the SQL exception object */ protected SQLException logAndConvert(Throwable ex) { SQLException e = null; try { e = DbException.toSQLException(ex); if (trace == null) { DbException.traceThrowable(e); } else { int errorCode = e.getErrorCode(); if (errorCode >= 23000 && errorCode < 24000) { trace.info(e, "exception"); } else { trace.error(e, "exception"); } } } catch(Throwable ignore) { if (e == null) { e = new SQLException("", "HY000", ex); } e.addSuppressed(ignore); } return e; }
@Override public void close() { if (session == null || session.isClosed()) { return; } synchronized (session) { session.traceOperation("COMMAND_CLOSE", id); for (Transfer transfer : transferList) { try { transfer.writeInt(SessionRemote.COMMAND_CLOSE).writeInt(id); } catch (IOException e) { trace.error(e, "close"); } } } session = null; try { for (ParameterInterface p : parameters) { Value v = p.getParamValue(); if (v != null) { v.remove(); } } } catch (DbException e) { trace.error(e, "close"); } parameters.clear(); }
TraceSystem traceSystem = database.getTraceSystem(); if (traceSystem != null) { traceSystem.getTrace(Trace.DATABASE).error(e, "flush");
@Override public void close() { RuntimeException closeError = null; if (transferList != null) { synchronized (this) { for (Transfer transfer : transferList) { try { traceOperation("SESSION_CLOSE", 0); transfer.writeInt(SessionRemote.SESSION_CLOSE); done(transfer); transfer.close(); } catch (RuntimeException e) { trace.error(e, "close"); closeError = e; } catch (Exception e) { trace.error(e, "close"); } } } transferList = null; } traceSystem.close(); if (embedded != null) { embedded.close(); embedded = null; } if (closeError != null) { throw closeError; } }
if (e instanceof DbException && !alreadyOpen) { trace.error(e, "opening {0}", databaseName);
} catch (Exception e) { trace.error(e, "readOnly {0}", readOnly);
private void rebuildIndex(Session session, MVIndex index, String indexName) { try { if (session.getDatabase().getMvStore() == null || index instanceof MVSpatialIndex) { // in-memory rebuildIndexBuffered(session, index); } else { rebuildIndexBlockMerge(session, index); } } catch (DbException e) { getSchema().freeUniqueName(indexName); try { index.remove(session); } catch (DbException e2) { // this could happen, for example on failure in the storage // but if that is not the case it means // there is something wrong with the database trace.error(e2, "could not remove index"); throw e2; } throw e; } }
/** * Execute the meta data statement. * * @param db the database * @param systemSession the system session * @param listener the database event listener */ void execute(Database db, Session systemSession, DatabaseEventListener listener) { try { Prepared command = systemSession.prepare(sql); command.setObjectId(id); command.update(); } catch (DbException e) { e = e.addSQL(sql); SQLException s = e.getSQLException(); db.getTrace(Trace.DATABASE).error(s, sql); if (listener != null) { listener.exceptionThrown(s, sql); // continue startup in this case } else { throw e; } } }
trace.error(e2, "could not undo operation"); throw e2;
trace.error(e2, "could not undo operation"); throw e2;
trace.error(null, "Transaction log could not be truncated; size: " + (newSize / 1024 / 1024) + " MB");