dovecot-2.1: mdbox: Detect duplicate GUIDs for different message...

dovecot at dovecot.org dovecot at dovecot.org
Thu Feb 9 02:34:44 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/408350532a18
changeset: 14087:408350532a18
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Feb 09 02:34:23 2012 +0200
description:
mdbox: Detect duplicate GUIDs for different messages. Don't delete these duplicates.
Only the message size is used for detecting if they are duplicates or not,
but since this shouldn't normally happen anyway this is good enough.

diffstat:

 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r e4272971f86f -r 408350532a18 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Thu Feb 09 02:25:18 2012 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Thu Feb 09 02:34:23 2012 +0200
@@ -127,7 +127,7 @@
 			      struct dbox_file *file, uint32_t file_id)
 {
 	const char *guid;
-	struct mdbox_rebuild_msg *rec;
+	struct mdbox_rebuild_msg *rec, *old_rec;
 	uoff_t offset, prev_offset;
 	bool last, first, fixed = FALSE;
 	int ret;
@@ -180,12 +180,20 @@
 		i_assert(!guid_128_is_empty(rec->guid_128));
 		array_append(&ctx->msgs, &rec, 1);
 
-		if (hash_table_lookup(ctx->guid_hash, rec->guid_128) != NULL) {
+		old_rec = hash_table_lookup(ctx->guid_hash, rec->guid_128);
+		if (old_rec == NULL)
+			hash_table_insert(ctx->guid_hash, rec->guid_128, rec);
+		else if (rec->size == old_rec->size) {
 			/* duplicate. save this as a refcount=0 to map,
 			   so it will eventually be deleted. */
 			rec->seen_zero_ref_in_map = TRUE;
 		} else {
-			hash_table_insert(ctx->guid_hash, rec->guid_128, rec);
+			/* duplicate GUID, but not a duplicate message. */
+			i_error("mdbox %s: Duplicate GUID %s in "
+				"m.%u:%u and m.%u:%u",
+				ctx->storage->storage_dir, guid,
+				old_rec->file_id, old_rec->offset,
+				rec->file_id, rec->offset);
 		}
 	}
 	if (ret < 0)


More information about the dovecot-cvs mailing list