]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Update comments about how transaction log corruption is handled
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 12 Feb 2024 08:58:55 +0000 (10:58 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 20 Oct 2025 05:53:35 +0000 (05:53 +0000)
src/lib-index/mail-index-private.h
src/lib-index/mail-index-sync-private.h
src/lib-index/mail-index-sync-update.c
src/lib-index/mail-transaction-log.h

index 856eb08b192bec9b31238ca4ad7952c5e2596417..2f5e1281118d3601a338c632d06237a84958edea 100644 (file)
@@ -358,7 +358,8 @@ struct mail_index_map *mail_index_map_alloc(struct mail_index *index);
 
    If we mmap()ed the index file, the map is returned locked.
 
-   Returns 1 = ok, 0 = corrupted, -1 = error. */
+   Returns 1 = ok, 0 = unusably corrupted, -1 = error. Corrupted records inside
+   the transaction log file doesn't cause this function to fail. */
 int mail_index_map(struct mail_index *index,
                   enum mail_index_sync_handler_type type);
 /* Unreference given mapping and unmap it if it's dropped to zero. */
index 094c83d90b88415d5a57bd05881334cc5b3e234f..ab41a41006dc921a51c27a187fec59594f4f82e2 100644 (file)
@@ -54,6 +54,9 @@ void mail_index_sync_map_init(struct mail_index_sync_map_ctx *sync_map_ctx,
 void mail_index_sync_map_deinit(struct mail_index_sync_map_ctx *sync_map_ctx);
 bool mail_index_sync_map_want_index_reopen(struct mail_index_map *map,
                                           enum mail_index_sync_handler_type type);
+/* Returns 1 if synced, 0 if map's log file is lost (or more likely, seq number
+   is corrupted), -1 on I/O error. Corrupted records inside the transaction log
+   file doesn't cause this function to fail. */
 int mail_index_sync_map(struct mail_index_map **_map,
                        enum mail_index_sync_handler_type type,
                        const char **reason_r);
index 16ea5aa088b598a25ebbf50cdf025fe7e817f001..82f03dda6b7aa622ee5ab05589537a519e21bc53 100644 (file)
@@ -1002,6 +1002,10 @@ int mail_index_sync_map(struct mail_index_map **_map,
        }
        map = NULL;
 
+       /* mail_transaction_log_view_next() returns -1 on corruption.
+          Since the log file content before the corruption was found can be
+          useful and important, we don't fail this sync entirely. Instead,
+          we'll just mark the rest of the log file as synced. */
        while ((ret = mail_transaction_log_view_next(view->log_view, &thdr,
                                                     &tdata)) > 0) {
                mail_transaction_log_view_get_prev_pos(view->log_view,
index b04c3aafcc7627ed23f4b4192fdf49b8464685b4..6779e30914979bf603fc1d153c3329aca80e9a68 100644 (file)
@@ -421,7 +421,7 @@ void mail_transaction_log_view_clear(struct mail_transaction_log_view *view,
                                     uint32_t oldest_file_seq);
 
 /* Read next transaction record from current position. The position is updated.
-   Returns -1 if error, 0 if we're at end of the view, 1 if ok. */
+   Returns -1 if log is corrupted, 0 if we're at end of the view, 1 if ok. */
 int mail_transaction_log_view_next(struct mail_transaction_log_view *view,
                                   const struct mail_transaction_header **hdr_r,
                                   const void **data_r);