Hello Thomas,
I've taken a look at the flushRedoLog method in the DiskFile. I may be
wrong, but could you explain how it supposed to work. If my log
contains and INSERT/UPDATE for a given record followed by the DELETE
for the same record then it seems like the log recovery would apply
the DELETE operation first and then follow that by the UPDATE/INSERT.
Would that not break the correct sequence and corrupt the data ?
Below is the code I am looking at:
public void flushRedoLog() throws SQLException {
synchronized (database) {
if (redoBuffer.size() == 0) {
return;
}
redoBuffer.sort(new Comparator() {
public int compare(Object o1, Object o2) {
RedoLogRecord e1 = (RedoLogRecord) o1;
RedoLogRecord e2 = (RedoLogRecord) o2;
int comp = e1.recordId - e2.recordId;
if (comp == 0) {
comp = e1.sequenceId - e2.sequenceId;
}
return comp;
}
});
// first write all deleted entries
RedoLogRecord last = null;
for (int i = 0; i < redoBuffer.size(); i++) {
RedoLogRecord entry = (RedoLogRecord)
redoBuffer.get(i);
if (entry.data != null) {
continue;
}
if (last != null && entry.recordId != last.recordId) {
writeRedoLog(last);
}
last = entry;
}
if (last != null) {
writeRedoLog(last);
}
// now write the last entry, skipping deleted entries
last = null;
for (int i = 0; i < redoBuffer.size(); i++) {
RedoLogRecord entry = (RedoLogRecord)
redoBuffer.get(i);
if (last != null && entry.recordId != last.recordId) {
if (last.data != null) {
writeRedoLog(last);
}
}
last = entry;
}
if (last != null && last.data != null) {
writeRedoLog(last);
}
redoBuffer.clear();
redoBufferSize = 0;
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---