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

插件中调用 ReactiveSettingFetcher.get 获取到的一直是上一次的结果 #6213

Closed
Rainsheep opened this issue Jun 29, 2024 · 2 comments · Fixed by #6216
Closed
Assignees
Labels
area/core Issues or PRs related to the Halo Core area/plugin Issues or PRs related to the Plugin Provider kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@Rainsheep
Copy link

系统信息

使用的哪种方式运行?

Docker Compose

发生了什么?

版本: 2.17.0-alpha.2
我在插件中监听了 ConfigMap 的更新。 监听到更新后,我使用 ReactiveSettingFetcher.get 获取到的永远是上一次的值。
怀疑和 6 月 26 日 run.halo.app.plugin.DefaultReactiveSettingFetcher#getValuesInternal 的缓存变更有关

相关日志输出

No response

附加信息

No response

@JohnNiang
Copy link
Member

我会尝试复现以上问题。

@JohnNiang
Copy link
Member

经过排查,大概率是更新缓存发生在发送 Config 更新事件之后了。所以在事件监听处理中通过 ReactiveSettingFetcher#get 获取到的配置是过时的。

applicationContext.publishEvent(PluginConfigUpdatedEvent.builder()
.source(this)
.oldConfig(existData)
.newConfig(result)
.build());
// update cache
cache.put(pluginName, result);

/kind bug
/area core
/area plugin
/milestone 2.17.x
/assign

@f2c-ci-robot f2c-ci-robot bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 29, 2024
@f2c-ci-robot f2c-ci-robot bot added this to the 2.17.x milestone Jun 29, 2024
@f2c-ci-robot f2c-ci-robot bot added area/core Issues or PRs related to the Halo Core area/plugin Issues or PRs related to the Plugin Provider labels Jun 29, 2024
f2c-ci-robot bot pushed a commit that referenced this issue Jun 30, 2024
)

#### What type of PR is this?

/kind bug
/area core
/area plugin
/milestone 2.17.x

#### What this PR does / why we need it:

This PR  makes sure the method `cache#put` is called before the event is published to avoid the event listener to fetch the old value from the cache.

The problem was introduced by <#6141>.

#### Which issue(s) this PR fixes:

Fixes #6213 

#### Does this PR introduce a user-facing change?

```release-note
修复在插件配置变更监听器中始终获取到旧数据的问题
```
@ruibaby ruibaby modified the milestones: 2.17.x, 2.17.0 Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Issues or PRs related to the Halo Core area/plugin Issues or PRs related to the Plugin Provider kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants