Skip to content

Commit

Permalink
re apache#3724: Tablet transaction log
Browse files Browse the repository at this point in the history
* Updated to always log even if no transactions
* Updated to clear the log when everything is consistent
  • Loading branch information
ivakegg committed Sep 5, 2023
1 parent d714745 commit 7932235
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,19 +583,25 @@ public MetadataUpdateCount getUpdateCount() {
return metadataUpdateCount.get();
}

public void logTransactions() {
if (!tabletLog.isEmpty()) {
log.error("Operation log: {}", tabletLog.dumpAndClearLog());
public void clearTransactions() {
tabletLog.clearLog();
}

public void resetTransactions() {
synchronized (tablet) {
tabletLog.resetLog(datafileSizes.keySet());
}
}

public void logTransactions() {
log.error("Operation log: {}", tabletLog.dumpLog());
}

public void checkTransactionLog() {
if (!tabletLog.isEmpty()) {
Set<StoredTabletFile> files = datafileSizes.keySet();
if (!tabletLog.isExpectedFiles(files)) {
log.error("In-memory files {} do not match transaction log {}", files);
logTransactions();
}
Set<StoredTabletFile> files = datafileSizes.keySet();
if (!tabletLog.isExpectedFiles(files)) {
log.error("In-memory files {} do not match transaction log {}", files);
logTransactions();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ public String dumpAndClearLog() {
return this.log.dumpLog(extent, true);
}

public void clearLog() {
this.log.clear();
}

public void resetLog(Set<StoredTabletFile> files) {
this.log.reset(files);
}

@Override
public String toString() {
return dumpLog();
Expand Down Expand Up @@ -184,6 +192,13 @@ public void clear() {
this.updateCount = this.tabletLog.getUpdateCount();
}

public void reset(Set<StoredTabletFile> files) {
this.tabletLog.clear();
this.initialTs = System.currentTimeMillis();
this.initialFiles = this.finalFiles = files.toArray(new StoredTabletFile[0]);
this.updateCount = this.tabletLog.getUpdateCount();
}

/**
* Add the passed in transaction, adjusting the log size as needed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,8 @@ private void closeConsistencyCheck() {
+ tabletMeta.getFilesMap() + " " + getDatafileManager().getDatafileSizes();
log.error(msg);
getDatafileManager().logTransactions();
} else {
getDatafileManager().clearTransactions();
}
} catch (Exception e) {
String msg = "Failed to do close consistency check for tablet " + extent;
Expand Down Expand Up @@ -1225,6 +1227,7 @@ public synchronized void compareTabletInfo(MetadataUpdateCount updateCounter,
log.trace("AMCC Tablet {} files in memory are same as in metadata table {}",
tabletMetadata.getExtent(), updateCounter);
}
getDatafileManager().clearTransactions();
}
}

Expand Down

0 comments on commit 7932235

Please sign in to comment.