Skip to content

Commit

Permalink
fix epoch migration bug (#592)
Browse files Browse the repository at this point in the history
Refactors the epoch system migration to prevent downgrade shenanigans
and jankery when pilots booted 3 -> 2 -> 3, or other similar
permutations. We use the version number in the `META` database of
`log/data.mdb` as our migration indicator now instead of the
(non-)existence of `log/data.mdb`.
  • Loading branch information
pkova authored Jan 30, 2024
2 parents 46e7fa9 + d28cbd3 commit d400723
Show file tree
Hide file tree
Showing 7 changed files with 393 additions and 165 deletions.
6 changes: 3 additions & 3 deletions pkg/noun/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,10 @@ _ce_patch_verify(u3_ce_patch* pat_u)
c3_zs ret_zs;
c3_o sou_o = c3n; // south seen

if ( U3E_VERLAT != pat_u->con_u->ver_w ) {
if ( U3P_VERLAT != pat_u->con_u->ver_w ) {
fprintf(stderr, "loom: patch version mismatch: have %"PRIc3_w", need %u\r\n",
pat_u->con_u->ver_w,
U3E_VERLAT);
U3P_VERLAT);
return c3n;
}

Expand Down Expand Up @@ -737,7 +737,7 @@ _ce_patch_compose(c3_w nor_w, c3_w sou_w)

_ce_patch_create(pat_u);
pat_u->con_u = c3_malloc(sizeof(u3e_control) + (pgs_w * sizeof(u3e_line)));
pat_u->con_u->ver_w = U3E_VERLAT;
pat_u->con_u->ver_w = U3P_VERLAT;
pgc_w = 0;

for ( i_w = 0; i_w < nor_w; i_w++ ) {
Expand Down
22 changes: 17 additions & 5 deletions pkg/noun/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@ typedef c3_w u3v_version;
#define U3V_VER3 3
#define U3V_VERLAT U3V_VER3

/* EVENTS
/* PATCHES
*/

typedef c3_w u3e_version;

#define U3E_VER1 1
#define U3E_VERLAT U3E_VER1
#define U3P_VER1 1
#define U3P_VERLAT U3P_VER1

/* DISK FORMAT
*
* synchronized between:
* - u3_disk->ver_w
* - version key in META table of data.mdb files
*/

#define U3D_VER1 1
#define U3D_VERLAT U3L_VER1
#define U3D_VER1 1 // <= vere-v2
#define U3D_VER2 2 // migrating to >= vere-v3
#define U3D_VER3 3 // >= vere-v3
#define U3D_VERLAT U3D_VER3

/* EPOCH SYSTEM
*/

#define U3E_VER1 1
#define U3E_VERLAT U3E_VER1

#endif /* ifndef U3_VERSION_H */
Loading

0 comments on commit d400723

Please sign in to comment.