Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Recovery early stop

  • Loading branch information...
commit cc4de962204da96e2860d30da6cc024d000e8869 1 parent 90440d3
@dgomezferro authored
View
10 src/main/java/com/yahoo/omid/tso/persistence/BookKeeperStateBuilder.java
@@ -211,9 +211,9 @@ public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> entri
} else {
while(entries.hasMoreElements()){
LedgerEntry le = entries.nextElement();
- lp.execute(ByteBuffer.wrap(le.getEntry()));
+ boolean recovered = lp.execute(ByteBuffer.wrap(le.getEntry()));
- if(le.getEntryId() == 0){
+ if(recovered || le.getEntryId() == 0){
((BookKeeperStateBuilder.Context) ctx).setState(lp.getState());
}
}
@@ -279,10 +279,8 @@ public void loggerInitComplete(int rc, StateLogger sl, Object ctx){
try{
synchronized(ctx){
- int counter = 0;
- while(!ctx.isReady() || (counter > 10)){
- ctx.wait(1000);
- counter++;
+ while(!ctx.isReady()){
+ ctx.wait();
}
}
} catch (InterruptedException e) {
View
15 src/main/java/com/yahoo/omid/tso/persistence/LoggerProtocol.java
@@ -48,8 +48,14 @@
super(timestampOracle);
}
- void execute(ByteBuffer bb){
- boolean done = false;
+ /**
+ * Execute a logged entry (several logged ops)
+ * @param bb Serialized operations
+ * @return true if the recovery is finished
+ */
+ boolean execute(ByteBuffer bb){
@fpj
fpj added a note

The semantics of the return value is a bit confusing here and seems to be unrelated with the role of the method. Perhaps we should detect early termination outside execute(). What do you think?

@dgomezferro Owner

Makes sense, I'll change that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ boolean done = !bb.hasRemaining();
+ boolean recovered = false;
while(!done){
byte op = bb.get();
long timestamp, startTimestamp, commitTimestamp;
@@ -65,7 +71,9 @@ void execute(ByteBuffer bb){
startTimestamp = bb.getLong();
commitTimestamp = bb.getLong();
processCommit(startTimestamp, commitTimestamp);
-
+ if (commitTimestamp < largestDeletedTimestamp) {
+ recovered = true;
@fpj
fpj added a note

Once recovered is true, can't we return right away?

@dgomezferro Owner

No, because we are executing each entry's operations from oldest to newest (in the order they were added) so there could be some ops that we must reexecute at the end of this entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
break;
case LARGESTDELETEDTIMESTAMP:
timestamp = bb.getLong();
@@ -85,6 +93,7 @@ void execute(ByteBuffer bb){
}
if(bb.remaining() == 0) done = true;
}
+ return recovered;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.