Skip to content

Commit

Permalink
play: support full replay of unmigrated piers without valid snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Jul 5, 2023
1 parent 5e3f253 commit 1140c4e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
20 changes: 16 additions & 4 deletions pkg/vere/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,23 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
return 0;
}

// migrate to the correct disk format if necessary
// try migrating the disk format
if ( c3n == u3_disk_migrate(log_u) ) {
fprintf(stderr, "disk: failed to migrate to v%d\r\n", U3D_VER1);
c3_free(log_u);
return 0;
fprintf(stderr, "disk: loading old format\r\n");

if ( 0 == (log_u->mdb_u = u3_lmdb_init(log_c, siz_i)) ) {
fprintf(stderr, "disk: failed to initialize lmdb\r\n");
c3_free(log_u);
}

c3_d fir_d;
if ( c3n == u3_lmdb_gulf(log_u->mdb_u, &fir_d, &log_u->dun_d) ) {
fprintf(stderr, "disk: failed to load latest event from lmdb\r\n");
c3_free(log_u);
return 0;
}

return log_u;
}

// get latest epoch number
Expand Down
14 changes: 11 additions & 3 deletions pkg/vere/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1924,12 +1924,12 @@ _cw_meld(c3_i argc, c3_c* argv[])
exit(1);
}

u3C.wag_w |= u3o_hashless;

u3_Host.eve_d = u3m_boot(u3_Host.dir_c, (size_t)1 << u3_Host.ops_u.lom_y);
u3_disk* log_u = _cw_disk_init(u3_Host.dir_c); // XX s/b try_aquire lock
c3_w pre_w;

u3C.wag_w |= u3o_hashless;

pre_w = u3a_open(u3R);
u3u_meld();
u3a_print_memory(stderr, "urbit: meld: gained", u3u_meld());
Expand Down Expand Up @@ -2245,7 +2245,11 @@ _cw_play(c3_i argc, c3_c* argv[])

// XX handle SIGTSTP so that the lockfile is not orphaned?
//
u3_disk* log_u = _cw_disk_init(u3_Host.dir_c); // XX s/b try_aquire lock
u3_disk* log_u;
if ( 0 == (log_u = _cw_disk_init(u3_Host.dir_c)) ) {
fprintf(stderr, "mars: failed to load event log\r\n");
exit(1);
}

// Handle SIGTSTP as if it was SIGINT.
//
Expand Down Expand Up @@ -2281,6 +2285,10 @@ _cw_play(c3_i argc, c3_c* argv[])
};

u3_mars_play(&mar_u, eve_d, sap_d);

// migrate after replay, if necessary
u3_Host.eve_d = mar_u.dun_d;
u3_disk_migrate(log_u);
}

u3_disk_exit(log_u);
Expand Down

0 comments on commit 1140c4e

Please sign in to comment.