Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix schema ledger deletion when deleting topic with delete schema. #10383

Merged

Conversation

codelipenghui
Copy link
Contributor

Related to #8167

Motivation

Fix schema ledger deletion when deleting topic with delete schema.

Modifications

Delete ledgers according to the schema index.

Verifying this change

New unit tests added.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@codelipenghui
Copy link
Contributor Author

@BewareMyPower Please also help review this PR.

Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@congbobo184 congbobo184 left a comment

Choose a reason for hiding this comment

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

Over look good! left some comment

deleteFuture.complete(null);
}, null);
});
FutureUtil.waitForAll(deleteFutures).whenComplete((v, e) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

whenComplete((v, e) need to handle the exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, one ledger delete failed, we only print the warn log instead failed the whole delete schema operation.

Copy link
Contributor

@gaoran10 gaoran10 Apr 26, 2021

Choose a reason for hiding this comment

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

If one ledger delete failed, does it need to be cleaned again? If delete zk path of the schema, we couldn't find its ledgers again.

try {
ZkUtils.deleteFullPathOptimistic(zooKeeper, getSchemaPath(schemaId), -1);
} catch (InterruptedException | KeeperException thr) {
future.completeExceptionally(thr);
Copy link
Contributor

Choose a reason for hiding this comment

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

should return after future.completeExceptionally(thr)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch!

});
FutureUtil.waitForAll(deleteFutures).whenComplete((v, e) -> {
try {
ZkUtils.deleteFullPathOptimistic(zooKeeper, getSchemaPath(schemaId), -1);
Copy link
Contributor

Choose a reason for hiding this comment

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

This call can be dangerous (I think it was already the case in the existing code). We're making a blocking call from the callback of an async call. It can lead to deadlock the ZK thread. We should never mix sync/async calls, rather we should convert into using ZkUtils.asyncDeleteFullPathOptimistic()

Copy link
Contributor Author

@codelipenghui codelipenghui Apr 27, 2021

Choose a reason for hiding this comment

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

@merlimat Fixed, PTAL.

@merlimat merlimat added the type/bug The PR fixed a bug or issue reported a bug label Apr 26, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

@eolivelli
Copy link
Contributor

@merlimat please take your final look,
we would like to pick this to 2.7.2, so it is blocking the release

@merlimat merlimat merged commit a227824 into apache:master Apr 27, 2021
@codelipenghui codelipenghui deleted the penghui/fix-delete-schema-ledger branch April 29, 2021 07:59
codelipenghui added a commit that referenced this pull request Apr 29, 2021
…10383)

* Fix schema ledger deletion when delete topic with delete schema.

* Revert public

* Apply comments.

* Apply comment.

* Fix checkstyle.

* Fix test

(cherry picked from commit a227824)
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.7 Archived: 2.7 is end of life release/2.7.2 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants