Skip to content

Commit e1cbc77

Browse files
committed
gossmap: use gossmap_disable_mmap() on corruption.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 2d09646 commit e1cbc77

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

gossipd/gossmap_manage.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,7 @@ static const u8 *fetch_tail_fd(const tal_t *ctx,
14111411
struct gossmap *gossmap_manage_get_gossmap(struct gossmap_manage *gm)
14121412
{
14131413
u64 map_used, map_size, written_len;
1414+
bool has_mmap = gossmap_has_mmap(gm->raw_gossmap);
14141415

14151416
gossmap_refresh(gm->raw_gossmap);
14161417

@@ -1419,10 +1420,12 @@ struct gossmap *gossmap_manage_get_gossmap(struct gossmap_manage *gm)
14191420
written_len = gossip_store_len_written(gm->gs);
14201421

14211422
if (map_size != written_len) {
1422-
status_broken("gossmap size %"PRIu64" != written size %"PRIu64,
1423-
map_size, written_len);
1424-
/* Push harder! */
1425-
gossip_store_fsync(gm->gs);
1423+
status_broken("gossmap size %"PRIu64" != written size %"PRIu64
1424+
": %s mmap!",
1425+
map_size, written_len,
1426+
has_mmap
1427+
? "disabling": "ALREADY DISABLED");
1428+
gossmap_disable_mmap(gm->raw_gossmap);
14261429
gossmap_refresh(gm->raw_gossmap);
14271430

14281431
/* Sanity check that we see everything we wrote. */
@@ -1439,11 +1442,21 @@ struct gossmap *gossmap_manage_get_gossmap(struct gossmap_manage *gm)
14391442
remainder_fd = fetch_tail_fd(tmpctx,
14401443
gossmap_fd(gm->raw_gossmap),
14411444
map_used, map_size);
1442-
status_failed(STATUS_FAIL_INTERNAL_ERROR,
1443-
"Gossmap failed to process entire gossip_store: "
1445+
status_broken("Gossmap failed to process entire gossip_store, %s mmap: "
14441446
"at %"PRIu64" of %"PRIu64" remaining_fd=%s",
1447+
has_mmap
1448+
? "disabling": "ALREADY DISABLED",
14451449
map_used, map_size,
14461450
tal_hex(tmpctx, remainder_fd));
1451+
gossmap_disable_mmap(gm->raw_gossmap);
1452+
gossmap_refresh(gm->raw_gossmap);
1453+
1454+
map_used = gossmap_lengths(gm->raw_gossmap, &map_size);
1455+
if (map_size != map_used) {
1456+
status_failed(STATUS_FAIL_INTERNAL_ERROR,
1457+
"Gossmap map_used %"PRIu64" of %"PRIu64" with %"PRIu64" written",
1458+
map_used, map_size, written_len);
1459+
}
14471460
}
14481461

14491462
return gm->raw_gossmap;

0 commit comments

Comments
 (0)