Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

play: exit if binary version mismatches latest epoch's #649

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pkg/vere/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ _disk_epoc_roll(u3_disk* log_u, c3_d epo_d)
fprintf(stderr, "disk: failed to read metadata\r\n");
goto fail3;
}

u3_lmdb_exit(log_u->mdb_u);
log_u->mdb_u = 0;

Expand Down Expand Up @@ -1416,7 +1416,7 @@ _disk_migrate(u3_disk* log_u, c3_d eve_d)
* 5. clobber old log/data.mdb with new log/tmp/data.mdb
* 6. open epoch lmdb and set it in log_u
*/

// NB: requires that log_u->mdb_u is initialized to log/data.mdb
// XX: put old log in separate pointer (old_u?)?

Expand Down Expand Up @@ -1509,7 +1509,7 @@ _disk_migrate(u3_disk* log_u, c3_d eve_d)
fprintf(stderr, "disk: failed to save metadata\r\n");
return c3n;
}

// atomic truncation of old log
//
u3_lmdb_exit(log_u->mdb_u);
Expand Down Expand Up @@ -1605,7 +1605,7 @@ u3_disk_kindly(u3_disk* log_u, c3_d eve_d)
} break;

case U3D_VER3: {
if ( (0 == log_u->epo_d) ||
if ( (0 == log_u->epo_d) ||
(c3y == _disk_vere_diff(log_u)) )
{
if ( c3n == _disk_epoc_roll(log_u, eve_d) ) {
Expand Down Expand Up @@ -1780,6 +1780,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
{
u3_disk* log_u = c3_calloc(sizeof(*log_u));
log_u->liv_o = c3n;
log_u->mis_o = c3n;
log_u->ted_o = c3n;
log_u->cb_u = cb_u;
log_u->red_u = 0;
Expand Down Expand Up @@ -1985,6 +1986,10 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
}
}

if ( c3y == _disk_vere_diff(log_u) ) {
log_u->mis_o = c3y;
}

return log_u;
} break;

Expand Down
5 changes: 5 additions & 0 deletions pkg/vere/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,11 @@ _cw_play_impl(c3_d eve_d, c3_d sap_d, c3_o mel_o, c3_o sof_o, c3_o ful_o)
//
u3_disk* log_u = _cw_disk_init(u3_Host.dir_c);

if ( c3y == log_u->mis_o ) {
fprintf(stderr, "mars: binary version mismatch\r\n");
exit(1);
}

// Handle SIGTSTP as if it was SIGINT.
//
// Configured here using signal() so as to be immediately available.
Expand Down
1 change: 1 addition & 0 deletions pkg/vere/vere.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@
u3_dire* com_u; // log directory
c3_o liv_o; // live
c3_w ver_w; // version (see version.h)
c3_o mis_o; // version/epoch mismatch
void* mdb_u; // lmdb env of current epoch
c3_d sen_d; // commit requested
c3_d dun_d; // committed
Expand Down
Loading