Skip to content

iter.Valid() 卡死 #175

@cceessff

Description

@cceessff
func DeleteCache(prefix string) error {
	fmt.Println("DeleteCache:" + prefix)
	iter, err := db.NewIterator(lotusdb.IteratorOptions{
		Prefix: []byte(prefix),
	})

	if err != nil {
		return err
	}
	fmt.Println("DeleteCache: NewIterator ")

	batch := db.NewBatch(lotusdb.BatchOptions{
		WriteOptions: lotusdb.WriteOptions{
			Sync: false,
		},
	})
	for iter.Valid() {
		fmt.Println("DeleteCache: Valid")
		key := append([]byte(nil), iter.Key()...)
		fmt.Println("DeleteRandHtml=>" + string(key))
		err = batch.Delete(key)
		if err != nil {
			return err
		}
		iter.Next()

	}
	fmt.Println("DeleteCache: 循环完成 ")
	err = batch.Commit()
	if err != nil {
		return err
	}
	err = iter.Close()
	if err != nil {
		return err
	}

	return nil
}

在输出了 DeleteCache: NewIterator 之后程序就卡死了

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions