Repository navigation
fix(tsdb): Write measurement deletions to fields.idxl - #27717
davidby-influx merged 2 commits into
Conversation
DROP MEASUREMENT, DROP SERIES and DELETE that remove the last series of a measurement save DeleteMeasurement field changes with a nil Field. marshalFieldChanges only appended changes with a non-nil Field, so the deletion was never persisted and a delete-only batch was written as an empty record After an unclean stop the change log was replayed without the deletion, so a later field of a different type failed with "field type conflict" and the shard could not open anymore Append every change to the record and leave Field unset for deletions Ignore a nil Field when replaying the change log instead of panicking and guard the marshal error message against a nil Field Add a regression test that reopens the field set with a deletion followed by a new field type Fixes influxdata#27699
|
The The same job passes on |
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes address the reported serialization and replay failure, with regression coverage and no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes #27699 by preserving measurement deletions in the field change log, preventing field-type conflicts during shard recovery after an unclean shutdown.
Changes:
- Serialize deletion records even when their
Fieldis nil. - Handle nil fields safely during replay and marshal-error reporting.
- Add a regression test that reopens the field set after deleting and recreating a field with a different type.
| File | Description |
|---|---|
tsdb/shard.go |
Preserves deletion records and handles nil fields safely. |
tsdb/shard_test.go |
Tests deletion replay followed by field recreation with a new type. |
Review effort: Balanced
Convert the new deletion replay regression test from conditional Fatalf checks to require NoError, NotNil and Equal assertions as requested in review
|
All review comments are addressed in 9dfe6c5 - the new test now uses require NoError, require NotNil and require Equal throughout, and the threads are resolved @davidby-influx could you take another look when you have a moment Verified locally - the tsdb field set tests pass, including TestMeasurementFieldSet_DeleteMeasurementReplay The build_packages failure is the fork CI image pull described earlier, not this change |
davidby-influx
left a comment
There was a problem hiding this comment.
Thanks for improving the tests,
Fixes #27699
DROP MEASUREMENT,DROP SERIESandDELETEthat remove the last series of a measurement saveDeleteMeasurementfield changes withField == nilmarshalFieldChangesonly appended changes with a non-nilField, so every deletion was dropped and a delete-only batch was written as an empty recordAfter an unclean stop the change log was replayed without the deletion, so a field written later with a different type failed with
field type conflictand the shard could not open anymore, not even on later clean restartsChanges
Fieldunset for deletionsFieldwhen replaying the change log instead of panickingFieldTesting
Reproduced with a locally built
influxdusing the steps from the issueWithout the fix
fields.idxlends with the record lengths0f 0c 00 0c, where00is the empty delete record, and afterkill -9the shard fails withfield type conflictsokeepis not queryableWith the fix
fields.idxlcontains the deletion record, the shard opens afterkill -9,keepis queryable andm.fis a floatgo test ./tsdb -count=1passgo test ./tsdb/engine/tsm1 -run TestEngine_Delete -count=1passgo vet ./tsdbpassgofmt clean
CHANGELOG.md updated - no entry needed, CHANGELOG.md refers to the external release notes
Rebased/mergable
Tests pass
Sign CLA