You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "Caideyipi (via GitHub)" <gi...@apache.org> on 2025/03/21 08:55:40 UTC
[PR] Enhance region deletion detection logic when concurrent error occurs [iotdb]
Caideyipi opened a new pull request, #15160:
URL: https://github.com/apache/iotdb/pull/15160
## Description
As the title said.
<!--
In each section, please describe design decisions made, including:
- Choice of algorithms
- Behavioral aspects. What configuration values are acceptable? How are corner cases and error
conditions handled, such as when there are insufficient resources?
- Class organization and design (how the logic is split between classes, inheritance, composition,
design patterns)
- Method organization and design (how the logic is split between methods, parameters and return types)
- Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
-->
<!-- It's good to describe an alternative design (or mention an alternative name) for every design
(or naming) decision point and compare the alternatives with the designs that you've implemented
(or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
<!-- If there was a discussion of the design of the feature implemented in this PR elsewhere
(e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list),
link to that discussion from this PR description and explain what have changed in your final design
compared to your original proposal or the consensus version in the end of the discussion.
If something hasn't changed since the original discussion, you can omit a detailed discussion of
those aspects of the design here, perhaps apart from brief mentioning for the sake of readability
of this PR description. -->
<!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] concurrent read
- [ ] concurrent write
- [ ] concurrent read and write
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods.
- [ ] added or updated version, __license__, or notice information
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious
for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold
for code coverage.
- [ ] added integration tests.
- [ ] been tested in a test IoTDB cluster.
<!-- Check the items by putting "x" in the brackets for the done things. Not all of these items
apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items
from the checklist above are strictly necessary, but it would be very helpful if you at least
self-review the PR. -->
<hr>
##### Key changed/added classes (or packages if there are too many classes) in this PR
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance region deletion detection logic when concurrent error occurs [iotdb]
Posted by "Caideyipi (via GitHub)" <gi...@apache.org>.
Caideyipi commented on PR #15160:
URL: https://github.com/apache/iotdb/pull/15160#issuecomment-6410688708
Self-review passed. The concurrent schema-region deletion path now removes the region from the map before teardown, so in-flight writes see it as unavailable; if teardown fails, the mapping is restored so deletion remains retryable. Added coverage for visibility during teardown and restoration after metadata and runtime failures.\n\nVerification: mvn -pl iotdb-core/datanode -am -Dtest=SchemaEngineDeletionTest -Dsurefire.failIfNoSpecifiedTests=false -Ddevelocity.off=true test passed on the remote test host (3 tests, 0 failures/errors); Spotless and git diff --check passed.
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance region deletion detection logic when concurrent error occurs [iotdb]
Posted by "Caideyipi (via GitHub)" <gi...@apache.org>.
Caideyipi commented on code in PR #15160:
URL: https://github.com/apache/iotdb/pull/15160#discussion_r4374058901
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java:
##########
@@ -336,20 +337,34 @@ private ISchemaRegion createSchemaRegionWithoutExistenceCheck(
return schemaRegion;
}
- public synchronized boolean deleteSchemaRegion(SchemaRegionId schemaRegionId)
+ public synchronized boolean deleteSchemaRegion(final SchemaRegionId schemaRegionId)
throws MetadataException {
- ISchemaRegion schemaRegion = schemaRegionMap.get(schemaRegionId);
+ final ISchemaRegion schemaRegion = schemaRegionMap.get(schemaRegionId);
if (schemaRegion == null) {
logger.warn(DataNodeSchemaMessages.SCHEMA_REGION_ALREADY_DELETED, schemaRegionId);
return false;
}
- schemaRegion.deleteSchemaRegion();
+ final AtomicReference<MetadataException> lastException = new AtomicReference<>();
+ // Synchronize it for region deletion detection when error occurs
+ schemaRegionMap.compute(
Review Comment:
ConcurrentHashMap.compute keeps the existing mapping visible to lock-free getSchemaRegion() calls while the remapping function is running. Therefore, while schemaRegion.deleteSchemaRegion() is clearing the region, DataNodeRegionManager still retains the validation lock and isRegionExists() still returns true. An in-flight schema write can fail in that window and be reported as INTERNAL_SERVER_ERROR instead of the retryable NO_AVAILABLE_REGION_GROUP, which is the concurrent-deletion race this PR is intended to fix. Please publish a deletion-in-progress state (or remove the map entry before teardown and restore it on failure) so isRegionExists() observes the region as unavailable during teardown.
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org