Skip to content

Commit

Permalink
wal: fix tsn calculations for mixed local/global space transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepetrenko committed Jul 27, 2023
1 parent 532bada commit fb1962f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/box/wal.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
struct xrow_header **end = entry->rows + entry->n_rows;
struct xrow_header **first_glob_row = entry->rows;
/** Assign LSN to all local rows. */
for (struct xrow_header **row = start; row < end; row++) {
for (struct xrow_header **row = start; row <= end; row++) {
if ((*row)->replica_id == 0) {
/*
* All rows representing local space data
Expand All @@ -988,11 +988,6 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
first_glob_row = row;
}
(*row)->tsn = tsn == 0 ? (*start)->lsn : tsn;
/* Tx meta is stored in the last tx row. */
if (row == end - 1) {
(*row)->flags = entry->flags;
(*row)->is_commit = true;
}
} else {
int64_t diff = (*row)->lsn - vclock_get(base, (*row)->replica_id);
if (diff <= vclock_get(vclock_diff,
Expand All @@ -1009,9 +1004,17 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
} else {
vclock_follow(vclock_diff, (*row)->replica_id, diff);
}
if (tsn == 0) {
tsn = (*row)->lsn;
first_glob_row = row;
}
(*row)->flags = 0;
(*row)->is_commit = false;
}
}

/* Tx meta is stored in the last tx row. */
*(end)->flags = entry->flags;
*(end)->is_commit = true;
/*
* Fill transaction id for all the local rows preceding
* the first global row. tsn was yet unknown when those
Expand Down

0 comments on commit fb1962f

Please sign in to comment.