Skip to content

Commit

Permalink
[ASTERIXDB-2497][TX] Ensure Log Record Flush LSN is Set
Browse files Browse the repository at this point in the history
- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Set the flush LSN of log records before giving it
  to the log flusher to avoid reading invalid value
  if the flush is completed before setting the LSN.
- Ensure log record LSN is thread-safe.
- Warn in case of a flush with LSN = 0.

Change-Id: Ifc605c2d794339a3dc5004b462eca50ec103c717
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3087
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Reviewed-by: Till Westmann <tillw@apache.org>
  • Loading branch information
mhubail committed Dec 15, 2018
1 parent 376cde4 commit 440e3a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Expand Up @@ -201,6 +201,9 @@ public synchronized void triggerScheduleFlush(LogRecord logRecord) throws Hyrack
}
idGenerator.refresh();
long flushLsn = logRecord.getLSN();
if (flushLsn == 0) {
LOGGER.warn("flushing an index with LSN 0. Flush log record: {}", logRecord::getLogRecordForDisplay);
}
ILSMComponentId nextComponentId = idGenerator.getId();
Map<String, Object> flushMap = new HashMap<>();
flushMap.put(LSMIOOperationCallback.KEY_FLUSH_LOG_LSN, flushLsn);
Expand Down
Expand Up @@ -88,7 +88,7 @@ public class LogRecord implements ILogRecord {
private final ILogMarkerCallback callback; // A callback for log mark operations
private int PKFieldCnt;
private ITransactionContext txnCtx;
private long LSN;
private volatile long LSN;
private final AtomicBoolean isFlushed;
private final PrimaryKeyTupleReference readPKValue;
private final SimpleTupleReference readNewValue;
Expand Down
Expand Up @@ -187,10 +187,10 @@ synchronized void syncAppendToLogTail(ILogRecord logRecord) {
}
final int logSize = logRecord.getLogSize();
ensureSpace(logSize);
appendPage.append(logRecord, appendLSN.get());
if (logRecord.getLogType() == LogType.FLUSH) {
logRecord.setLSN(appendLSN.get());
}
appendPage.append(logRecord, appendLSN.get());
if (logRecord.isMarker()) {
logRecord.logAppended(appendLSN.get());
}
Expand Down

0 comments on commit 440e3a5

Please sign in to comment.