Skip to content
Open
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
4 changes: 4 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>io.netty.incubator</groupId>
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7664](https://github.com/apache/incubator-seata/pull/7664)] support shentongdatabase XA mode
- [[#7675](https://github.com/apache/incubator-seata/pull/7675)] support Oracle Batch Insert
- [[#7663](https://github.com/apache/incubator-seata/pull/7663)] add Java 25 support in CI configuration files

- [[#7338](https://github.com/apache/incubator-seata/pull/7338)] feat: add io-uring to server and client

### bugfix:

Expand Down
2 changes: 1 addition & 1 deletion changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
- [[#7485](https://github.com/apache/incubator-seata/pull/7485)] 给seata-server端的http请求添加过滤器
- [[#7509](https://github.com/apache/incubator-seata/pull/7509)] 复用连接合并分支事务
- [[#7492](https://github.com/apache/incubator-seata/pull/7492)] 升级 common 模块中的 HTTP 客户端以支持 HTTP/2
- [[#7338](https://github.com/apache/incubator-seata/pull/7338)] 添加server和client的io-uring的支持
- [[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils支持达梦数据库
- [[#7559](https://github.com/apache/incubator-seata/pull/7559)] 为 TableMetaRefreshHolder 实例引入清理 API
- [[#7669](https://github.com/apache/incubator-seata/pull/7669)] 添加对 Jackson 序列化和反序列化 PostgreSQL 数组类型的支持
- [[#7664](https://github.com/apache/incubator-seata/pull/7565)] 支持神通数据库的XA模式
- [[#7675](https://github.com/apache/incubator-seata/pull/7675)] 支持Oracle批量插入
- [[#7663](https://github.com/apache/incubator-seata/pull/7663)] 支持java25版本的CI流水綫


### bugfix:

- [[#6476](https://github.com/apache/seata/issues/6476)] 修复SerialArray equals()方法在二阶段回滚中多维数组比较的问题
Expand Down
5 changes: 5 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<!--io-uring-->
<dependency>
<groupId>io.netty.incubator</groupId>
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1282,4 +1282,14 @@ public interface ConfigurationKeys {
* The constant RATE_LIMIT_BUCKET_TOKEN_INITIAL_NUM.
*/
String RATE_LIMIT_BUCKET_TOKEN_INITIAL_NUM = RATE_LIMIT_PREFIX + ".bucketTokenInitialNum";

/**
* The constant TRANSPORT_IO_PREFIX.
*/
String TRANSPORT_IO_PREFIX = TRANSPORT_PREFIX + "io.";

/**
* The constant TRANSPORT_IO_IO_URING_ENABLE.
*/
String TRANSPORT_IO_IO_URING_ENABLE = TRANSPORT_IO_PREFIX + "ioUringEnable";
}
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,9 @@ public interface DefaultValues {
"<object>",
"<style>",
"<link>");

/**
* The constant DEFAULT_TRANSPORT_IO_IO_URING_ENABLE.
*/
boolean DEFAULT_TRANSPORT_IO_IO_URING_ENABLE = false;
}
4 changes: 4 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>io.netty.incubator</groupId>
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.incubator.channel.uring.IOUring;
import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
import io.netty.incubator.channel.uring.IOUringSocketChannel;
import io.netty.util.NettyRuntime;
import io.netty.util.internal.PlatformDependent;
import org.apache.commons.lang3.StringUtils;
import org.apache.seata.common.DefaultValues;
import org.apache.seata.config.Configuration;
import org.apache.seata.config.ConfigurationFactory;
import org.apache.seata.core.constants.ConfigurationKeys;
Expand Down Expand Up @@ -57,6 +61,12 @@ public class NettyBaseConfig {
*/
protected static final boolean SHARE_BOSS_WORKER = CONFIG.getBoolean(ConfigurationKeys.SHARE_BOSS_WORKER);

/**
* The constant SERVER_CHANNEL_MAX_WRITE_BUFFER_SIZE.
*/
protected static final boolean TRANSPORT_IO_IO_URING_ENABLE = CONFIG.getBoolean(
ConfigurationKeys.TRANSPORT_IO_IO_URING_ENABLE, DefaultValues.DEFAULT_TRANSPORT_IO_IO_URING_ENABLE);

/**
* The constant WORKER_THREAD_SIZE.
*/
Expand Down Expand Up @@ -101,8 +111,14 @@ public class NettyBaseConfig {
}

boolean useEpoll = !PlatformDependent.isWindows() && !PlatformDependent.isOsx() && Epoll.isAvailable();
SERVER_CHANNEL_CLAZZ = useEpoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
CLIENT_CHANNEL_CLAZZ = useEpoll ? EpollSocketChannel.class : NioSocketChannel.class;
boolean useIoUring = TRANSPORT_IO_IO_URING_ENABLE && IOUring.isAvailable();
if (useIoUring) {
SERVER_CHANNEL_CLAZZ = IOUringServerSocketChannel.class;
CLIENT_CHANNEL_CLAZZ = IOUringSocketChannel.class;
} else {
SERVER_CHANNEL_CLAZZ = useEpoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
CLIENT_CHANNEL_CLAZZ = useEpoll ? EpollSocketChannel.class : NioSocketChannel.class;
}

boolean enableHeartbeat = CONFIG.getBoolean(ConfigurationKeys.TRANSPORT_HEARTBEAT, DEFAULT_TRANSPORT_HEARTBEAT);
if (enableHeartbeat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.netty.handler.codec.http2.Http2MultiplexHandler;
import io.netty.handler.codec.http2.Http2StreamChannelBootstrap;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
import io.netty.util.internal.PlatformDependent;
import org.apache.seata.common.exception.FrameworkException;
import org.apache.seata.common.thread.NamedThreadFactory;
Expand Down Expand Up @@ -233,14 +234,25 @@ private EventLoopGroup getOrCreateEventLoopGroupWorker(int selectorThreadSizeThr
}

private EventLoopGroup createEventLoopGroupWorker(int selectorThreadSizeThreadSize) {
if (NettyServerConfig.enableIoUring()) {
LOGGER.info("Using IOUringEventLoopGroup for Netty Client");
return new IOUringEventLoopGroup(
selectorThreadSizeThreadSize,
new NamedThreadFactory(
getThreadPrefix(this.nettyClientConfig.getClientSelectorThreadPrefix()),
selectorThreadSizeThreadSize));
}

if (NettyServerConfig.enableEpoll()) {
LOGGER.info("Using EpollEventLoopGroup for Netty Client");
return new EpollEventLoopGroup(
selectorThreadSizeThreadSize,
new NamedThreadFactory(
getThreadPrefix(this.nettyClientConfig.getClientSelectorThreadPrefix()),
selectorThreadSizeThreadSize));
}

LOGGER.info("Using NioEventLoopGroup for Netty Client");
return new NioEventLoopGroup(
selectorThreadSizeThreadSize,
new NamedThreadFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
import org.apache.seata.common.ConfigurationKeys;
import org.apache.seata.common.XID;
import org.apache.seata.common.metadata.Instance;
Expand Down Expand Up @@ -69,6 +70,7 @@ public class NettyServerBootstrap implements RemotingBootstrap {
public NettyServerBootstrap(NettyServerConfig nettyServerConfig) {
this.nettyServerConfig = nettyServerConfig;
if (NettyServerConfig.enableEpoll()) {
LOGGER.info("Using EpollEventLoopGroup for Netty Server");
this.eventLoopGroupBoss = new EpollEventLoopGroup(
nettyServerConfig.getBossThreadSize(),
new NamedThreadFactory(
Expand All @@ -79,7 +81,19 @@ public NettyServerBootstrap(NettyServerConfig nettyServerConfig) {
nettyServerConfig.getWorkerThreadPrefix(),
nettyServerConfig.getServerWorkerThreads(),
false));
} else if (NettyServerConfig.enableIoUring()) {
LOGGER.info("Using IOUringEventLoopGroup for Netty Server");
this.eventLoopGroupBoss = new IOUringEventLoopGroup(
nettyServerConfig.getBossThreadSize(),
new NamedThreadFactory(
nettyServerConfig.getBossThreadPrefix(), nettyServerConfig.getBossThreadSize()));
this.eventLoopGroupWorker = new IOUringEventLoopGroup(
nettyServerConfig.getServerWorkerThreads(),
new NamedThreadFactory(
nettyServerConfig.getWorkerThreadPrefix(), nettyServerConfig.getServerWorkerThreads()));
System.out.println("Using IOUringEventLoopGroup for Netty server");
} else {
LOGGER.info("Using NioEventLoopGroup for Netty Server");
this.eventLoopGroupBoss = new NioEventLoopGroup(
nettyServerConfig.getBossThreadSize(),
new NamedThreadFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import io.netty.channel.ServerChannel;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.incubator.channel.uring.IOUring;
import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
import org.apache.seata.common.DefaultValues;
import org.apache.seata.core.constants.ConfigurationKeys;

Expand Down Expand Up @@ -127,6 +129,15 @@ public static boolean enableEpoll() {
return NettyBaseConfig.SERVER_CHANNEL_CLAZZ.equals(EpollServerSocketChannel.class) && Epoll.isAvailable();
}

/**
* Enable io-uring boolean.
*
* @return the boolean
*/
public static boolean enableIoUring() {
return NettyBaseConfig.SERVER_CHANNEL_CLAZZ.equals(IOUringServerSocketChannel.class) && IOUring.isAvailable();
}

/**
* Gets server socket send buf size.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.incubator.channel.uring.IOUring;
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
import io.netty.util.internal.PlatformDependent;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -81,6 +84,24 @@ void testStartWithSharedEventLoopAndChannelSelection() {
tmNettyClientBootstrap.start();
}

@Test
void testIOUringEventLoopGroup() {
try (MockedStatic<NettyServerConfig> mockedStatic = org.mockito.Mockito.mockStatic(NettyServerConfig.class)) {
mockedStatic.when(NettyServerConfig::enableIoUring).thenReturn(true);
if (IOUring.isAvailable()) {
NettyClientBootstrap tmNettyClientBootstrap =
new NettyClientBootstrap(nettyClientConfig, NettyPoolKey.TransactionRole.TMROLE);
EventLoopGroup tmEventLoopGroupWorker = getEventLoopGroupWorker(tmNettyClientBootstrap);
Assertions.assertTrue(tmEventLoopGroupWorker instanceof IOUringEventLoopGroup);

} else {
Assertions.assertThrows(
UnsatisfiedLinkError.class,
() -> new NettyClientBootstrap(nettyClientConfig, NettyPoolKey.TransactionRole.TMROLE));
}
}
}

private EventLoopGroup getEventLoopGroupWorker(NettyClientBootstrap bootstrap) {
try {
java.lang.reflect.Field field = NettyClientBootstrap.class.getDeclaredField("eventLoopGroupWorker");
Expand Down
6 changes: 6 additions & 0 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<motan.version>1.0.0</motan.version>
<jcommander.version>1.82</jcommander.version>
<bucket4j.version>8.1.0</bucket4j.version>
<netty-io-uring.version>0.0.26.Final</netty-io-uring.version>
<commons-compress.version>1.27.1</commons-compress.version>
<ant.version>1.10.12</ant.version>
<lz4.version>1.7.1</lz4.version>
Expand Down Expand Up @@ -629,6 +630,11 @@
<artifactId>bucket4j_jdk8-core</artifactId>
<version>${bucket4j.version}</version>
</dependency>
<dependency>
<groupId>io.netty.incubator</groupId>
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
<version>${netty-io-uring.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion script/config-center/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ transport.threadFactory.workerThreadSize=default
transport.shutdown.wait=3
transport.serialization=seata
transport.compressor=none
transport.io.ioUringEnable=false
#HTTP thread pool
transport.minHttpPoolSize=10
transport.maxHttpPoolSize=100
Expand All @@ -57,7 +58,6 @@ transport.maxServerPoolSize=500
transport.maxTaskQueueSize=20000
transport.keepAliveTime=500


#Transaction routing rules configuration, only for the client
service.vgroupMapping.default_tx_group=default
#If you use a registry, you can ignore it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.seata.spring.boot.autoconfigure.properties.LogProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.ShutdownProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.ThreadFactoryProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.TransportIoProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.TransportProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigApolloProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigConsulProperties;
Expand Down Expand Up @@ -116,6 +117,7 @@ public static void init() {
PROPERTY_BEAN_MAP.put(TRANSPORT_PREFIX, TransportProperties.class);
PROPERTY_BEAN_MAP.put(SHUTDOWN_PREFIX, ShutdownProperties.class);
PROPERTY_BEAN_MAP.put(LOG_PREFIX, LogProperties.class);
PROPERTY_BEAN_MAP.put(StarterConstants.TRANSPORT_IO_PREFIX, TransportIoProperties.class);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public interface StarterConstants {

String SERVER_PREFIX = SEATA_PREFIX + ".server";
String SERVER_RATELIMIT_PREFIX = SERVER_PREFIX + ".ratelimit";
String TRANSPORT_IO_PREFIX = TRANSPORT_PREFIX + ".io";
String SERVER_UNDO_PREFIX = SERVER_PREFIX + ".undo";
String SERVER_RAFT_PREFIX = SERVER_PREFIX + ".raft";
String SERVER_RAFT_SSL_PREFIX = SERVER_RAFT_PREFIX + ".ssl";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.seata.spring.boot.autoconfigure.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.TRANSPORT_IO_PREFIX;

@Component
@ConfigurationProperties(prefix = TRANSPORT_IO_PREFIX)
public class TransportIoProperties {
private boolean ioUringEnable;

public boolean isIoUringEnable() {
return ioUringEnable;
}

public void setIoUringEnable(boolean ioUringEnable) {
this.ioUringEnable = ioUringEnable;
}
}
2 changes: 2 additions & 0 deletions server/src/main/resources/application.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,5 @@ seata:
boss-thread-prefix: NettyBoss
worker-thread-prefix: NettyServerNIOWorker
boss-thread-size: 1
io:
ioUringEnable: false
2 changes: 2 additions & 0 deletions server/src/main/resources/application.raft.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,5 @@ seata:
boss-thread-prefix: NettyBoss
worker-thread-prefix: NettyServerNIOWorker
boss-thread-size: 1
io:
ioUringEnable: false
Loading