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

保存主题自定义设置失败 #1068

Closed
whymesay opened this issue Sep 13, 2020 · 1 comment · Fixed by #1070
Closed

保存主题自定义设置失败 #1068

whymesay opened this issue Sep 13, 2020 · 1 comment · Fixed by #1070
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@whymesay
Copy link

我的环境

版本:1.3.2
数据库:MySQL 8.0.20
运行模式:production
User Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36

错误日志

Caused by: javax.persistence.NonUniqueResultException: query did not return a unique result: 6
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:128) ~[hibernate-core-5.4.12.Final.jar!/:5.4.12.Final]
	at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1585) ~[hibernate-core-5.4.12.Final.jar!/:5.4.12.Final]
	at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:111) ~[hibernate-core-5.4.12.Final.jar!/:5.4.12.Final]
	at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) ~[spring-data-jpa-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) ~[spring-data-jpa-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) ~[spring-data-jpa-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) ~[spring-data-jpa-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:618) ~[spring-data-commons-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605) ~[spring-data-commons-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.transaction.interceptor.TransactionInterceptor$$Lambda$846/000000006DAE8470.proceedWithInvocation(Unknown Source) ~[na:na]
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) ~[spring-tx-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	... 119 common frames omitted

期望行为

当前行为

保存主题自定义设置--的时候,如果网速比较慢,多次点击保存按钮,会出现将新增主题设置重复保存的情
setting_key 和 theme_id在数据库中重复,导致后续保存都会失败,只能手动到数据库删除,是否应该添加setting_key 和 theme_id的唯一索引

@whymesay whymesay added the kind/bug Categorizes issue or PR as related to a bug. label Sep 13, 2020
@ruibaby
Copy link
Member

ruibaby commented Sep 13, 2020

@yuanhca 是的,这是一个 bug,你现在只能去数据库手动删除多余的数据。

@lnsane lnsane mentioned this issue Sep 14, 2020
lnsane added a commit to lnsane/halo that referenced this issue Sep 14, 2020
@lnsane lnsane mentioned this issue Sep 14, 2020
JohnNiang pushed a commit that referenced this issue Sep 14, 2020
* fix: #1068

* add: ThemeSettingService.save add SERIALIZABLE level

* add: saveSettingsByThemeId Api add @CacheLock
ruibaby pushed a commit to ruibaby/halo that referenced this issue Jun 11, 2021
* fix: halo-dev#1068

* add: ThemeSettingService.save add SERIALIZABLE level

* add: saveSettingsByThemeId Api add @CacheLock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants