diff --git a/src/controller/persist.c b/src/controller/persist.c index e39aad5..76e3e64 100644 --- a/src/controller/persist.c +++ b/src/controller/persist.c @@ -256,8 +256,12 @@ int persist_wal_async(persist_t* p, uint32_t type, p->last_replicated_crc = hdr.crc; /* Rotate segment when full */ - if (p->seg_offset >= WAL_SEGMENT_SIZE_BYTES) - rotate_segment(p); + if (p->seg_offset >= WAL_SEGMENT_SIZE_BYTES) { + if (rotate_segment(p) != 0) { + pthread_mutex_unlock(&p->lock); + return -EIO; + } + } pthread_mutex_unlock(&p->lock); return 0; diff --git a/src/include/persist.h b/src/include/persist.h index f139ad8..4d8af2b 100644 --- a/src/include/persist.h +++ b/src/include/persist.h @@ -89,8 +89,8 @@ struct persist_s { /* WAL state */ int wal_fd; uint64_t current_lsn; - uint64_t last_crc; - uint64_t last_replicated_crc; + uint32_t last_crc; + uint32_t last_replicated_crc; uint64_t term; uint32_t seg_offset; uint64_t checkpoint_lsn;