Skip to content

fix(tsdb): Write measurement deletions to fields.idxl - #27717

Merged
davidby-influx merged 2 commits into
influxdata:master-1.xfrom
akasakariko:fix/27699-fields-idxl-delete
Oct 27, 2026
Merged

davidby-influx merged 2 commits into
influxdata:master-1.xfrom
akasakariko:fix/27699-fields-idxl-delete

Conversation

@akasakariko

@akasakariko akasakariko commented Oct 22, 2026 •

Copy link
Copy Markdown

Fixes #27699

DROP MEASUREMENT, DROP SERIES and DELETE that remove the last series of a measurement save DeleteMeasurement field changes with Field == nil

marshalFieldChanges only appended changes with a non-nil Field, so every deletion was dropped 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 field written later with a different type failed with field type conflict and the shard could not open anymore, not even on later clean restarts

Changes

  • Always append the change to the record, leaving Field unset for deletions
  • Ignore a nil Field when replaying the change log instead of panicking
  • 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

Testing

Reproduced with a locally built influxd using the steps from the issue

Without the fix fields.idxl ends with the record lengths 0f 0c 00 0c, where 00 is the empty delete record, and after kill -9 the shard fails with field type conflict so keep is not queryable

With the fix fields.idxl contains the deletion record, the shard opens after kill -9, keep is queryable and m.f is a float

  • go test ./tsdb -count=1 pass

  • go test ./tsdb/engine/tsm1 -run TestEngine_Delete -count=1 pass

  • go vet ./tsdb pass

  • gofmt clean

  • CHANGELOG.md updated - no entry needed, CHANGELOG.md refers to the external release notes

  • Rebased/mergable

  • Tests pass

  • Sign CLA

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
@akasakariko

Copy link
Copy Markdown
Author

The build_packages job fails in Spin up environment because pulling us-east1-docker.pkg.dev/influxdata-team-edge/ci-support/ci-packager-next from a fork returns 403 Forbidden

The same job passes on master-1.x (517347) and build_binaries, the three unit test jobs, fluxtest and static_code_checks pass on this branch

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 Field is 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

@davidby-influx davidby-influx left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission! Would you change the tests to use the testify functions like require.NoError, require.NotNil, etc. everywhere there is a conditional and call to t.Fatalf? Thank you!

Comment thread tsdb/shard_test.go Resolved
Comment thread tsdb/shard_test.go Resolved
Comment thread tsdb/shard_test.go Resolved
Comment thread tsdb/shard_test.go Resolved
Comment thread tsdb/shard_test.go Resolved
Convert the new deletion replay regression test from conditional
Fatalf checks to require NoError, NotNil and Equal assertions
as requested in review
@akasakariko

akasakariko commented Oct 24, 2026 •

Copy link
Copy Markdown
Author

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change preserving measurement deletions during field-set recovery.

No open issues 🎉

Review effort: Balanced

@davidby-influx davidby-influx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving the tests,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.12: DROP MEASUREMENT / DELETE not written to fields.idxl; after an unclean stop the shard fails to open forever with "field type conflict"

3 participants