Return-Path: X-Original-To: apmail-asterixdb-dev-archive@minotaur.apache.org Delivered-To: apmail-asterixdb-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BA0E118220 for ; Thu, 13 Aug 2015 19:57:34 +0000 (UTC) Received: (qmail 6344 invoked by uid 500); 13 Aug 2015 19:57:31 -0000 Delivered-To: apmail-asterixdb-dev-archive@asterixdb.apache.org Received: (qmail 6287 invoked by uid 500); 13 Aug 2015 19:57:31 -0000 Mailing-List: contact dev-help@asterixdb.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.incubator.apache.org Delivered-To: mailing list dev@asterixdb.incubator.apache.org Received: (qmail 6276 invoked by uid 99); 13 Aug 2015 19:57:31 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Aug 2015 19:57:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 02F0B1AA06C for ; Thu, 13 Aug 2015 19:57:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.202 X-Spam-Level: ** X-Spam-Status: No, score=2.202 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, MISSING_HEADERS=1.207, RP_MATCHES_RCVD=-0.006, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id XoAlWv8Wmg6H for ; Thu, 13 Aug 2015 19:57:24 +0000 (UTC) Received: from unhygienix.ics.uci.edu (unhygienix.ics.uci.edu [128.195.14.130]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 2C62E42B42 for ; Thu, 13 Aug 2015 19:57:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by unhygienix.ics.uci.edu (Postfix) with ESMTP id 9C2DC240F97; Thu, 13 Aug 2015 12:55:39 -0700 (PDT) Date: Thu, 13 Aug 2015 12:55:39 -0700 From: "Murtadha Hubail (Code Review)" CC: Jenkins , Young-Seok Kim Reply-To: hubailmor@gmail.com X-Gerrit-MessageType: merged Subject: Change in asterixdb[master]: Fix for issue 923 X-Gerrit-Change-Id: I87053315fc7650682fcbedd573b1155c17810073 X-Gerrit-ChangeURL: X-Gerrit-Commit: 80db07f255488912660baca6a2b829f6a31f99fd In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.8.4 Message-Id: <20150813195539.9C2DC240F97@unhygienix.ics.uci.edu> Murtadha Hubail has submitted this change and it was merged. Change subject: Fix for issue 923 ...................................................................... Fix for issue 923 Change-Id: I87053315fc7650682fcbedd573b1155c17810073 Reviewed-on: https://asterix-gerrit.ics.uci.edu/347 Tested-by: Jenkins Reviewed-by: Young-Seok Kim --- M asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java 1 file changed, 33 insertions(+), 25 deletions(-) Approvals: Young-Seok Kim: Looks good to me, approved Jenkins: Verified diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java index 90a812b..2146eff 100644 --- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java +++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java @@ -65,6 +65,7 @@ private LogPage appendPage; private LogFlusher logFlusher; private Future futureLogFlusher; + private static final long SMALLEST_LOG_FILE_ID = 0; public LogManager(TransactionSubsystem txnSubsystem) throws ACIDException { this.txnSubsystem = txnSubsystem; @@ -77,7 +78,7 @@ logFilePrefix = logManagerProperties.getLogFilePrefix(); flushLSN = new MutableLong(); appendLSN = new AtomicLong(); - initializeLogManager(0); + initializeLogManager(SMALLEST_LOG_FILE_ID); } private void initializeLogManager(long nextLogFileId) { @@ -96,7 +97,7 @@ logFlusher = new LogFlusher(this, emptyQ, flushQ); futureLogFlusher = txnSubsystem.getAsterixAppRuntimeContextProvider().getThreadExecutor().submit(logFlusher); } - + @Override public void log(ILogRecord logRecord) throws ACIDException { if (logRecord.getLogSize() > logPageSize) { @@ -104,7 +105,7 @@ } syncLog(logRecord); - + if ((logRecord.getLogType() == LogType.JOB_COMMIT || logRecord.getLogType() == LogType.ABORT) && !logRecord.isFlushed()) { synchronized (logRecord) { @@ -121,12 +122,12 @@ private synchronized void syncLog(ILogRecord logRecord) throws ACIDException { ITransactionContext txnCtx = null; - - if(logRecord.getLogType() != LogType.FLUSH) - { + + if (logRecord.getLogType() != LogType.FLUSH) { txnCtx = logRecord.getTxnCtx(); if (txnCtx.getTxnState() == ITransactionManager.ABORTED && logRecord.getLogType() != LogType.ABORT) { - throw new ACIDException("Aborted job(" + txnCtx.getJobId() + ") tried to write non-abort type log record."); + throw new ACIDException("Aborted job(" + txnCtx.getJobId() + + ") tried to write non-abort type log record."); } } @@ -142,9 +143,8 @@ logRecord.setPrevLSN(txnCtx.getLastLSN()); } appendPage.append(logRecord, appendLSN.get()); - - if(logRecord.getLogType() == LogType.FLUSH) - { + + if (logRecord.getLogType() == LogType.FLUSH) { logRecord.setLSN(appendLSN.get()); } appendLSN.addAndGet(logRecord.getLogSize()); @@ -292,22 +292,22 @@ initializeLogManager(lastMaxLogFileId + 1); } - public void deleteOldLogFiles(long checkpointLSN){ + public void deleteOldLogFiles(long checkpointLSN) { Long checkpointLSNLogFileID = getLogFileId(checkpointLSN); List logFileIds = getLogFileIds(); - for (Long id : logFileIds) { - - if(id < checkpointLSNLogFileID) - { - File file = new File(getLogFilePath(id)); - if (!file.delete()) { - throw new IllegalStateException("Failed to delete a file: " + file.getAbsolutePath()); + if (logFileIds != null) { + for (Long id : logFileIds) { + if (id < checkpointLSNLogFileID) { + File file = new File(getLogFilePath(id)); + if (!file.delete()) { + throw new IllegalStateException("Failed to delete a file: " + file.getAbsolutePath()); + } } } } } - + private void terminateLogFlusher() { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Terminating LogFlusher thread ..."); @@ -336,13 +336,17 @@ } } List logFileIds = getLogFileIds(); - for (Long id : logFileIds) { - File file = new File(getLogFilePath(id)); - if (!file.delete()) { - throw new IllegalStateException("Failed to delete a file: " + file.getAbsolutePath()); + if (logFileIds != null) { + for (Long id : logFileIds) { + File file = new File(getLogFilePath(id)); + if (!file.delete()) { + throw new IllegalStateException("Failed to delete a file: " + file.getAbsolutePath()); + } } + return logFileIds.get(logFileIds.size() - 1); + } else { + throw new IllegalStateException("Couldn't find any log files."); } - return logFileIds.get(logFileIds.size() - 1); } private List getLogFileIds() { @@ -425,7 +429,11 @@ public long getReadableSmallestLSN() { List logFileIds = getLogFileIds(); - return logFileIds.get(0) * logFileSize; + if (logFileIds != null) { + return logFileIds.get(0) * logFileSize; + }else{ + throw new IllegalStateException("Couldn't find any log files."); + } } } -- To view, visit https://asterix-gerrit.ics.uci.edu/347 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I87053315fc7650682fcbedd573b1155c17810073 Gerrit-PatchSet: 4 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Murtadha Hubail Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Murtadha Hubail Gerrit-Reviewer: Young-Seok Kim