Yukang-Lian opened a new pull request, #67652:
URL: https://github.com/apache/doris/pull/67652
### What problem does this PR solve?
Issue Number: None
Related PR: #60544, #65184
Problem Summary:
In cloud mode, `ALTER TABLE ... SET ("disable_auto_compaction" = "false")`
never resumed automatic compaction on a BE that had previously observed
`disable_auto_compaction = true` for the same tablet. The scheduler kept
reporting the tablet as disabled (`num_disabled=1`, `tablets=[]`) until the BE
was restarted. The docker case
`cloud_p0/compaction/test_cloud_alter_disable_auto_compaction` fails
deterministically in its re-enable phase once the sync intervals are short
enough for the disable phase to pass (#65184).
Root cause:
`disable_auto_compaction` is carried by `TabletSchema`, and `TabletSchema`
objects are shared across tablets through `TabletSchemaCache`, keyed by the
serialized schema content (which includes this property).
`CloudTablet::sync_meta` applied the new value with
`mutable_tablet_schema()->set_disable_auto_compaction()`, i.e. it mutated the
shared cached object in place. This silently turned the cache entry of the
original (`false`) schema into an object whose content says `true`.
- ALTER to `true`: Meta Service returns a schema with `true`; its key is
new, so a fresh object is created and the local (shared) schema object is
mutated to `true`. Looks correct.
- ALTER back to `false`: Meta Service returns the original schema; its key
hits the polluted entry, so `TabletMeta::init_from_pb` hands back the very same
object the tablet already holds. `sync_meta` compares the object with itself,
sees no change, and the tablet stays disabled forever.
The same in-place mutation also leaked the value to every other tablet
sharing that schema object on the BE.
Fix:
- Keep the effective value in a per-tablet atomic on `CloudTablet`,
initialized from the tablet schema at load time and refreshed by `sync_meta`.
The shared `TabletSchema` is never mutated again, so cache entries always match
their keys.
- The compaction scheduler reads the per-tablet value.
### Release note
Fix `ALTER TABLE ... SET ("disable_auto_compaction" = "false")` not resuming
automatic compaction in cloud mode.
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [x] Regression test
- [x] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- `CloudTabletSyncMetaTest.TestSyncMetaDisableAutoCompactionRoundTrip`
reproduces the false -> true -> false round trip on the same tablet (fails
before this fix at the cache-pollution check and at the re-enable check) and
verifies the shared schema object stays untouched.
-
`CloudCompactionTest.disable_auto_compaction_toggle_is_read_from_tablet` covers
the scheduler honoring the per-tablet toggle.
- Existing
`cloud_p0/compaction/test_cloud_alter_disable_auto_compaction` docker case
covers the end-to-end path.
- Behavior changed:
- [x] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [x] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]