本次涉及 100+ Dubbo 后端服务升级,过程沉淀的一些素材、以及踩过的一些坑,将其整理成文,由于公司安全,暂时没有太多截图。

1. dubbo升级要求

由于安全要求,需要将 Nacos 从本地升级迁移到阿里云 MSE Nacos,但是对 Dubbo 版本有要求,因此需要对 Dubbo 先进行版本升级。当前服务版本是 3.0.10, 因此必须升级最低版本是 3.1。 本文是一些升级过程的素材。

2. 官方版本推荐

针对版本升级,Dubbo 官文推荐最稳定的版本如下:https://cn.dubbo.apache.org/zh-cn/download/

截止2026.3.17 Dubbo官方推荐的最稳定版本,分别是 3.1.11、3.2.19、3.3.6。因此目标版本如上。 不过在升级到这些稳定版本之前,有一些注意事项需要关注。

3. 版本升级详细(各个版本升级详细)

为了彻底了解升级影响,枚举了过程所有版本,了解fixed、feature等情况。具体如下:

主要分三个大版本,分别是3.1.x、3.2.x、3.3.x

3.0.10 -> 3.0.15

3.0.x 版本主要的一些 bug 和 fixed 情况如下:

3.0.11 版本 (fixed)

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.0.11

3.0.12 版本 (fixed)

Bug fixed、部分小优化

https://github.com/apache/dubbo/releases/tag/dubbo-3.0.12

3.0.13 版本 (fixed)

  • Revert "Local references support mergeable"
  • Update check list

https://github.com/apache/dubbo/releases/tag/dubbo-3.0.13

3.0.14 版本 (feature)

  • Add serializable check for pojo

https://github.com/apache/dubbo/releases/tag/dubbo-3.0.14

3.0.15 版本 (feature)

https://github.com/apache/dubbo/releases/tag/dubbo-3.0.15

3.1 -> 3.1.11

版本

升级内容

链接信息

3.1 版本 (feature)

  • Sidecar mesh 支持
  • xDS proxyless mesh 支持
  • fastjson2 support
  • Port Unification support.
  • Dubbo Reactive stream with project reactor

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.0

3.1.1 版本(fixed)

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.1

3.1.2 版本(feature+fixed)

  • jdk19 支持
  • Spring 注解 @AliasFor 支持
  • Experimental support for upper header in triple
  • 添加线程池耗尽侦听器配置

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.2

3.1.3版本( fixed 为主)

Bug fixed 为主

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.3

3.1.4 版本(feature+fixed)

  • Dubbo QoS 支持国外 ip 白名单
  • fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.4

3.1.5 版本(feature+fixed)

  • Add nacos create client retry
  • 添加 Nacos sub try test
  • 添加 serialzie 类检查
  • ....

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.5

3.1.6 版本(feature+fixed)

  • Add service name mapping retry
  • ....

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.6

3.1.7 版本(feature+fixed)

  • 增强可序列化检查选项
  • Triple stub 支持

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.7

3.1.8 版本(fixed)

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.8

3.1.9 版本(fixed)

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.9

3.1.10 版本(fixed)

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.10

3.1.11 版本(feature)

  • 按输入增强日志
  • 使用 random id by

https://github.com/apache/dubbo/releases/tag/dubbo-3.1.11

3.2->3.2.16

3.2 版本 (core feature)

  • 原生 REST 协议支持(beta):Dubbo 现在可以只使用 Netty 导出或引用 RESTful 服务。
  • 可观测性:Dubbo 引入了一系列指标和追踪能力,并支持多种方式向第三方采集器上报。
  • GraalVM 原生镜像支持:您现在可以使用 dubbo-maven-plugin 将 Dubbo 作为原生镜像运行,而无需任何代理进行预处理。
  • JDK17 和 Spring Boot 3 支持:Dubbo 现在正式支持 JDK17 和 Spring Boot 3。
  • 对于 Dubbo 协议,Dubbo 3.2 比 3.1 快了 10 倍。对于 Triple 协议,Dubbo 3.2 的性能可以与 gRPC-Java 相媲美。

https://github.com/apache/dubbo/releases/tag/dubbo-3.2.0

3.2.1 版本 (feature + fixed)

  • Rest netty server support tls
  • 支持 packable 方法扩展

.......

https://github.com/apache/dubbo/releases/tag/dubbo-3.2.1

3.2.2 版本 (feature + fixed)

  • Rest netty server support tls
  • 支持 packable 方法扩展

.......

https://github.com/apache/dubbo/releases/tag/dubbo-3.2.2

....

....

....

3.2.16 版本 (feature + fixed)

Bug fixed

https://github.com/apache/dubbo/releases/tag/dubbo-3.2.16

注意大版本的更新都是跨度比较大的,在更新的时候特别要注意前后兼容。

4. 升级注意实现

4.1. 一些踩坑细节

MetadataInfo#getParameter #NPE

Fastjson2 对特殊字符反序列化失败

排除 Fastjson2

日志不断输出 disconnected、 established (解决)

dubbo3.2.16 对日志修改,会打印 pod 的就绪探针日志,、NettyServerHandler的disconnect 日志输出

日志级别修改。(pod probe 的端口可以改成 QOS)

rest 变动从 servlet server-> netty server

3.2 版本改动了 rest server 的实现,移除所有 servlet 的server

可以解决,切换实现类; 但不能兼容上层应用的 API

Unsupported protocol 协议不支持

由问题MetadataInfo#getParameter #NPE 导致,生成 empty//xxx 协议

排除 Fastjson2

No Provider 服务找不到(偶现,由多种原因共同组成产生)

排除问题1.2 ; 且升级版本未重现

未重现

4.2. 3.2.x 版本(重点变化)

1、REST Server只支持netty,配置成其他最后实例化都是使用NettyHttpRestServer,源码只支持 netty,不再支持其他的 server

2、原生 REST 协议(Netty Server)不支持设置 HTTP Status Code。

3、不能直接使用 JAX-RS 标准的 @Context 注解获取 Servlet 上下文信息。

4、不能使用JAX-RS标准的ExceptionMapper。

5、不能输出HTTP日志。

6、dubbo-rpc-rest包依赖了JAX-RS的实现RESTEasy,但不能处理javax.ws.rs.core.Response。

RpcContext.getContext().getRequest(NettyRequestFacade.class) 兼容; 但上下文传递过程,一旦有未升级的服务,那么上下文获取会失败,导致调用异常、数据丢失等风险。

4.3. 序列化协议升级

  • 3.1.0 版本中,Dubbo 默认支持的序列化协议新增对 Fastjson2 的支持。部分用户可能会考虑在现有的系统中对序列化协议进行升级,但服务端和客户端版本的差异可能导致客户端并不支持服务端的序列化协议。
  • 3.2.0 版本中, Dubbo 的服务端引入新的配置 prefer-serialization,该特性可以完美解决服务端序列化升级过程中可能带来的风险。

升级协议需要的注意事项

https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/serialization/serialization-upgrade/

4.4. github 的问题讨论

关于版本升级,也在 dubbo 官网发起过一些讨论。主要是 3.2 有较大版本的变化。

3.2 版本丢弃 servlet server,换成 netty server,如果平滑升级?

  1. https://github.com/apache/dubbo/discussions/15162

dubbo repeatedly established and disconnected connections ?

https://github.com/apache/dubbo/discussions/15159

dubbo upgrade 3.0.10->3.2.16, occurred NPE ? #15132

https://github.com/apache/dubbo/discussions/15132

4.5. 兼容注意事项

检查项目

具体描述

检查application.yml 是否配置属性: dubbo.registry.group

如果没有配置,则直接跳过

从 Dubbo 3.1.0 开始,dubbo.registry.group 属性被重新启用,用于对齐 Nacos 注册中心中的分组。如果设置 dubbo.registry.group则需要设置 dubbo.registry.group;否则跳过

点击查询详情 (3.0->3.1)

3.2 版本中,Dubbo 将默认开启序列化白名单的强校验。application.yml 中增加配置

-Ddubbo.application.serialize-check-status=WARN

在升级 Dubbo 3.2.0 版本前添加 -Ddubbo.application.serialize-check-status=WARN 配置以保证最佳的兼容性。否则可能导致线上数据异常的情况!

点击查询详情 (3.1->3.2)

Dubbo 3.2.0 版本开始默认序列化方式从 hessian2 切换为 fastjson2

如果序列化没有特殊要求,可以跳过

Dubbo 3.2.0 版本开始默认序列化方式从 hessian2 切换为 fastjson2

如果有配置序列化要求,则选择配置: dubbo.provider.prefer-serialization=fastjson2,hessian2

点击查询详情 (3.1->3.2)

4.6. github常见问题

5. live 存活探针日志 (额外)

https://blog.csdn.net/shupili141005/article/details/137884052

https://support.huaweicloud.com/basics-cce/kubernetes_0026.html

https://blog.csdn.net/shupili141005/article/details/137884052

<!-- k8s liveness probe qos日志很多,不打印 -->

<logger name="org.apache.dubbo.qos.command" level="warn" additivity="false"/>

logging.level.org.apache.dubbo.qos.command=warn

6. 充分测试

迁移过程离不开充分的测试。包括全链路测试、多维度多角度测试、灰度等,下面是一些测试视角:

  • 单服务
  • 集群
  • 消费者、服务者
  • Instance、All 等注册模式
  • .......

保障测试到位,避免升级代理的不兼容带来的业务影响。

Logo

智能硬件社区聚焦AI智能硬件技术生态,汇聚嵌入式AI、物联网硬件开发者,打造交流分享平台,同步全国赛事资讯、开展 OPC 核心人才招募,助力技术落地与开发者成长。

更多推荐