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

bugfix: fix the column TINYINT(1) in MySql being resolved to BIT type #6068

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ jobs:
# step 4
- name: "Test with Maven"
run: |
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dspring-boot-for-server.version=2.5.14 -Dspring-framework-for-server.version=5.3.20 -Dkotlin-maven-plugin.version=1.7.22 -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dspring-boot-for-server.version=2.7.17 -Dspring-framework-for-server.version=5.3.30 -Dkotlin-maven-plugin.version=1.7.22 -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
10 changes: 10 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-rm-datasource-mysql5</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-rm-datasource-mysql8</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-sqlparser-core</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@
<artifactId>seata-rm-datasource</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-rm-datasource-mysql5</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-rm-datasource-mysql8</artifactId>
<version>${project.version}</version>
</dependency>
<!-- the 'seata-server' is an application, not a dependency
<dependency>
<groupId>io.seata</groupId>
Expand Down
4 changes: 2 additions & 2 deletions build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- The version of spring-boot for 'spring-boot-dependencies' and 'spring-boot-maven-plugin' -->
<spring-boot.version>2.5.13</spring-boot.version>
<spring-framework.version>5.3.20</spring-framework.version>
<spring-boot.version>2.7.17</spring-boot.version>
<spring-framework.version>5.3.30</spring-framework.version>

<!-- For test -->
<junit-jupiter.version>5.8.2</junit-jupiter.version>
Expand Down
3 changes: 2 additions & 1 deletion changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Add changes here for all PR submitted to the develop branch.
- [[#5991](https://github.com/seata/seata/pull/5991)] fix the issue that the Lua script is not synchronized when the redis sentinel master node is down
- [[#6025](https://github.com/seata/seata/pull/6025)] fix the white screen after click the "View Global Lock" button on the transaction info page in the console
- [[#6026](https://github.com/seata/seata/pull/6026)] fix incorrect metric report
- [[#6068](https://github.com/seata/seata/pull/6068)] fix the column `TINYINT(1)` in MySql being resolved to `BIT` type

### optimize:
- [[#6044](https://github.com/seata/seata/pull/6044)] optimize derivative product check base on mysql
Expand All @@ -27,6 +28,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [jsbxyyx](https://github.com/jsbxyyx)
- [liuqiufeng](https://github.com/liuqiufeng)
- [ptyin](https://github.com/ptyin)

- [wangliang181230](https://github.com/wangliang181230)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
2 changes: 2 additions & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [[#5991](https://github.com/seata/seata/pull/5991)] 修复redis sentinel master node 宕机时,lua脚本未同步的问题
- [[#6025](https://github.com/seata/seata/pull/6025)] 修复控制台点击事务信息页面中的"查看全局锁"按钮之后白屏的问题
- [[#6026](https://github.com/seata/seata/pull/6026)] 修复异常的打点
- [[#6068](https://github.com/seata/seata/pull/6068)] 修复 “MySql中的 `TINYINT(1)` 类型字段被解析为`BIT`,导致回滚后的值要么是0,要么是1。而不是原来的值。” 的问题。

### optimize:
- [[#6044](https://github.com/seata/seata/pull/6044)] 优化MySQL衍生数据库判断逻辑
Expand All @@ -27,5 +28,6 @@
- [jsbxyyx](https://github.com/jsbxyyx)
- [liuqiufeng](https://github.com/liuqiufeng)
- [ptyin](https://github.com/ptyin)
- [wangliang181230](https://github.com/wangliang181230)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.common.loader;

/**
* The DependsOn Exception
*
* @author wang.liang
*/
class DependsOnException extends Exception {

public DependsOnException(String message) {
super(message);
}

public DependsOnException(String message, Throwable cause) {
super(message, cause);
}

public DependsOnException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.seata.common.Constants;
import io.seata.common.executor.Initialize;
import io.seata.common.util.CollectionUtils;
import io.seata.common.util.ReflectionUtil;
import io.seata.common.util.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -339,7 +340,7 @@ private S load(String activateName, Object[] args, ClassLoader loader)
* @param activateName the activate name
* @param argsType the args type
* @param args the args
* @param loader the class loader
* @param loader the class loader
* @return the s
* @throws EnhancedServiceNotFoundException the enhanced service not found exception
*/
Expand All @@ -350,8 +351,8 @@ private S load(String activateName, Class<?>[] argsType, Object[] args, ClassLoa

/**
* get all implements
* @param loader the class loader
*
* @param loader the class loader
* @return list list
*/
private List<S> loadAll(ClassLoader loader) {
Expand Down Expand Up @@ -541,7 +542,7 @@ private void loadFile(String dir, ClassLoader loader, List<ExtensionDefinition<S
continue;
}
extensions.add(extensionDefinition);
} catch (LinkageError | ClassNotFoundException e) {
} catch (LinkageError | ClassNotFoundException | DependsOnException e) {
LOGGER.warn("Load [{}] class fail: {}", line, e.getMessage());
} catch (ClassCastException e) {
LOGGER.error("Load [{}] class fail, please make sure the extension" +
Expand Down Expand Up @@ -572,7 +573,7 @@ private void loadFile(String dir, ClassLoader loader, List<ExtensionDefinition<S

@SuppressWarnings("unchecked")
private ExtensionDefinition<S> getUnloadedExtensionDefinition(String className, ClassLoader loader)
throws ClassNotFoundException, ClassCastException {
throws ClassNotFoundException, ClassCastException, DependsOnException {
//Check whether the definition has been loaded
if (!isDefinitionContainsClazz(className, loader)) {
Class<?> clazz = Class.forName(className, true, loader);
Expand All @@ -584,11 +585,17 @@ private ExtensionDefinition<S> getUnloadedExtensionDefinition(String className,
String serviceName = null;
int priority = 0;
Scope scope = Scope.SINGLETON;
LoadLevel loadLevel = clazz.getAnnotation(LoadLevel.class);
if (loadLevel != null) {
serviceName = loadLevel.name();
priority = loadLevel.order();
scope = loadLevel.scope();
try {
LoadLevel loadLevel = clazz.getAnnotation(LoadLevel.class);
if (loadLevel != null) {
serviceName = loadLevel.name();
priority = loadLevel.order();
scope = loadLevel.scope();

this.verifyDependsOn(loadLevel);
}
} catch (ArrayStoreException | TypeNotPresentException e) {
throw new DependsOnException("Verify depends on classes failed.", e);
}
ExtensionDefinition<S> result = new ExtensionDefinition<>(serviceName, priority, scope, enhancedServiceClass);
classToDefinitionMap.put(clazz, result);
Expand All @@ -601,6 +608,20 @@ private ExtensionDefinition<S> getUnloadedExtensionDefinition(String className,
return null;
}

private void verifyDependsOn(LoadLevel loadLevel) throws DependsOnException {
// In java11 and above, a TypeNotPresentException will throw only after obtaining it once,
// if any dependent class does not exist.
@SuppressWarnings("unused")
Class<?>[] dependsOnClasses = loadLevel.dependsOnClasses();

// verify depends on class names
for (String className : loadLevel.dependsOnClassNames()) {
if (!ReflectionUtil.existsClass(className)) {
throw new DependsOnException("The dependent class '" + className + "' does not exist");
}
}
}

private boolean isDefinitionContainsClazz(String className, ClassLoader loader) {
for (Map.Entry<Class<?>, ExtensionDefinition<S>> entry : classToDefinitionMap.entrySet()) {
if (!entry.getKey().getName().equals(className)) {
Expand Down Expand Up @@ -654,6 +675,7 @@ private S initInstance(Class<S> implClazz, Class<?>[] argTypes, Object[] args)

/**
* Helper Class for hold a value.
*
* @param <T>
*/
private static class Holder<T> {
Expand Down
14 changes: 14 additions & 0 deletions common/src/main/java/io/seata/common/loader/LoadLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@
* Scope enum.
*/
Scope scope() default Scope.SINGLETON;

/**
* Depends on classes.
*
* @return the classes
*/
Class<?>[] dependsOnClasses() default {};

/**
* Depends on class names.
*
* @return the class names
*/
String[] dependsOnClassNames() default {};
}
25 changes: 25 additions & 0 deletions common/src/test/java/io/seata/common/loader/AfricaHello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.common.loader;

/**
* The type Africa hello.
*
* @author wang.liang
*/
@LoadLevel(name = "AfricaHello", dependsOnClasses = String.class, dependsOnClassNames = "java.lang.Integer")
public class AfricaHello implements Hello3 {
}
25 changes: 25 additions & 0 deletions common/src/test/java/io/seata/common/loader/AustraliaHello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.common.loader;

/**
* The type Australia hello.
*
* @author wang.liang
*/
@LoadLevel(name = "AustraliaHello", dependsOnClassNames = "io.seata.Xxxxx")
public class AustraliaHello implements Hello3 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,10 @@ public void classCastExceptionTest() {
});
}

@Test
public void testDependsOn() {
List<Hello3> hello3List = EnhancedServiceLoader.loadAll(Hello3.class);
assertThat(hello3List.size()).isEqualTo(1);
assertThat(hello3List.get(0).getClass()).isEqualTo(AfricaHello.class);
}
}
22 changes: 22 additions & 0 deletions common/src/test/java/io/seata/common/loader/Hello3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.common.loader;

/**
* @author wang.liang
*/
interface Hello3 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
io.seata.common.loader.AfricaHello
io.seata.common.loader.AustraliaHello
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @author ph3636
*/
@LoadLevel(name = "FastThreadLocalContextCore", order = Integer.MIN_VALUE + 1)
@LoadLevel(name = "FastThreadLocalContextCore", order = Integer.MIN_VALUE + 1, dependsOnClasses = FastThreadLocal.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么要把不想干的代码一起改了?
Why did you change the unrelated code together?

public class FastThreadLocalContextCore implements ContextCore {

private FastThreadLocal<Map<String, Object>> fastThreadLocal = new FastThreadLocal<Map<String, Object>>() {
Expand Down
22 changes: 5 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.seata</groupId>
<artifactId>seata-build</artifactId>
<artifactId>seata-dependencies</artifactId>
<version>${revision}</version>
<relativePath>./build/pom.xml</relativePath>
<relativePath>./dependencies/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -52,6 +52,8 @@
<module>integration/brpc</module>
<module>rm</module>
<module>rm-datasource</module>
<module>rm-datasource-mysql5</module>
<module>rm-datasource-mysql8</module>
<module>spring</module>
<module>spring-aot</module>
<module>spring-framework-fake-for-java8</module>
Expand Down Expand Up @@ -104,18 +106,6 @@
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-dependencies</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<profiles>
<!-- profile: licenseCheck -->
<profile>
Expand Down Expand Up @@ -158,15 +148,13 @@
<properties>
<image.publish.skip>false</image.publish.skip>
<dependencies.copy.skip>false</dependencies.copy.skip>
<mysql.jdbc.version>5.1.42</mysql.jdbc.version>
<mysql8.jdbc.version>8.0.27</mysql8.jdbc.version>
</properties>
</profile>
<!-- profile: release-image-based-on-java8 -->
<profile>
<id>release-image-based-on-java8</id>
<properties>
<image.tags>${project.version},latest</image.tags>
<image.tags>${project.version}</image.tags>
</properties>
</profile>
<!-- profile: release-image-based-on-java8-slim -->
Expand Down
Loading