You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "VGalaxies (via GitHub)" <gi...@apache.org> on 2026/05/28 05:58:01 UTC
[PR] Subscription: add topic owner epoch fencing [iotdb]
VGalaxies opened a new pull request, #17780:
URL: https://github.com/apache/iotdb/pull/17780
## Summary
- Add topic-level owner epoch metadata for subscription fencing.
- Propagate owner id and epoch from subscription consumers.
- Reject stale owners during heartbeat, subscribe, poll, and commit.
- Add focused tests for serialization and owner transfer fencing.
## Tests
- mvn test -pl iotdb-core/relational-grammar,iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/datanode -Dtest=SubscriptionReceiverV1Test -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- mvn test -pl iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons -Dtest=TopicDeSerTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4563496796
## [Codecov](https://app.codecov.io/gh/apache/iotdb/pull/17780?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `44.61538%` with `144 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 40.82%. Comparing base ([`0c25e53`](https://app.codecov.io/gh/apache/iotdb/commit/0c25e53281f54c360bb33264b7acbc06fcf32bdc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`b6086b2`](https://app.codecov.io/gh/apache/iotdb/commit/b6086b2f4e183c10a7d288aad11dd1c7a8669512?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 14 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/iotdb/pull/17780?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../subscription/receiver/SubscriptionReceiverV1.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fsubscription%2Freceiver%2FSubscriptionReceiverV1.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvc3Vic2NyaXB0aW9uL3JlY2VpdmVyL1N1YnNjcmlwdGlvblJlY2VpdmVyVjEuamF2YQ==) | 0.00% | [40 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...tdb/commons/subscription/meta/topic/TopicMeta.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-core%2Fnode-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fcommons%2Fsubscription%2Fmeta%2Ftopic%2FTopicMeta.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9ub2RlLWNvbW1vbnMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2lvdGRiL2NvbW1vbnMvc3Vic2NyaXB0aW9uL21ldGEvdG9waWMvVG9waWNNZXRhLmphdmE=) | 81.72% | [17 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...on/consumer/base/AbstractSubscriptionConsumer.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-client%2Fsubscription%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fsession%2Fsubscription%2Fconsumer%2Fbase%2FAbstractSubscriptionConsumer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY2xpZW50L3N1YnNjcmlwdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvc2Vzc2lvbi9zdWJzY3JpcHRpb24vY29uc3VtZXIvYmFzZS9BYnN0cmFjdFN1YnNjcmlwdGlvbkNvbnN1bWVyLmphdmE=) | 0.00% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...umer/base/AbstractSubscriptionConsumerBuilder.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-client%2Fsubscription%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fsession%2Fsubscription%2Fconsumer%2Fbase%2FAbstractSubscriptionConsumerBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY2xpZW50L3N1YnNjcmlwdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvc2Vzc2lvbi9zdWJzY3JpcHRpb24vY29uc3VtZXIvYmFzZS9BYnN0cmFjdFN1YnNjcmlwdGlvbkNvbnN1bWVyQnVpbGRlci5qYXZh) | 0.00% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...on/consumer/base/AbstractSubscriptionProvider.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-client%2Fsubscription%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fsession%2Fsubscription%2Fconsumer%2Fbase%2FAbstractSubscriptionProvider.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY2xpZW50L3N1YnNjcmlwdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvc2Vzc2lvbi9zdWJzY3JpcHRpb24vY29uc3VtZXIvYmFzZS9BYnN0cmFjdFN1YnNjcmlwdGlvblByb3ZpZGVyLmphdmE=) | 0.00% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...on/exception/SubscriptionOwnerFencedException.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-client%2Fsubscription%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Frpc%2Fsubscription%2Fexception%2FSubscriptionOwnerFencedException.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY2xpZW50L3N1YnNjcmlwdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvcnBjL3N1YnNjcmlwdGlvbi9leGNlcHRpb24vU3Vic2NyaXB0aW9uT3duZXJGZW5jZWRFeGNlcHRpb24uamF2YQ==) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...on/consumer/tree/SubscriptionTreePullConsumer.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-client%2Fsubscription%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fsession%2Fsubscription%2Fconsumer%2Ftree%2FSubscriptionTreePullConsumer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY2xpZW50L3N1YnNjcmlwdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvc2Vzc2lvbi9zdWJzY3JpcHRpb24vY29uc3VtZXIvdHJlZS9TdWJzY3JpcHRpb25UcmVlUHVsbENvbnN1bWVyLmphdmE=) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...on/consumer/tree/SubscriptionTreePushConsumer.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-client%2Fsubscription%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fsession%2Fsubscription%2Fconsumer%2Ftree%2FSubscriptionTreePushConsumer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY2xpZW50L3N1YnNjcmlwdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvc2Vzc2lvbi9zdWJzY3JpcHRpb24vY29uc3VtZXIvdHJlZS9TdWJzY3JpcHRpb25UcmVlUHVzaENvbnN1bWVyLmphdmE=) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../db/subscription/agent/SubscriptionTopicAgent.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fsubscription%2Fagent%2FSubscriptionTopicAgent.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvc3Vic2NyaXB0aW9uL2FnZW50L1N1YnNjcmlwdGlvblRvcGljQWdlbnQuamF2YQ==) | 76.47% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...er/table/SubscriptionTablePullConsumerBuilder.java](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&filepath=iotdb-client%2Fsubscription%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fsession%2Fsubscription%2Fconsumer%2Ftable%2FSubscriptionTablePullConsumerBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY2xpZW50L3N1YnNjcmlwdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvc2Vzc2lvbi9zdWJzY3JpcHRpb24vY29uc3VtZXIvdGFibGUvU3Vic2NyaXB0aW9uVGFibGVQdWxsQ29uc3VtZXJCdWlsZGVyLmphdmE=) | 0.00% | [6 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| ... and [4 more](https://app.codecov.io/gh/apache/iotdb/pull/17780?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #17780 +/- ##
============================================
+ Coverage 40.58% 40.82% +0.23%
- Complexity 2575 2616 +41
============================================
Files 5181 5185 +4
Lines 350404 351103 +699
Branches 44801 44925 +124
============================================
+ Hits 142225 143334 +1109
+ Misses 208179 207769 -410
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/iotdb/pull/17780?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4619384420
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [8.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17780&metric=new_duplicated_lines_density&view=list) (required ≤ 5%)
<!-- sqra:qg_revision=34cf8df44a929cbd58cb57211f5f6ee68c213ccdf3ed36449f99ce60522ac629 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "Caideyipi (via GitHub)" <gi...@apache.org>.
Caideyipi commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4562888526
Findings
- P1: TopicMeta 的新尾部字段破坏旧格式兼容。deserialize(InputStream) 用 inputStream.available() 判断是否还有 owner
字段,但 TopicMeta 在 snapshot 里是连续写入的;旧版本数据没有 owner flag,多个 topic 时这里会把下一个 topic
的首字节当成 owner flag 消费,导致后续反序列化错位。ByteBuffer.hasRemaining() 在旧 procedure/plan
列表里也有同类问题。见 TopicMeta.java#L260
(https://github.com/apache/iotdb/blob/76f2a882411ba790f7db290740f0232a1e5c4022/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/meta/topic/TopicMeta.java#L260)
和 TopicMetaKeeper.java#L112
(https://github.com/apache/iotdb/blob/76f2a882411ba790f7db290740f0232a1e5c4022/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/meta/topic/TopicMetaKeeper.java#L112)。建议改成版本化或长度前缀格式,或只从
config 属性恢复 owner,不在非自描述对象尾部追加可选字段。
- P1: owner epoch 单调性没有在真实元数据替换路径上保证。transferOwner() 只在同一个对象上检查递增,但 AlterTopicPlan /
metadata replace 路径直接 remove + add 新 TopicMeta,新对象从 -1 初始化,所以较小 epoch 也能覆盖当前 epoch,使旧
owner 重新合法。见 TopicMeta.java#L135
(https://github.com/apache/iotdb/blob/76f2a882411ba790f7db290740f0232a1e5c4022/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/meta/topic/TopicMeta.java#L135)
和 SubscriptionInfo.java#L340
(https://github.com/apache/iotdb/blob/76f2a882411ba790f7db290740f0232a1e5c4022/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/subscription/SubscriptionInfo.java#L340)。建议在
ConfigNode alter/handle meta change 时对比 existing owner epoch 并拒绝回退。
- P2: 新增的 owner status code 没有接入客户端错误分类。1913-1916 会落到 default,变成 generic critical
exception;heartbeat 还会把 provider 标成 unavailable,导致 stale owner 场景反复重连/重试且错误信息不稳定。见
TSStatusCode.java#L319
(https://github.com/apache/iotdb/blob/76f2a882411ba790f7db290740f0232a1e5c4022/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java#L319)、AbstractSubscriptionProvider.java#L445
(https://github.com/apache/iotdb/blob/76f2a882411ba790f7db290740f0232a1e5c4022/iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/consumer/base/AbstractSubscriptionProvider.java#L445)。建议显式处理
owner fenced/required/lease expired,映射成明确的不可重试业务异常。
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4687207886
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=665df1d6e703891d280356d227a6c94ced49320d01af2f590f5474845b334c21 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3370523216
##########
iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/ISubscriptionTableSession.java:
##########
@@ -99,6 +99,49 @@ void createTopic(final String topicName, final Properties properties)
void createTopicIfNotExists(final String topicName, final Properties properties)
throws IoTDBConnectionException, StatementExecutionException;
+ /**
+ * Alters a topic with the specified properties.
+ *
+ * @param topicName If the topic name contains single quotes, the passed parameter needs to be
+ * enclosed in backticks.
+ * @param properties A {@link Properties} object containing the topic properties to alter.
+ * @throws IoTDBConnectionException If a connection issue occurs.
+ * @throws StatementExecutionException If the SQL statement execution fails.
+ */
+ void alterTopic(final String topicName, final Properties properties)
+ throws IoTDBConnectionException, StatementExecutionException;
Review Comment:
Is the TopicOwner allowed to be modified by this interface?
Or can it only be modified through `alterTopicOwner`?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java:
##########
@@ -1733,6 +1736,35 @@ public TSStatus createTopic(TCreateTopicReq req) {
}
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ try {
+ final TopicMeta updatedTopicMeta =
+ configManager
+ .getSubscriptionManager()
+ .getSubscriptionCoordinator()
+ .buildAlteredTopicMeta(req);
+ if (updatedTopicMeta == null) {
+ return new TSStatus(TSStatusCode.ALTER_TOPIC_ERROR.getStatusCode())
+ .setMessage(
+ String.format(
+ "Failed to alter topic %s, the topic is not existed", req.getTopicName()));
+ }
Review Comment:
i18n
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java:
##########
@@ -4425,6 +4426,23 @@ public Statement visitCreateTopic(IoTDBSqlParser.CreateTopicContext ctx) {
return createTopicStatement;
}
+ @Override
+ public Statement visitAlterTopic(IoTDBSqlParser.AlterTopicContext ctx) {
+ final AlterTopicStatement alterTopicStatement = new AlterTopicStatement();
+
+ if (ctx.topicName != null) {
+ alterTopicStatement.setTopicName(parseIdentifier(ctx.topicName.getText()));
+ } else {
+ throw new SemanticException(
+ "Not support for this sql in ALTER TOPIC, please enter topicName.");
+ }
Review Comment:
i18n
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -149,6 +151,25 @@ public TSStatus createTopic(TCreateTopicReq req) {
return status;
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ final TSStatus status = configManager.getProcedureManager().alterTopic(req);
+ if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ LOGGER.warn(
+ "Failed to alter topic {} with attributes {}, result status is {}.",
+ req.getTopicName(),
+ req.getTopicAttributes(),
+ status);
+ }
+ return status;
+ }
+
+ public TopicMeta buildAlteredTopicMeta(TAlterTopicReq req) {
+ final TopicMeta existedTopicMeta = subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ return existedTopicMeta == null
+ ? null
+ : existedTopicMeta.deepCopyWithUpdatedAttributes(req.getTopicAttributes());
+ }
Review Comment:
Why deep copy twice?
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4563191571
Thanks @Caideyipi, addressed the three findings in b6086b2f4e.
- P1 serialization compatibility: removed the optional owner fields from the non-self-describing TopicMeta serialization tail. Owner state is now restored from topic attributes after deserialization, so sequential TopicMeta snapshot/procedure streams are not consumed out of boundary. Added a sequential deserialization regression test.
- P1 epoch rollback: added TopicMeta.validateOwnerProgression(...) and applied it on both ConfigNode alter-topic metadata replacement and DataNode topic-meta update handling, rejecting owner clears/rollbacks/stale same-epoch owner changes. Added ConfigNode rollback coverage and extended the network-partition old-SN test to verify stale topic meta cannot make the old owner valid again.
- P2 client classification: mapped 1913-1917 explicitly to SubscriptionOwnerFencedException, a SubscriptionRuntimeNonCriticalException subclass, so stale-owner/business fencing errors no longer fall into the generic critical default path.
Local verification passed:
- mvn spotless:apply -pl iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/datanode,iotdb-core/confignode -DskipTests
- mvn test -pl iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons -Dtest=TopicDeSerTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- mvn test -pl iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/confignode -Dtest=SubscriptionInfoTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- mvn test -pl iotdb-core/relational-grammar,iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/datanode -Dtest=SubscriptionReceiverV1Test -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- mvn test -pl iotdb-client/service-rpc,iotdb-client/subscription -Dtest=TSStatusCodeTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- git diff --check
The Sonar duplication check is queued again on the new commit; I will follow up if the rerun still fails.
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4563229212
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [5.2% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17780&metric=new_duplicated_lines_density&view=list) (required ≤ 5%)
<!-- sqra:qg_revision=7e4feb7eabc2050b77eebb32a3838a2ade6fc1711b6b500765c8e59881e2d8c2 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3340236791
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionTopicAgent.java:
##########
@@ -188,4 +195,73 @@ public Map<String, TopicConfig> getTopicConfigs(final Set<String> topicNames) {
releaseReadLock();
}
}
+
+ public TSStatus checkTopicOwner(final ConsumerConfig consumerConfig, final String topicName) {
+ acquireReadLock();
+ try {
+ if (!topicMetaKeeper.containsTopicMeta(topicName)) {
+ return RpcUtils.SUCCESS_STATUS;
+ }
+
+ final TopicMeta topicMeta = topicMetaKeeper.getTopicMeta(topicName);
+ if (!topicMeta.isOwnerFencingEnabled()) {
+ return RpcUtils.SUCCESS_STATUS;
+ }
Review Comment:
Done. I merged the contains/get path into a single getTopicMeta(...) call and handle the missing-topic case with a null check before owner-fencing validation.
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3371178923
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java:
##########
@@ -1733,6 +1736,35 @@ public TSStatus createTopic(TCreateTopicReq req) {
}
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ try {
+ final TopicMeta updatedTopicMeta =
+ configManager
+ .getSubscriptionManager()
+ .getSubscriptionCoordinator()
+ .buildAlteredTopicMeta(req);
+ if (updatedTopicMeta == null) {
+ return new TSStatus(TSStatusCode.ALTER_TOPIC_ERROR.getStatusCode())
+ .setMessage(
+ String.format(
+ "Failed to alter topic %s, the topic is not existed", req.getTopicName()));
+ }
Review Comment:
Addressed in 82049d7b46. Moved this hard-coded ALTER TOPIC error message into `ManagerMessages` for both en and zh locale sources.
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -149,6 +151,25 @@ public TSStatus createTopic(TCreateTopicReq req) {
return status;
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ final TSStatus status = configManager.getProcedureManager().alterTopic(req);
+ if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ LOGGER.warn(
+ "Failed to alter topic {} with attributes {}, result status is {}.",
+ req.getTopicName(),
+ req.getTopicAttributes(),
+ status);
+ }
+ return status;
+ }
+
+ public TopicMeta buildAlteredTopicMeta(TAlterTopicReq req) {
+ final TopicMeta existedTopicMeta = subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ return existedTopicMeta == null
+ ? null
+ : existedTopicMeta.deepCopyWithUpdatedAttributes(req.getTopicAttributes());
+ }
Review Comment:
Addressed in 82049d7b46. I added `SubscriptionInfo#deepCopyTopicMetaWithUpdatedAttributes(...)`, so the read-lock protected lookup and attribute merge now create one copied `TopicMeta` instead of deep-copying twice in `SubscriptionCoordinator`.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java:
##########
@@ -4425,6 +4426,23 @@ public Statement visitCreateTopic(IoTDBSqlParser.CreateTopicContext ctx) {
return createTopicStatement;
}
+ @Override
+ public Statement visitAlterTopic(IoTDBSqlParser.AlterTopicContext ctx) {
+ final AlterTopicStatement alterTopicStatement = new AlterTopicStatement();
+
+ if (ctx.topicName != null) {
+ alterTopicStatement.setTopicName(parseIdentifier(ctx.topicName.getText()));
+ } else {
+ throw new SemanticException(
+ "Not support for this sql in ALTER TOPIC, please enter topicName.");
+ }
Review Comment:
Addressed in 82049d7b46. Moved this parser error into `DataNodeQueryMessages` for both en and zh locale sources.
##########
iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/ISubscriptionTableSession.java:
##########
@@ -99,6 +99,49 @@ void createTopic(final String topicName, final Properties properties)
void createTopicIfNotExists(final String topicName, final Properties properties)
throws IoTDBConnectionException, StatementExecutionException;
+ /**
+ * Alters a topic with the specified properties.
+ *
+ * @param topicName If the topic name contains single quotes, the passed parameter needs to be
+ * enclosed in backticks.
+ * @param properties A {@link Properties} object containing the topic properties to alter.
+ * @throws IoTDBConnectionException If a connection issue occurs.
+ * @throws StatementExecutionException If the SQL statement execution fails.
+ */
+ void alterTopic(final String topicName, final Properties properties)
+ throws IoTDBConnectionException, StatementExecutionException;
Review Comment:
Addressed in 82049d7b46. The public session `alterTopic(topicName, properties)` now rejects `owner-id`, `owner-epoch`, and `owner-lease-expire-time-ms`; owner fields are only allowed through the internal path used by `alterTopicOwner(...)`.
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4646026716
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate passed**
Issues
 [20 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17780&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17780&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=17780&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17780&metric=new_coverage&view=list)
 [3.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17780&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4601242100
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [5.2% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17780&metric=new_duplicated_lines_density&view=list) (required ≤ 5%)
<!-- sqra:qg_revision=7e4feb7eabc2050b77eebb32a3838a2ade6fc1711b6b500765c8e59881e2d8c2 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4601167621
Addressed the latest review comments in 25c34c2bfe.
- Added IoTDBSubscriptionTopicOwnerIT as a complete local subscription use case: a stale owner (sn1/epoch 5) is fenced after the topic is owned by sn2/epoch 6, while the current owner can subscribe, poll data, commit, and unsubscribe.
- Kept the new IT aligned with the current subscription IT convention: it is @Ignore because SubscriptionConfig#getSubscriptionEnabled() is currently hard-coded false in this codebase, but the class compiles and is discovered under the with-integration-tests profile.
- Preserved SubscriptionOwnerFencedException through subscribe redirection so the stale-owner path remains a business fencing error.
- Merged the SubscriptionTopicAgent contains/get check into one getTopicMeta(...) null check.
Local verification:
- mvn spotless:apply -pl integration-test -P with-integration-tests -DskipTests
- mvn verify -DskipUTs -Dit.test=IoTDBSubscriptionTopicOwnerIT -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false -pl integration-test -am -P with-integration-tests
- mvn test -pl iotdb-client/service-rpc,iotdb-client/subscription -Dtest=TSStatusCodeTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- mvn test -pl iotdb-core/relational-grammar,iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/datanode -Dtest=SubscriptionReceiverV1Test -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- git diff --check
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3395911858
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/meta/topic/TopicMeta.java:
##########
@@ -168,14 +187,29 @@ public void transferOwner(
+ " current owner-epoch: %s, current owner-lease-expire-time-ms: %s",
topicName, this.ownerId, this.ownerEpoch, this.ownerLeaseExpireTimeMs));
}
+ if (Objects.nonNull(ownerLeaseDurationMs) && ownerLeaseDurationMs <= 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Subscription topic owner lease duration should be positive, topic: %s,"
+ + " owner-lease-duration-ms: %s",
+ topicName, ownerLeaseDurationMs));
Review Comment:
Addressed in 6787927100. Moved the TopicMeta owner-fencing exception messages (owner id/epoch validation, monotonic/never-reused epoch, stale-clear, rollback, and lease-duration checks) into `SubscriptionMessages` with both en and zh locale sources. node-commons already depends on the subscription client module, so it reuses that i18n class.
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -163,11 +169,81 @@ public TSStatus alterTopic(TAlterTopicReq req) {
return status;
}
+ public boolean blockOwnerLeaseRenewalIfOwnerTransfer(TAlterTopicReq req) {
+ final TopicMeta currentTopicMeta = subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ final TopicMeta updatedTopicMeta = buildAlteredTopicMeta(req);
+ if (Objects.isNull(currentTopicMeta)
+ || Objects.isNull(updatedTopicMeta)
+ || Objects.equals(currentTopicMeta.getOwnerId(), updatedTopicMeta.getOwnerId())) {
+ return false;
+ }
+
+ blockedOwnerLeaseRenewalTopics.add(req.getTopicName());
+ return true;
+ }
+
+ public void unblockOwnerLeaseRenewal(String topicName) {
+ blockedOwnerLeaseRenewalTopics.remove(topicName);
+ }
+
+ public TopicMeta buildAlteredTopicMetaAfterOwnerLeaseExpired(TAlterTopicReq req)
+ throws InterruptedException {
+ while (true) {
+ final TopicMeta currentTopicMeta = subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ final TopicMeta updatedTopicMeta = buildAlteredTopicMeta(req);
+ if (Objects.isNull(currentTopicMeta)
+ || Objects.isNull(updatedTopicMeta)
+ || Objects.equals(currentTopicMeta.getOwnerId(), updatedTopicMeta.getOwnerId())) {
+ return updatedTopicMeta;
+ }
+
+ final long ownerLeaseRemainingTimeMs = currentTopicMeta.getOwnerLeaseRemainingTimeMs();
+ if (Objects.isNull(currentTopicMeta.getOwnerLeaseExpireTimeMs())
+ || ownerLeaseRemainingTimeMs <= 0) {
+ return updatedTopicMeta;
+ }
+
+ Thread.sleep(Math.min(ownerLeaseRemainingTimeMs + 1, 1000L));
+ }
+ }
+
public TopicMeta buildAlteredTopicMeta(TAlterTopicReq req) {
return subscriptionInfo.deepCopyTopicMetaWithUpdatedAttributes(
req.getTopicName(), req.getTopicAttributes());
}
+ public TSStatus renewTopicOwnerLease(TRenewTopicOwnerLeaseReq req) {
+ if (blockedOwnerLeaseRenewalTopics.contains(req.getTopicName())) {
+ return RpcUtils.getStatus(
+ TSStatusCode.SUBSCRIPTION_OWNER_FENCED,
+ String.format(
+ "Subscription: topic %s owner lease renewal is blocked by a pending owner transfer.",
+ req.getTopicName()));
+ }
Review Comment:
Addressed in 6787927100. The originally flagged `renewTopicOwnerLease` message was removed during the owner-lease rework (CN-side renewal was replaced by a DataNode-local lease heartbeat). The remaining PR-introduced hard-coded message in this file, the alter-topic warn, now uses `ManagerMessages.FAILED_TO_ALTER_TOPIC_WITH_ATTRIBUTES_RESULT_STATUS` (en/zh).
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3400221521
##########
integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionTopicOwnerIT.java:
##########
@@ -150,49 +142,24 @@ public void testHeartbeatRenewsOwnerLeaseAndAlterOwnerWaitsForLeaseExpiration()
TopicConstant.OWNER_LEASE_DURATION_MS_KEY, String.valueOf(ownerLeaseDurationMs));
session.createTopic(topicName, properties);
- final Long initialOwnerLeaseExpireTimeMs = getOwnerLeaseExpireTimeMs(session, topicName);
- Assert.assertNotNull(initialOwnerLeaseExpireTimeMs);
- Assert.assertTrue(initialOwnerLeaseExpireTimeMs > System.currentTimeMillis());
-
- try (final SubscriptionTreePullConsumer currentOwnerConsumer =
- new SubscriptionTreePullConsumer.Builder()
- .host(host)
- .port(port)
- .consumerId("current_sn")
- .consumerGroupId("topic_owner_lease_group")
- .ownerId("sn1")
- .ownerEpoch(5L)
- .heartbeatIntervalMs(heartbeatIntervalMs)
- .autoCommit(false)
- .buildPullConsumer()) {
- currentOwnerConsumer.open();
- currentOwnerConsumer.subscribe(topicName);
-
- final AtomicReference<Long> renewedOwnerLeaseExpireTimeMs =
- new AtomicReference<>(initialOwnerLeaseExpireTimeMs);
- IoTDBSubscriptionITConstant.AWAIT.untilAsserted(
- () -> {
- final Long ownerLeaseExpireTimeMs = getOwnerLeaseExpireTimeMs(session, topicName);
- Assert.assertNotNull(ownerLeaseExpireTimeMs);
- Assert.assertTrue(ownerLeaseExpireTimeMs > initialOwnerLeaseExpireTimeMs);
- renewedOwnerLeaseExpireTimeMs.set(ownerLeaseExpireTimeMs);
- });
-
+ try {
+ // Transferring to a different owner must wait for the old owner's lease to drain on every
+ // DataNode before the new owner is installed. ConfigNode stops renewing and waits at least
+ // the lease duration (measured on its own clock), so the call blocks for >= the lease
+ // duration. This is the admission gate that prevents cross-DataNode double-active
+ // consuming.
final long alterStartTimeMs = System.currentTimeMillis();
session.alterTopicOwner(topicName, "sn2", 6L);
final long alterElapsedTimeMs = System.currentTimeMillis() - alterStartTimeMs;
-
- final long ownerLeaseRemainingTimeMs =
- renewedOwnerLeaseExpireTimeMs.get() - alterStartTimeMs;
- if (ownerLeaseRemainingTimeMs > 500L) {
- Assert.assertTrue(alterElapsedTimeMs >= ownerLeaseRemainingTimeMs - 250L);
- }
+ Assert.assertTrue(
+ "alterTopicOwner should block at least the lease drain duration, but only took "
+ + alterElapsedTimeMs
+ + "ms",
+ alterElapsedTimeMs >= ownerLeaseDurationMs);
Review Comment:
The waiting time also depends on the renewal interval (heartbeat interval).
For example,
lease renewed at t0
owner altered at t1
lease expired at t2
then the waiting time will be t2 - t1 <= t2 - t0 = leaseDuration
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4672908214
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=8f0b4eaa230a7670b9eadd30692a9b1819680970b66ec681392ecb9c8cbc4c1f -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3392759614
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/meta/topic/TopicMeta.java:
##########
@@ -168,14 +187,29 @@ public void transferOwner(
+ " current owner-epoch: %s, current owner-lease-expire-time-ms: %s",
topicName, this.ownerId, this.ownerEpoch, this.ownerLeaseExpireTimeMs));
}
+ if (Objects.nonNull(ownerLeaseDurationMs) && ownerLeaseDurationMs <= 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Subscription topic owner lease duration should be positive, topic: %s,"
+ + " owner-lease-duration-ms: %s",
+ topicName, ownerLeaseDurationMs));
Review Comment:
i18n
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -163,11 +169,81 @@ public TSStatus alterTopic(TAlterTopicReq req) {
return status;
}
+ public boolean blockOwnerLeaseRenewalIfOwnerTransfer(TAlterTopicReq req) {
+ final TopicMeta currentTopicMeta = subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ final TopicMeta updatedTopicMeta = buildAlteredTopicMeta(req);
+ if (Objects.isNull(currentTopicMeta)
+ || Objects.isNull(updatedTopicMeta)
+ || Objects.equals(currentTopicMeta.getOwnerId(), updatedTopicMeta.getOwnerId())) {
+ return false;
+ }
+
+ blockedOwnerLeaseRenewalTopics.add(req.getTopicName());
+ return true;
+ }
+
+ public void unblockOwnerLeaseRenewal(String topicName) {
+ blockedOwnerLeaseRenewalTopics.remove(topicName);
+ }
+
+ public TopicMeta buildAlteredTopicMetaAfterOwnerLeaseExpired(TAlterTopicReq req)
+ throws InterruptedException {
+ while (true) {
+ final TopicMeta currentTopicMeta = subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ final TopicMeta updatedTopicMeta = buildAlteredTopicMeta(req);
+ if (Objects.isNull(currentTopicMeta)
+ || Objects.isNull(updatedTopicMeta)
+ || Objects.equals(currentTopicMeta.getOwnerId(), updatedTopicMeta.getOwnerId())) {
+ return updatedTopicMeta;
+ }
+
+ final long ownerLeaseRemainingTimeMs = currentTopicMeta.getOwnerLeaseRemainingTimeMs();
+ if (Objects.isNull(currentTopicMeta.getOwnerLeaseExpireTimeMs())
+ || ownerLeaseRemainingTimeMs <= 0) {
+ return updatedTopicMeta;
+ }
+
+ Thread.sleep(Math.min(ownerLeaseRemainingTimeMs + 1, 1000L));
+ }
+ }
+
public TopicMeta buildAlteredTopicMeta(TAlterTopicReq req) {
return subscriptionInfo.deepCopyTopicMetaWithUpdatedAttributes(
req.getTopicName(), req.getTopicAttributes());
}
+ public TSStatus renewTopicOwnerLease(TRenewTopicOwnerLeaseReq req) {
+ if (blockedOwnerLeaseRenewalTopics.contains(req.getTopicName())) {
+ return RpcUtils.getStatus(
+ TSStatusCode.SUBSCRIPTION_OWNER_FENCED,
+ String.format(
+ "Subscription: topic %s owner lease renewal is blocked by a pending owner transfer.",
+ req.getTopicName()));
+ }
Review Comment:
i18n
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4645990724
Addressed the lease-transfer review comment in 82049d7b46.
Topic ownership transfer now checks the current topic owner lease before replacing owner metadata: if the current owner has an unexpired `owner-lease-expire-time-ms` and the incoming owner id is different, the transfer is rejected. Once the lease has expired, the transfer can proceed. Added `SubscriptionInfoTest` coverage for both paths.
Also addressed the inline comments in the same commit:
- public session `alterTopic(...)` rejects owner attributes; `alterTopicOwner(...)` is the session API entry for owner updates.
- removed the extra deep copy from the alter-topic metadata build path.
- moved the two hard-coded messages to en/zh i18n constants.
Local verification passed:
- `mvn spotless:apply -pl iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/confignode,iotdb-core/datanode -DskipTests`
- `mvn test -pl iotdb-protocol/thrift-confignode,iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/confignode -Dtest=SubscriptionInfoTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false`
- `mvn test -pl iotdb-protocol/thrift-confignode,iotdb-core/relational-grammar,iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/node-commons,iotdb-core/datanode -Dtest=StatementGeneratorTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false`
- `mvn compile -pl iotdb-protocol/thrift-confignode,iotdb-client/service-rpc,iotdb-client/subscription,iotdb-core/relational-grammar,iotdb-core/node-commons,iotdb-core/confignode,iotdb-core/datanode -P with-zh-locale -DskipTests`
- `git diff --check`
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4680724459
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=e0d75874a67de1d9460d7a17c08c0d7bab9450e7b6fcbf0d701e29c02bbd5f27 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4682594659
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=d5479d9edd6fdb9141ff1c300872c27ce90287d94721d298cd2af3b6c9f3c04a -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4682883861
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=d5479d9edd6fdb9141ff1c300872c27ce90287d94721d298cd2af3b6c9f3c04a -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4680567036
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=e0d75874a67de1d9460d7a17c08c0d7bab9450e7b6fcbf0d701e29c02bbd5f27 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4686934715
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=665df1d6e703891d280356d227a6c94ced49320d01af2f590f5474845b334c21 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4687387847
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=665df1d6e703891d280356d227a6c94ced49320d01af2f590f5474845b334c21 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3339464993
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionTopicAgent.java:
##########
@@ -188,4 +195,73 @@ public Map<String, TopicConfig> getTopicConfigs(final Set<String> topicNames) {
releaseReadLock();
}
}
+
+ public TSStatus checkTopicOwner(final ConsumerConfig consumerConfig, final String topicName) {
+ acquireReadLock();
+ try {
+ if (!topicMetaKeeper.containsTopicMeta(topicName)) {
+ return RpcUtils.SUCCESS_STATUS;
+ }
+
+ final TopicMeta topicMeta = topicMetaKeeper.getTopicMeta(topicName);
+ if (!topicMeta.isOwnerFencingEnabled()) {
+ return RpcUtils.SUCCESS_STATUS;
+ }
Review Comment:
Is it possible to merge contains and get?
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4619251670
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [8.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17780&metric=new_duplicated_lines_density&view=list) (required ≤ 5%)
<!-- sqra:qg_revision=34cf8df44a929cbd58cb57211f5f6ee68c213ccdf3ed36449f99ce60522ac629 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4561247622
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [6.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17780&metric=new_duplicated_lines_density&view=list) (required ≤ 5%)
<!-- sqra:qg_revision=5b1209601367a2ae793706d576d2eca780b40e0d78228050dcf2d473edddf731 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4662394674
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=0f5f9b2f9954b3ddc3d74c37cf16e090c8cc3f002a9b5a210cc9e6f4488f9b02 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 merged PR #17780:
URL: https://github.com/apache/iotdb/pull/17780
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3400587568
##########
integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionTopicOwnerIT.java:
##########
@@ -150,49 +142,24 @@ public void testHeartbeatRenewsOwnerLeaseAndAlterOwnerWaitsForLeaseExpiration()
TopicConstant.OWNER_LEASE_DURATION_MS_KEY, String.valueOf(ownerLeaseDurationMs));
session.createTopic(topicName, properties);
- final Long initialOwnerLeaseExpireTimeMs = getOwnerLeaseExpireTimeMs(session, topicName);
- Assert.assertNotNull(initialOwnerLeaseExpireTimeMs);
- Assert.assertTrue(initialOwnerLeaseExpireTimeMs > System.currentTimeMillis());
-
- try (final SubscriptionTreePullConsumer currentOwnerConsumer =
- new SubscriptionTreePullConsumer.Builder()
- .host(host)
- .port(port)
- .consumerId("current_sn")
- .consumerGroupId("topic_owner_lease_group")
- .ownerId("sn1")
- .ownerEpoch(5L)
- .heartbeatIntervalMs(heartbeatIntervalMs)
- .autoCommit(false)
- .buildPullConsumer()) {
- currentOwnerConsumer.open();
- currentOwnerConsumer.subscribe(topicName);
-
- final AtomicReference<Long> renewedOwnerLeaseExpireTimeMs =
- new AtomicReference<>(initialOwnerLeaseExpireTimeMs);
- IoTDBSubscriptionITConstant.AWAIT.untilAsserted(
- () -> {
- final Long ownerLeaseExpireTimeMs = getOwnerLeaseExpireTimeMs(session, topicName);
- Assert.assertNotNull(ownerLeaseExpireTimeMs);
- Assert.assertTrue(ownerLeaseExpireTimeMs > initialOwnerLeaseExpireTimeMs);
- renewedOwnerLeaseExpireTimeMs.set(ownerLeaseExpireTimeMs);
- });
-
+ try {
+ // Transferring to a different owner must wait for the old owner's lease to drain on every
+ // DataNode before the new owner is installed. ConfigNode stops renewing and waits at least
+ // the lease duration (measured on its own clock), so the call blocks for >= the lease
+ // duration. This is the admission gate that prevents cross-DataNode double-active
+ // consuming.
final long alterStartTimeMs = System.currentTimeMillis();
session.alterTopicOwner(topicName, "sn2", 6L);
final long alterElapsedTimeMs = System.currentTimeMillis() - alterStartTimeMs;
-
- final long ownerLeaseRemainingTimeMs =
- renewedOwnerLeaseExpireTimeMs.get() - alterStartTimeMs;
- if (ownerLeaseRemainingTimeMs > 500L) {
- Assert.assertTrue(alterElapsedTimeMs >= ownerLeaseRemainingTimeMs - 250L);
- }
+ Assert.assertTrue(
+ "alterTopicOwner should block at least the lease drain duration, but only took "
+ + alterElapsedTimeMs
+ + "ms",
+ alterElapsedTimeMs >= ownerLeaseDurationMs);
Review Comment:
Good catch — addressed in 55b95686c6 (comment clarified). You're right that the heartbeat interval matters. The ConfigNode does not wait until a DataNode's absolute lease-expire time (that would couple the two clocks); instead it stops renewal at `blockSince` and waits `leaseDuration + one heartbeat interval (H)` on its own clock. The extra H is needed because a renewal may have been in flight to a DataNode right before renewal was stopped, so that DataNode's lease could expire as late as `blockSince + H + leaseDuration`. Hence the actual wait is `L + H`, which is why `alterElapsedTimeMs >= leaseDuration` holds as a (loose) lower bound. I've updated the test comment to state the `L + H` relationship explicitly.
--
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] Subscription: add topic owner epoch fencing [iotdb]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#issuecomment-4677478133
## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780) (required ≥ A)
<!-- sqra:qg_revision=d5479d9edd6fdb9141ff1c300872c27ce90287d94721d298cd2af3b6c9f3c04a -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17780)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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