问题环境
最近项目组正在升级jdk8到17,笔者正好负责这个过程中相关依赖jar包的整理工作
部分jar包以及中间件,例如spring-core的5.x系列,zookeeper等在这个过程中不能很好的支持jdk17,所以需要对其进行升级工作,并且要求能够同时支持jdk8与17(灰度需求),并且我们生产环境因为历史原因,部分jar包会有多个版本同时存在于classpath中,此次升级对于这些非强制性升级的jar包不会进行调整
生产环境的classpath路径:

同时存在多版本的jar包举例:

之前在生产环境用脚本看过一次jvm里的class,确认了这些class都是从低版本的jar包加载来的,所以默认了classpath下的加载顺序是文件名的字典序(事实并非如此)
我们在内网有30台+的服务器,笔者在整理完在内网其中5台部署了新的代码与依赖jar包,剩下的30台服务器在正常的开发流程中会慢慢的更新这些变动,当时这5台服务器部署完成后没有任何异常,因为jar包依赖的问题很难一下子测出来,所以笔者开了内网的日志监控上报 (根据一些异常的关键字如ClassNotFoundException等),准备观察一段时间看看.
通过内网日志监控及时捕捉关键子的异常代码

异常出现
仅仅一天过后,内网就开始出现部分服务器因为各种class文件的原因导致启动失败,业务报错等异常情况.这些服务器都是docker容器搭建的(后来证明与docker无关),笔者开始排查时发现linux原生环境都没有问题,出现异常的都是docker容器,所以导致开始的排查方向错误,以为是docker内部机制导致文件同步失败或者加载顺序等
异常堆栈:

幸运的是这次的类笔者比较熟悉,这个类出自jackson-databind.jar,并且在2.14.2版本是删除的,所以基本能够确定是先加载了2.14.2版本的jar,为了验证这个猜想,在启动脚本加上class加载相关的信息
-verbose:class 启动脚本加上class加载打印,可以看出这个类是从哪个jar包加载的
举个例子: 可以看出NettyEventExecutorMetrics这个类从micrometer-core-1.12.1.jar中加载而来
[89.090s][info][class,load] io.micrometer.core.instrument.binder.netty4.NettyEventExecutorMetrics source: file:/usr/local/cok/SFS2X/extensions/lib/micrometer-core-1.12.1.jar

至此基本能够确定问题点了,就是因为加载了高版本的jar包导致的异常,接下来就是弄清楚为什么这些机器是先加载了高版本的jar包
jar包加载顺序原理:
问题就是jar的加载顺序问题,这个顺序实际上是由文件系统决定的,linux内部是用inode来指示文件的。 这种储存文件元信息的区域就叫做inode,中文译名为”索引节点”。每一个文件都有对应的inode,里面包含了与该文件有关的一些信息。 Unix/linux系统内部不使用文件名,而使用inode号码来识别文件。
#查看文件的inode值
ll -i

实际的jar包读取顺序是按照这个inode值从小到大的顺序 例如图中的okhttp-4.11.0.jar会比okhttp-3.4.2.jar先加载
笔者又去扒了一下生产环境的inode值
生产环境:
538483828 -rwxr-xr-x. 1 root root 1718751 9月 9 2020 akka-actor-2.0.5.jar
538483829 -rwxr-xr-x. 1 root root 14416 9月 9 2020 akka-slf4j-2.0.5.jar
538483830 -rw-r--r--. 1 root root 3482 9月 9 2020 animal-sniffer-annotations-1.14.jar
538483831 -rwxr-xr-x. 1 root root 4467 9月 9 2020 aopalliance-1.0.jar
538483826 -rwxr-xr-x. 1 root root 7763 9月 9 2020 ApiGateway-HMAC_2.0.0.jar
538483832 -rw-r--r--. 1 root root 137693 5月 13 06:53 app-store-server-library8-1.0.jar
538483833 -rw-r--r--. 1 root root 53297 9月 9 2020 asm-5.0.4.jar
538483834 -rw-r--r--. 1 root root 20437 9月 9 2020 audience-annotations-0.5.0.jar
538483835 -rw-r--r--. 1 root root 792825 9月 9 2020 bcpkix-jdk15on-159.jar
538483837 -rw-r--r--. 1 root root 4092400 9月 9 2020 bcprov-jdk15on-159.jar
538483836 -rw-r--r--. 1 root root 5867298 10月 9 2023 bcprov-jdk15on-1.70.jar
538483838 -rwxr-xr-x. 1 root root 110600 9月 9 2020 bonecp-0.8.0.RELEASE.jar
538483839 -rwxr-xr-x. 1 root root 7767 9月 9 2020 boot.jar
538483840 -rwxr-xr-x. 1 root root 280513 9月 9 2020 bsh.jar
538483841 -rw-r--r--. 1 root root 879660 9月 9 2020 caffeine-2.8.0.jar
538483842 -rw-r--r--. 1 root root 301393 12月 18 2023 cglib-3.2.2.jar
538483843 -rw-r--r--. 1 root root 5816 9月 9 2020 checker-compat-qual-2.5.2.jar
538483844 -rw-r--r--. 1 root root 201216 9月 9 2020 checker-qual-2.10.0.jar
538483845 -rwxr-xr-x. 1 root root 188671 9月 9 2020 commons-beanutils-1.7.0.jar
538483846 -rw-r--r--. 1 root root 284184 9月 9 2020 commons-codec-1.10.jar
538483847 -rwxr-xr-x. 1 root root 575389 9月 9 2020 commons-collections-3.2.1.jar
538483848 -rwxr-xr-x. 1 root root 362679 9月 9 2020 commons-configuration-1.10.jar
538483849 -rwxr-xr-x. 1 root root 160519 9月 9 2020 commons-dbcp-1.4.jar
538483850 -rwxr-xr-x. 1 root root 109043 9月 9 2020 commons-io-1.4.jar
538483851 -rwxr-xr-x. 1 root root 261809 9月 9 2020 commons-lang-2.4.jar
538483852 -rw-r--r--. 1 root root 503880 9月 9 2020 commons-lang3-3.9.jar
538483853 -rw-r--r--. 1 root root 61829 9月 9 2020 commons-logging-1.2.jar
538483854 -rwxr-xr-x. 1 root root 96221 9月 9 2020 commons-pool-1.5.4.jar
538483855 -rw-r--r--. 1 root root 134858 9月 10 2021 commons-pool2-2.9.0.jar
538483856 -rwxr-xr-x. 1 root root 362717 9月 9 2020 commons-vfs-1.0.jar
538483857 -rwxr-xr-x. 1 root root 155044 9月 9 2020 config-0.3.1.jar
538483858 -rw-r--r--. 1 root root 167731 4月 18 2022 cron-utils-9.1.6.jar
538483859 -rw-r--r--. 1 root root 84626 7月 27 2023 disruptor-3.4.4.jar
538483860 -rwxr-xr-x. 1 root root 313898 9月 9 2020 dom4j-1.6.1.jar
538483469 drwxrwxrwx. 2 root root 261 6月 27 2019 @eaDir
538483827 -rw-r--r--. 1 root root 11532014 7月 8 05:05 elasticsearch-java-8.12.1.jar
538483861 -rw-r--r--. 1 root root 72739 7月 8 05:05 elasticsearch-rest-client-8.12.1.jar
538483869 -rw-r--r--. 1 root root 13161 9月 9 2020 error_prone_annotations-2.3.3.jar
538483870 -rwxr-xr-x. 1 root root 86487 9月 9 2020 ezmorph-1.0.6.jar
538483871 -rw-r--r--. 1 root root 4617 7月 15 2021 failureaccess-1.0.1.jar
538484000 -rw-r--r--. 1 root root 375938 8月 26 2021 fastjson-1.1.46.sec10.jar
538484001 -rw-r--r--. 1 root root 23371302 4月 3 2023 fastutil-8.5.11.jar
538484002 -rw-r--r--. 1 root root 207067 7月 15 2021 google-api-client-1.30.11.jar
538484003 -rw-r--r--. 1 root root 252818 7月 15 2021 google-api-services-androidpublisher-v3-rev20201022-1.30.10.jar
538484004 -rw-r--r--. 1 root root 5669 7月 15 2021 google-auth-library-credentials-0.21.1.jar
538484005 -rw-r--r--. 1 root root 114898 7月 15 2021 google-auth-library-oauth2-http-0.21.1.jar
538484006 -rw-r--r--. 1 root root 286856 7月 15 2021 google-http-client-1.37.0.jar
538484007 -rw-r--r--. 1 root root 8492 7月 15 2021 google-http-client-jackson2-1.37.0.jar
538484008 -rw-r--r--. 1 root root 69591 7月 15 2021 google-oauth-client-1.31.1.jar
538484009 -rw-r--r--. 1 root root 7395898 4月 10 2023 groovy-4.0.6.jar
538484010 -rw-r--r--. 1 root root 29411 7月 15 2021 grpc-context-1.22.1.jar
538484011 -rw-r--r--. 1 root root 283367 10月 9 2023 gson-2.10.1.jar
538484012 -rw-r--r--. 1 root root 241622 7月 15 2021 gson-2.8.5.jar
538484013 -rw-r--r--. 1 root root 2631690 7月 15 2021 guava-29.0-android.jar
538484014 -rw-r--r--. 1 root root 899523 9月 9 2020 hessian-4.0.62.jar
538484015 -rw-r--r--. 1 root root 1159086 10月 9 2023 hppc-0.8.1.jar
538484016 -rwxr-xr-x. 1 root root 1466174 9月 9 2020 hsqldb.jar
538484017 -rw-r--r--. 1 root root 179964 10月 9 2023 httpasyncclient-4.1.4.jar
538484018 -rw-r--r--. 1 root root 778156 10月 9 2023 httpclient-4.5.12.jar
538484019 -rw-r--r--. 1 root root 328593 10月 9 2023 httpcore-4.4.13.jar
538484020 -rw-r--r--. 1 root root 367672 10月 9 2023 httpcore-nio-4.4.12.jar
538484021 -rwxr-xr-x. 1 root root 135354 9月 9 2020 imap.jar
538484022 -rw-r--r--. 1 root root 8782 9月 9 2020 j2objc-annotations-1.1.jar
538484023 -rwxr-xr-x. 1 root root 1106334 9月 9 2020 jackson-all-1.9.1.jar
538484024 -rw-------. 1 root root 68215 11月 5 2020 jackson-annotations-2.11.3.jar
538484025 -rw-------. 1 root root 351495 11月 5 2020 jackson-core-2.11.3.jar
538484026 -rw-------. 1 root root 1421699 11月 5 2020 jackson-databind-2.11.3.jar
538484027 -rw-r--r--. 1 root root 1616844 10月 9 2023 jackson-databind-2.14.2.jar
538483862 -rw-r--r--. 1 root root 46260 7月 8 05:05 jakarta.json-api-2.0.2.jar
538484028 -rw-r--r--. 1 root root 64477 10月 9 2023 java-jwt-4.4.0.jar
538484029 -rw-r--r--. 1 root root 782774 9月 11 2022 javassist-3.27.0-GA.jar
538484030 -rw-r--r--. 1 root root 65508 9月 9 2020 javatuples-1.2.jar
538484031 -rw-r--r--. 1 root root 867106 9月 10 2021 jedis-3.6.3.jar
538484032 -rw-r--r--. 1 root root 87325 9月 9 2020 jline-0.9.94.jar
538484033 -rwxr-xr-x. 1 root root 10635 9月 9 2020 jmx-util-1.2.3.jar
538484034 -rwxr-xr-x. 1 root root 573912 9月 9 2020 joda-time-2.2.jar
538484035 -rwxr-xr-x. 1 root root 813521 9月 9 2020 js.jar
538484036 -rwxr-xr-x. 1 root root 148490 9月 9 2020 json-lib-2.2.3-jdk15.jar.bak
538793513 -rw-r--r--. 1 root root 159123 4月 22 06:49 json-lib-2.4-jdk15.jar
538484037 -rwxr-xr-x. 1 root root 39308 9月 9 2020 json.org.jar
538484038 -rwxr-xr-x. 1 root root 16046 9月 9 2020 json_simple-1.1.jar
538484039 -rw-r--r--. 1 root root 19936 9月 9 2020 jsr305-3.0.2.jar
538484040 -rwxr-xr-x. 1 root root 121070 9月 9 2020 junit.jar
538484041 -rwxr-xr-x. 1 root root 1204789 9月 9 2020 jython.jar
538484043 -rw-r--r--. 1 root root 5447200 11月 27 2023 kafka_2.13-3.1.0.jar
538484042 -rw-r--r--. 1 root root 4933464 11月 27 2023 kafka-clients-3.1.0.jar
538484044 -rw-r--r--. 1 root root 1509405 10月 9 2023 kotlin-stdlib-1.6.20.jar
538484045 -rw-r--r--. 1 root root 200631 10月 9 2023 kotlin-stdlib-common-1.6.20.jar
538484046 -rw-r--r--. 1 root root 23898 10月 9 2023 kotlin-stdlib-jdk7-1.6.20.jar
538484047 -rw-r--r--. 1 root root 17773 10月 9 2023 kotlin-stdlib-jdk8-1.6.20.jar
538484048 -rw-r--r--. 1 root root 337512 9月 9 2020 kryo-4.0.2.jar
538484049 -rw-r--r--. 1 root root 410874 9月 9 2020 kryo-shaded-4.0.2.jar
538484051 -rw-r--r--. 1 root root 1355626 9月 9 2020 lettuce-core-5.1.8.RELEASE.jar
538484052 -rw-r--r--. 1 root root 7954 1月 10 2023 lf-agent-1.0.jar
271458465 -rw-r--r--. 1 root root 4337121 7月 8 05:05 lf-common-1.0.jar
538484054 -rw-r--r--. 1 root root 217053 9月 9 2020 libthrift-0.9.1.jar
538484055 -rw-r--r--. 1 root root 2199 7月 15 2021 listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
538484056 -rwxr-xr-x. 1 root root 391834 9月 9 2020 log4j-1.2.15.jar
538484057 -rw-r--r--. 1 root root 489884 9月 9 2020 log4j-1.2.17.jar
538484058 -rw-r--r--. 1 root root 264060 10月 9 2023 log4j-api-2.11.1.jar
538484059 -rw-r--r--. 1 root root 290339 9月 9 2020 logback-classic-1.2.3.jar
538484060 -rw-r--r--. 1 root root 471901 9月 9 2020 logback-core-1.2.3.jar
538484061 -rwxr-xr-x. 1 root root 2998 9月 9 2020 logs-backup-app.jar
538484062 -rwxr-xr-x. 1 root root 735977 9月 9 2020 logstash-logback-encoder-4.3.jar
538484063 -rw-r--r--. 1 root root 103059 7月 8 05:05 ls-game-rpc-1.0.6.jar
538484064 -rw-r--r--. 1 root root 1685426 10月 9 2023 lucene-analyzers-common-8.6.2.jar
538484065 -rw-r--r--. 1 root root 151731 10月 9 2023 lucene-backward-codecs-8.6.2.jar
538484066 -rw-r--r--. 1 root root 3491673 10月 9 2023 lucene-core-8.6.2.jar
538484067 -rw-r--r--. 1 root root 98333 10月 9 2023 lucene-grouping-8.6.2.jar
538484068 -rw-r--r--. 1 root root 209890 10月 9 2023 lucene-highlighter-8.6.2.jar
538484069 -rw-r--r--. 1 root root 149145 10月 9 2023 lucene-join-8.6.2.jar
538484070 -rw-r--r--. 1 root root 52132 10月 9 2023 lucene-memory-8.6.2.jar
538484071 -rw-r--r--. 1 root root 99400 10月 9 2023 lucene-misc-8.6.2.jar
538484072 -rw-r--r--. 1 root root 379965 10月 9 2023 lucene-queries-8.6.2.jar
538484073 -rw-r--r--. 1 root root 382443 10月 9 2023 lucene-queryparser-8.6.2.jar
538484074 -rw-r--r--. 1 root root 223507 10月 9 2023 lucene-sandbox-8.6.2.jar
538484076 -rw-r--r--. 1 root root 309344 10月 9 2023 lucene-spatial3d-8.6.2.jar
538484075 -rw-r--r--. 1 root root 240647 10月 9 2023 lucene-spatial-extras-8.6.2.jar
538484077 -rw-r--r--. 1 root root 249856 10月 9 2023 lucene-suggest-8.6.2.jar
538484078 -rwxr-xr-x. 1 root root 178220 9月 9 2020 mailapi.jar
538496292 -rw-r--r--. 1 root root 47275 4月 8 07:01 micrometer-commons-1.12.1.jar
538496293 -rw-r--r--. 1 root root 882379 4月 8 07:01 micrometer-core-1.12.1.jar
538496294 -rw-r--r--. 1 root root 17612 4月 8 07:01 micrometer-jvm-extras-0.2.2.jar
538496295 -rw-r--r--. 1 root root 71748 4月 8 07:01 micrometer-observation-1.12.1.jar
538496296 -rw-r--r--. 1 root root 43654 4月 8 07:01 micrometer-registry-prometheus-1.12.1.jar
538484080 -rwxr-xr-x. 1 root root 38284 4月 8 07:01 microsoft-translator-java-api-0.6.2-jar-with-dependencies.jar
538484081 -rw-r--r--. 1 root root 5711 9月 9 2020 minlog-1.3.0.jar
268967938 -rw-r--r--. 1 root root 590913 7月 8 05:05 mmo-server.jar
538484083 -rw-r--r--. 1 root root 1742200 12月 6 2021 mybatis-3.5.7.jar
538484084 -rw-r--r--. 1 root root 5613 12月 6 2021 mybatis-plus-3.4.3.4.jar
538484085 -rw-r--r--. 1 root root 17406 12月 6 2021 mybatis-plus-annotation-3.4.3.4.jar
538484086 -rw-r--r--. 1 root root 36201 12月 6 2021 mybatis-plus-boot-starter-3.4.3.4.jar
538484087 -rw-r--r--. 1 root root 291428 12月 6 2021 mybatis-plus-core-3.4.3.4.jar
538484088 -rw-r--r--. 1 root root 169367 12月 6 2021 mybatis-plus-extension-3.4.3.4.jar
538484089 -rw-r--r--. 1 root root 195342 12月 6 2021 mybatis-plus-generator-3.5.1.jar
538484090 -rw-r--r--. 1 root root 999016 12月 6 2021 mysql-connector-java-5.1.43.jar_bak
538484091 -rw-r--r--. 1 root root 1006904 7月 18 2022 mysql-connector-java-5.1.49.jar
538484092 -rw-r--r--. 1 root root 4057413 9月 9 2020 netty-all-4.1.38.Final.jar
538484093 -rwxr-xr-x. 1 root root 168359 9月 9 2020 newalicebot.jar
805665035 drwxr-xr-x. 2 root root 249 6月 27 2019 newrelic
538484094 -rwxr-xr-x. 1 root root 15242 9月 9 2020 newrelic-api.jar
538484095 -rw-r--r--. 1 root root 102509 9月 9 2020 nifty-core-0.23.0.jar
538484096 -rw-r--r--. 1 root root 52576 9月 9 2020 objenesis-2.2.jar
538484097 -rw-r--r--. 1 root root 54391 9月 9 2020 objenesis-2.5.1.jar
538484098 -rw-r--r--. 1 root root 344514 1月 29 2021 okhttp-3.4.2.jar
538484099 -rw-r--r--. 1 root root 786969 10月 9 2023 okhttp-4.11.0.jar
538484100 -rw-r--r--. 1 root root 76036 1月 29 2021 okio-1.9.0.jar
538484101 -rw-r--r--. 1 root root 327600 9月 9 2020 opencensus-api-0.19.2.jar
538484102 -rw-r--r--. 1 root root 22978 9月 9 2020 opencensus-contrib-http-util-0.19.2.jar
538483863 -rw-r--r--. 1 root root 137979 7月 8 05:05 opentelemetry-api-1.29.0.jar
538483864 -rw-r--r--. 1 root root 47185 7月 8 05:05 opentelemetry-context-1.29.0.jar
538484103 -rw-r--r--. 1 root root 171372 9月 9 2020 org.eclipse.paho.client.mqttv3-1.0.2.jar
538483865 -rw-r--r--. 1 root root 118767 7月 8 05:05 parsson-1.0.5.jar
538484105 -rwxr-xr-x. 1 root root 41915 9月 9 2020 pingpp-java-2.0.4.jar
538484106 -rwxr-xr-x. 1 root root 1815576 9月 9 2020 plugin.jar
538484107 -rwxr-xr-x. 1 root root 20080 9月 9 2020 pop3.jar
538484108 -rw-r--r--. 1 root root 9781008 6月 12 2023 presto-jdbc-0.280.jar
538484109 -rw-r--r--. 1 root root 1664677 9月 9 2020 protobuf-java-3.10.0.jar
538484110 -rw-r--r--. 1 root root 77777 2月 28 2022 protobuf-java-format-1.2.jar
538484111 -rw-r--r--. 1 root root 54915 9月 9 2020 protostuff-api-1.3.8.jar
538484112 -rw-r--r--. 1 root root 10081 9月 9 2020 protostuff-collectionschema-1.3.8-sources.jar
538484113 -rw-r--r--. 1 root root 63915 9月 9 2020 protostuff-core-1.3.8.jar
538484114 -rw-r--r--. 1 root root 404050 9月 9 2020 protostuff-runtime-1.3.8.jar
538484116 -rw-r--r--. 1 root root 2097 9月 9 2020 reactive-streams-1.0.2.jar
538484117 -rw-r--r--. 1 root root 1478769 9月 9 2020 reactor-core-3.2.11.RELEASE.jar
538484118 -rw-r--r--. 1 root root 20883 9月 9 2020 reflectasm-1.11.3.jar
538484119 -rw-r--r--. 1 root root 130398 11月 27 2023 reflections-0.10.2.jar
538484120 -rwxr-xr-x. 1 root root 8842990 9月 9 2020 scala-library.jar
538496297 -rw-r--r--. 1 root root 90482 4月 8 07:01 simpleclient-0.16.0.jar
538496298 -rw-r--r--. 1 root root 8011 4月 8 07:01 simpleclient_common-0.16.0.jar
538496299 -rw-r--r--. 1 root root 14688 4月 8 07:01 simpleclient_httpserver-0.16.0.jar
538496300 -rw-r--r--. 1 root root 3405 4月 8 07:01 simpleclient_tracer_common-0.16.0.jar
538496302 -rw-r--r--. 1 root root 4338 4月 8 07:01 simpleclient_tracer_otel-0.16.0.jar
538496303 -rw-r--r--. 1 root root 4611 4月 8 07:01 simpleclient_tracer_otel_agent-0.16.0.jar
538484121 -rwxr-xr-x. 1 root root 28688 9月 9 2020 slf4j-api-1.7.6.jar
538484122 -rw-r--r--. 1 root root 12244 9月 9 2020 slf4j-log4j12-1.7.25.jar
538484123 -rwxr-xr-x. 1 root root 23252 9月 9 2020 smtp.jar
538484124 -rw-r--r--. 1 root root 1773124 7月 3 2023 snappy-java-1.1.10.0.jar
538484125 -rw-r--r--. 1 root root 15121 9月 9 2020 spotbugs-annotations-3.1.9.jar
538484126 -rw-r--r--. 1 root root 369054 9月 9 2020 spring-aop-5.1.9.RELEASE.jar
538484127 -rw-r--r--. 1 root root 673959 9月 9 2020 spring-beans-5.1.9.RELEASE.jar
538484128 -rw-r--r--. 1 root root 1102790 9月 9 2020 spring-context-5.1.9.RELEASE.jar
538484129 -rw-r--r--. 1 root root 1293311 9月 9 2020 spring-core-5.1.9.RELEASE.jar
538484130 -rw-r--r--. 1 root root 280854 9月 9 2020 spring-expression-5.1.9.RELEASE.jar
538484131 -rw-r--r--. 1 root root 1324225 9月 9 2020 spring-integration-core-5.1.7.RELEASE.jar
538484132 -rw-r--r--. 1 root root 23761 9月 9 2020 spring-jcl-5.1.9.RELEASE.jar
538484133 -rwxr-xr-x. 1 root root 428320 9月 9 2020 spring-jdbc-4.1.1.RELEASE.jar
538484134 -rw-r--r--. 1 root root 383581 9月 9 2020 spring-messaging-5.1.9.RELEASE.jar
538484135 -rw-r--r--. 1 root root 129174 9月 9 2020 spring-retry-1.2.4.RELEASE.jar
538484136 -rw-r--r--. 1 root root 256433 9月 9 2020 spring-tx-5.1.9.RELEASE.jar
538484137 -rwxr-xr-x. 1 root root 21506 9月 9 2020 terracotta-api-1.1.1.jar
538484138 -rwxr-xr-x. 1 root root 15256650 9月 9 2020 tools.jar
538484139 -rw-r--r--. 1 root root 900516 7月 27 2023 vavr-0.10.4.jar
538484140 -rw-r--r--. 1 root root 149395 9月 9 2020 warz-remote-1.0.0.jar
538484141 -rwxr-xr-x. 1 root root 973548 9月 9 2020 ws-engine.jar
538484143 -rw-r--r--. 1 root root 109318 9月 9 2020 xml-apis-1.0.b2.jar
538484144 -rwxr-xr-x. 1 root root 24956 9月 9 2020 xpp3_min-1.1.4c.jar
538484145 -rwxr-xr-x. 1 root root 431406 9月 9 2020 xstream-1.3.1.jar
538484146 -rw-r--r--. 1 root root 911603 9月 9 2020 zookeeper-3.4.14.jar.bak
538793514 -rw-r--r--. 1 root root 1254153 4月 22 06:49 zookeeper-3.6.3.jar
538793515 -rw-r--r--. 1 root root 250399 4月 22 06:49 zookeeper-jute-3.6.3.jar
538793515 -rw-r--r--. 1 root root 250399 4月 22 06:49 zookeeper-jute-3.6.3.jar
可以看出线上按照这个inode顺序,jackson-databind是会优先加载低版本的,更糟糕的是这个inode值是操作系统决定的,macos和linux都有这个概念,windows不清楚.所以这也能解释为什么内网服只有个别会报这种异常,
解决方案
笔者将生产环境的几个服务的inode值都拉了下来比对了一下,确认了生产环境都是优先加载低版本jar包,然后针对高版本jar包直接手动排除掉.并在内网继续进行测试,至此因为inode导致的jar包加载顺序问题得到根本解决.后续出现的其他依赖问题都是同一个问题,针对这些jar包按照同样的思路处理
问题总结
- 虽然linux用了很久,但是对其文件系统方面的内容还是不够熟悉,工作5年竟然一直错误的认为读取目录文件是按照文件名字典序
- 良好的异常监控机制和灰度测试是兜底的最后一道门槛, 这次的升级在老服可能不会暴露问题,但是后续开新服可能会炸服,对游戏导量产生较严重的影响 多亏了同事搭建的日志监控推送组件,在测试环节就暴露了问题
参考连接: