nakabonne/tstorage

nil tail when recovering existing partitions

Opened this issue · 0 comments

When recovering / restoring from an existing data directory the tail is nil and results in a segment fault during inserting.

I have introduced a recovery mode on my fork but as a work around, I have added the following code to getTail on partitionListImpl.

func (p *partitionListImpl) getTail() partition {
	if p.size() <= 0 {
		return nil
	}
	p.mu.RLock()
	defer p.mu.RUnlock()

	if p.tail == nil {
		log.Warn("tail partition not found, attempting to recover tail")
		i := p.newIterator()
		for i.next() {
			p.tail = i.currentNode()
		}
	}

	return p.tail.value()
}