浏览代码

Fix bug where old partitions weren't cleaned up

When we refresh a topic, discard all old partitions for that topic.
Evan Huus 12 年之前
父节点
当前提交
5e41ad652f
共有 1 个文件被更改,包括 1 次插入4 次删除
  1. 1 4
      broker_manager.go

+ 1 - 4
broker_manager.go

@@ -192,15 +192,12 @@ func (bm *brokerManager) refreshTopics(topics []*string) error {
 		if topic.err != NO_ERROR {
 		if topic.err != NO_ERROR {
 			return topic.err
 			return topic.err
 		}
 		}
+		bm.partitions[*topic.name] = make(map[int32]*partitionMetadata, len(topic.partitions))
 		for j := range topic.partitions {
 		for j := range topic.partitions {
 			partition := &topic.partitions[j]
 			partition := &topic.partitions[j]
 			if partition.err != NO_ERROR {
 			if partition.err != NO_ERROR {
 				return partition.err
 				return partition.err
 			}
 			}
-			id_map := bm.partitions[*topic.name]
-			if id_map == nil {
-				bm.partitions[*topic.name] = make(map[int32]*partitionMetadata)
-			}
 			bm.partitions[*topic.name][partition.id] = partition
 			bm.partitions[*topic.name][partition.id] = partition
 		}
 		}
 	}
 	}