4.2.10升级到4.3.1后订阅就断开连接

问题描述

4.2.10升级到4.3.1后不能订阅,使用了内置ACL(版本升级后查看过/etc/emqx/acl.conf,配置正常),升级前可以正常订阅,升级后只要一订阅就会断开连接。

MQTTX v1.5.4 测试,订阅acl允许的主题会断开连接,订阅acl拒绝的主题会正常提示testtopic/#订阅失败 错误的QoS,SubACK失败, 请检查MQTT broker设置

更新后变更过emqx_auth_username认证到emqx_auth_mnesia认证

环境信息

  • EMQ X 版本:4.3.1
  • 操作系统及版本:Ubuntu20.4
  • 其他

相应的配置文件内容

# etc/emqx.conf

## Allow anonymous authentication by default if no auth plugins loaded.
## Notice: Disable the option in production deployment!
##
## Value: true | false
allow_anonymous = false

## Allow or deny if no ACL rules matched.
##
## Value: allow | deny
acl_nomatch = deny

其它配置项未做变更

详细日志

(emqx@127.0.0.1)1> 2021-05-18T09:14:11.300658+08:00 [error] xpcmanage@xxx.xxx.xxx.xxx:62601 crasher: initial call: emqx_connection:init/4, pid: <0.2103.0>, registered_name: [], error: {{badmatch,{error,{bad_type,{emqx_trie,{<<"testtopic/#">>,1},1}}}},[{emqx_session,subscribe,4,[{file,"emqx_session.erl"},{line,248}]},{emqx_channel,do_subscribe,3,[{file,"emqx_channel.erl"},{line,656}]},{emqx_channel,process_subscribe,4,[{file,"emqx_channel.erl"},{line,641}]},{emqx_channel,handle_in,2,[{file,"emqx_channel.erl"},{line,633}]},{emqx_connection,with_channel,3,[{file,"emqx_connection.erl"},{line,617}]},{emqx_connection,process_msg,2,[{file,"emqx_connection.erl"},{line,325}]},{emqx_connection,process_msg,2,[{file,"emqx_connection.erl"},{line,331}]},{emqx_connection,handle_recv,3,[{file,"emqx_connection.erl"},{line,290}]},{proc_lib,wake_up,3,[{file,"proc_lib.erl"},{line,236}]}]}, ancestors: [<0.1803.0>,<0.1802.0>,esockd_sup,<0.1553.0>], message_queue_len: 0, messages: [], links: [<0.1803.0>], dictionary: [{guid,{1621300448360102,268564305020983,0}},{'$logger_metadata$',#{clientid => "xpcmanage",peername => "xxx.xxx.xxx.xxx:62601"}},{incoming_bytes,93},{recv_pkt,2},{acl_keys_q,{[{subscribe,<<"testtopic/#">>}],[]}},{send_pkt,1},{acl_cache_size,1},{outgoing_bytes,4},{{subscribe,<<"testtopic/#">>},{allow,1621300451299}}], trap_exit: false, status: running, heap_size: 4185, stack_size: 28, reductions: 4331; neighbours:
2021-05-18T09:14:11.301819+08:00 [error] supervisor: 'esockd_connection_sup - <0.1803.0>', errorContext: connection_crashed, reason: {{badmatch,{error,{bad_type,{emqx_trie,{<<"testtopic/#">>,1},1}}}},[{emqx_session,subscribe,4,[{file,"emqx_session.erl"},{line,248}]},{emqx_channel,do_subscribe,3,[{file,"emqx_channel.erl"},{line,656}]},{emqx_channel,process_subscribe,4,[{file,"emqx_channel.erl"},{line,641}]},{emqx_channel,handle_in,2,[{file,"emqx_channel.erl"},{line,633}]},{emqx_connection,with_channel,3,[{file,"emqx_connection.erl"},{line,617}]},{emqx_connection,process_msg,2,[{file,"emqx_connection.erl"},{line,325}]},{emqx_connection,process_msg,2,[{file,"emqx_connection.erl"},{line,331}]},{emqx_connection,handle_recv,3,[{file,"emqx_connection.erl"},{line,290}]},{proc_lib,wake_up,3,[{file,"proc_lib.erl"},{line,236}]}]}, offender: [{pid,<0.2103.0>},{name,connection},{mfargs,{emqx_connection,start_link,[[{deflate_options,[]},{max_conn_rate,1000},{active_n,100},{zone,external},{proxy_address_header,<<>>},{proxy_port_header,<<>>},{supported_subprotocols,[]}]]}}]

看起来是触发了个bug?稍等我看看

:ok_hand:
目前

apt purge emqx
apt install emqx

重装后已恢复正常。配置是复制后覆盖的,相当于同配置。

是的 刚才我们在讨论这个问题,因为升级后内存表结构不兼容导致这个问题的。后面会出个升级指南文档来避免坑

升级指南有跟进木~

  • 4.3 版本不兼容 4.2 的 Mnesia 数据文件,无法启动新版本,可以借助导入导出功能进行升级:
    • 使用导入导出功能,导出最新数据并将导出的数据下载备份
    • 将集群中所有节点停机,删除 data/mnesia 目录下的文件以清空数据库
    • 升级到 4.3 版本
    • 启动新版本 EMQ X,使用导入导出功能导入备份的数据,完成数据恢复

升级过程中请妥善备份相关目录和数据文件。