Changeset: 51d4e8ec61a7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=51d4e8ec61a7
Modified Files:
gdk/gdk_logger.c
Branch: HTM
Log Message:
Fix non-persistes and transactions behaviour of restore
Also fix again persisted transactions
diffs (141 lines):
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -95,6 +95,7 @@ typedef struct logformat_t {
int tid;
lng nr;
lng htm_id;
+ lng global_commit;
} logformat;
static int bm_commit(logger *lg);
@@ -189,7 +190,8 @@ log_read_format(logger *l, logformat *da
return mnstr_read(l->log, &data->flag, 1, 1) == 1 &&
mnstr_readLng(l->log, &data->nr) == 1 &&
mnstr_readInt(l->log, &data->tid) == 1 &&
- mnstr_readLng(l->log, &data->htm_id) == 1;
+ mnstr_readLng(l->log, &data->htm_id) == 1 &&
+ mnstr_readLng(l->log, &data->global_commit) == 1;
}
static int
@@ -198,7 +200,8 @@ log_write_format(logger *l, logformat *d
if (mnstr_write(l->log, &data->flag, 1, 1) == 1 &&
mnstr_writeLng(l->log, data->nr) &&
mnstr_writeInt(l->log, data->tid) &&
- mnstr_writeLng(l->log, data->htm_id))
+ mnstr_writeLng(l->log, data->htm_id) &&
+ mnstr_writeLng(l->log, data->global_commit))
return LOG_OK;
fprintf(stderr, "!ERROR: log_write_format: write failed\n");
return LOG_ERR;
@@ -1012,7 +1015,9 @@ logger_readlog(logger *lg, char *filenam
err = 1;
else if (l.tid != l.nr) /* abort record */
tr = tr_abort(lg, tr);
- else if (l.htm_id > -1) /* otherwise the transaction
might not be globally committed */
+ else if (l.htm_id == 0 || (l.htm_id > 0 &&
l.global_commit == 1))
+ /* htm == 0: not a 2-pahse transaction
+ otherwise the transaction might must be globally committed to
re-commit */
tr = tr_commit(lg, tr);
break;
case LOG_SEQ:
@@ -2222,6 +2227,7 @@ log_bat_persists(logger *lg, BAT *b, con
l.flag = flag;
l.tid = lg->tid;
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
lg->changes++;
if (log_write_format(lg, &l) == LOG_ERR ||
log_write_string(lg, name) == LOG_ERR)
@@ -2288,6 +2294,7 @@ log_bat_transient(logger *lg, const char
l.tid = lg->tid;
l.nr = 0;
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
lg->changes++;
/* if this is a snapshot bat, we need to skip all changes */
@@ -2349,6 +2356,7 @@ log_delta(logger *lg, BAT *uid, BAT *uva
l.tid = lg->tid;
l.nr = (BUNlast(uval) - BUNfirst(uval));
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
lg->changes += l.nr;
if (l.nr) {
@@ -2393,6 +2401,7 @@ log_bat(logger *lg, BAT *b, const char *
l.tid = lg->tid;
l.nr = (BUNlast(b) - b->batInserted);
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
lg->changes += l.nr;
if (l.nr) {
@@ -2467,6 +2476,7 @@ log_bat_clear(logger *lg, const char *na
l.nr = 1;
l.tid = lg->tid;
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
lg->changes += l.nr;
l.flag = LOG_CLEAR;
@@ -2490,6 +2500,7 @@ log_tstart(logger *lg, lng htm_id)
l.nr = lg->tid;
lg->htm_id = htm_id;
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
if (lg->debug & 1)
fprintf(stderr, "#log_tstart %d:" LLFMT "\n", lg->tid, htm_id);
@@ -2506,11 +2517,17 @@ log_globalpersist(logger *lg, lng htm_id
l.tid = lg->tid;
l.nr = lg->tid;
l.htm_id = htm_id;
+ l.global_commit = 1;
if (lg->debug & 1)
fprintf(stderr, "#log_globalpersist %d:" LLFMT "\n", lg->tid,
htm_id);
- return log_write_format(lg, &l);
+ if (log_write_format(lg, &l) == LOG_ERR ||
+ mnstr_flush(lg->log) ||
+ mnstr_fsync(lg->log)) {
+ return LOG_ERR;
+ }
+ return LOG_OK;
}
#define DBLKSZ 8192
@@ -2585,6 +2602,7 @@ log_tend(logger *lg)
l.tid = lg->tid;
l.nr = lg->tid;
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
if (res != GDK_SUCCEED ||
log_write_format(lg, &l) == LOG_ERR ||
mnstr_flush(lg->log) ||
@@ -2608,10 +2626,13 @@ log_abort(logger *lg)
l.tid = lg->tid;
l.nr = -1;
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
- if (log_write_format(lg, &l) == LOG_ERR)
+ if (log_write_format(lg, &l) == LOG_ERR ||
+ mnstr_flush(lg->log) ||
+ mnstr_fsync(lg->log)) {
return LOG_ERR;
-
+ }
return LOG_OK;
}
@@ -2624,6 +2645,7 @@ log_sequence_(logger *lg, int seq, lng v
l.tid = lg->tid;
l.nr = seq;
l.htm_id = lg->htm_id;
+ l.global_commit = 0;
if (lg->debug & 1)
fprintf(stderr, "#log_sequence_ (%d," LLFMT ")\n", seq, val);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list