**What this PR does / why we need it**:
This PR fixes some bugs discovered while setting the default chunk
format yo _V4_ and the default head format to _unordered with
non-indexed labels_.
Note that this PR doesn't change the defaults, but fixes some bugs that
would prevent us from changing them in the future.
The bugs it fixes are:
- Index out-of-range panic when symbols' labels are empty and we do a
Lookup. **Test added**.
- When applying retention, new chunks wouldn't contain non-indexed
labels (caused by https://github.com/grafana/loki/pull/10090). **Test
added**.
- New chunks would fail to serialize non-indexed labels when applying
retention because the head format would be the [dummy one (ordered)][1]
[(used here via `c.headFmt`)][2]. **Cannot test unless we change the
default chunk/head format** but tested manually.
**Checklist**
- [ ] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](d10549e3ec)
[1]:
457f2e6ec0/pkg/chunkenc/memchunk.go (L375)
[2]:
24fd566833/pkg/chunkenc/memchunk.go (L1088-L1095)
// The alternative here could be going over all the blocks and using the size of the largest block as target block size but I(Sandeep) feel that it is not worth the complexity.
// For target chunk size I am using compressed size of original chunk since the newChunk should anyways be lower in size than that.