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

refactor: reduce the number of failures due to conflict post update #5604

Merged
merged 1 commit into from Mar 27, 2024

Conversation

guqing
Copy link
Member

@guqing guqing commented Mar 27, 2024

What type of PR is this?

/kind improvement
/area core
/milestone 2.14.x

What this PR does / why we need it:

减少文章更新因版本号冲突而失败的次数

Which issue(s) this PR fixes:

Fixes #5579

Does this PR introduce a user-facing change?

None

@f2c-ci-robot f2c-ci-robot bot added release-note-none Denotes a PR that doesn't merit a release note. kind/improvement Categorizes issue or PR as related to a improvement. labels Mar 27, 2024
@f2c-ci-robot f2c-ci-robot bot added this to the 2.14.x milestone Mar 27, 2024
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Mar 27, 2024
@f2c-ci-robot f2c-ci-robot bot requested review from LIlGG and ruibaby March 27, 2024 08:52
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 31 lines in your changes are missing coverage. Please review.

Project coverage is 56.48%. Comparing base (5fdf6c0) to head (ecd8da4).
Report is 89 commits behind head on main.

Files Patch % Lines
...a/run/halo/app/content/AbstractContentService.java 0.00% 11 Missing ⚠️
...halo/app/core/extension/endpoint/PostEndpoint.java 0.00% 6 Missing ⚠️
...pp/core/extension/endpoint/SinglePageEndpoint.java 0.00% 6 Missing ⚠️
...ava/run/halo/app/content/impl/PostServiceImpl.java 0.00% 4 Missing ⚠️
...n/halo/app/content/impl/SinglePageServiceImpl.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5604      +/-   ##
============================================
- Coverage     56.91%   56.48%   -0.43%     
- Complexity     3319     3320       +1     
============================================
  Files           587      595       +8     
  Lines         18968    19250     +282     
  Branches       1401     1357      -44     
============================================
+ Hits          10795    10874      +79     
- Misses         7594     7814     +220     
+ Partials        579      562      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@LIlGG LIlGG left a comment

Choose a reason for hiding this comment

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

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2024
Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

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

Hi @guqing ,

建议不在 run.halo.app.content.impl.PostServiceImpl#updatePost 中实现 retry 逻辑。因为改方法的 post 参数已经传递过来了,重试 n 次都不会有效果。

推荐在

实现。在这里,可以重新拿到最新的文章数据,并重试整个流程。

@guqing
Copy link
Member Author

guqing commented Mar 27, 2024

Hi @guqing ,

建议不在 run.halo.app.content.impl.PostServiceImpl#updatePost 中实现 retry 逻辑。因为改方法的 post 参数已经传递过来了,重试 n 次都不会有效果。

推荐在

实现。在这里,可以重新拿到最新的文章数据,并重试整个流程。

本次修改,我并没有在 updatePost 中方法中写重试啊,你说的是哪里呢

@JohnNiang
Copy link
Member

JohnNiang commented Mar 27, 2024

在 run.halo.app.content.impl.PostServiceImpl#updatePost 中 retry 的源码如下所示:

.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException));

另外,这里不推荐强制修改 post 数据。

@guqing
Copy link
Member Author

guqing commented Mar 27, 2024

在 run.halo.app.content.impl.PostServiceImpl#updatePost 中 retry 的源码如下所示:

.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException));

这个代码并不是在本次修改中添加的,你是建议我在此 PR 中移除它吗

@guqing
Copy link
Member Author

guqing commented Mar 27, 2024

在 run.halo.app.content.impl.PostServiceImpl#updatePost 中 retry 的源码如下所示:

.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException));

另外,这里不推荐强制修改 post 数据。

有什么好的办法吗,前端传过来的参数是 Post 我无法确定要修改哪些部分,这是在后端无法知晓的总会被覆盖,并且我认为这里强制更新对文章应该没有影响,该覆盖的还是会被覆盖只要数据最终是一致的

@f2c-ci-robot f2c-ci-robot bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2024
@guqing guqing requested review from LIlGG and JohnNiang March 27, 2024 10:25
Copy link

sonarcloud bot commented Mar 27, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.3% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

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

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2024
Copy link

f2c-ci-robot bot commented Mar 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 27, 2024
@f2c-ci-robot f2c-ci-robot bot merged commit 867d86b into halo-dev:main Mar 27, 2024
8 checks passed
@ruibaby ruibaby removed this from the 2.14.x milestone Mar 27, 2024
@ruibaby ruibaby added this to the 2.14.0 milestone Mar 27, 2024
@guqing guqing deleted the refactor/5579 branch March 27, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

修改文章标题之后保存可能会保存失败
4 participants