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

[Bug]: select count() 有概率出现预期之外的结果 #1952

Open
r33s3n6 opened this issue May 7, 2024 · 1 comment
Open

[Bug]: select count() 有概率出现预期之外的结果 #1952

r33s3n6 opened this issue May 7, 2024 · 1 comment
Labels
status: confirmed bug or feature request is confirmed type: bug Something isn't working

Comments

@r33s3n6
Copy link
Contributor

r33s3n6 commented May 7, 2024

Describe the bug
master分支版本,select count() 返回了预期之外的数值

Fast Reproduce Steps(Required)
先执行init.sql建表,随后执行error.sql,出现预期之外的结果。
init.sql.txt
error.sql.txt

这个问题非常难以复现,但我尝试复现了多次,流程如下:

  1. 执行init.sql和error.sql,记录下初始输出(一般是正确的)
  2. 重新建库,执行init.sql
  3. 执行16次error.sql,检测结果是否有区别
  4. 每隔1秒执行1次error.sql,检测结果是否有区别
  5. 回到2

建议编写自动脚本执行上述复现流程。
以上述流程复现,通常会在10余次重新建库后得到错误结果,在不清除数据库状态的情况下,此后可以稳定复现(可能是缓存),但经过一段时间后会回归正常状态。

Expected behavior
OB的单节点版本和多节点版本都有概率出现预期之外的结果。
正确结果应该是一共220行的 319

mysql> select sum(case when c_vj1hci is null then 1 else 0 end), count(c_vj1hci) from t_vm5;
+---------------------------------------------------+-----------------+
| sum(case when c_vj1hci is null then 1 else 0 end) | count(c_vj1hci) |
+---------------------------------------------------+-----------------+
|                                               477 |             319 |
+---------------------------------------------------+-----------------+
1 row in set (0.00 sec)

Actual Behavior
但偶尔会出现一共220行的751

Environment

Linux c0bae494cabb 6.5.0-18-generic #18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 11:40:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

commit 7ead2595472f666ae677b2a820aef3bfe40ffcb0 (HEAD -> master, origin/master)

observer (OceanBase_CE 4.3.1.0)

REVISION: 1-7ead2595472f666ae677b2a820aef3bfe40ffcb0
BUILD_BRANCH: master
BUILD_TIME: Apr 29 2024 21:37:35
BUILD_FLAGS: RelWithDebInfo
BUILD_INFO: 

Copyright (c) 2011-present OceanBase Inc.

部署配置文件

user:
  username: root
  key_file: private_key
oceanbase-ce:
  servers:
    - name: server1
      ip: 10.0.10.11
    - name: server2
      ip: 10.0.10.12
    - name: server3
      ip: 10.0.10.13
  server1:
    mysql_port: 10000
    rpc_port: 10001
    home_path: /root/data/observer1
    zone: zone1
  server2:
    mysql_port: 10000
    rpc_port: 10001
    home_path: /root/data/observer2
    zone: zone2
  server3:
    mysql_port: 10000
    rpc_port: 10001
    home_path: /root/data/observer3
    zone: zone3
  tag: latest
  include: obd/observer.include.yaml
  global: 
    # for default system config used by farm, please see tools/deploy/obd/observer.include.yaml
    # You can also specify the configuration directly below (stored locally, switching the working directory and redeploying will still take effect)
    production_mode: false
    devname: eth0
    syslog_level: 'WARN'
    syslog_io_bandwidth_limit: '30M'
    log_disk_size: '30G'
    # diag_syslog_per_error_limit: '4'
    max_syslog_file_count: '4'
    cpu_count: '6'
    datafile_size: '10G'
    datafile_next: '5G'
    datafile_maxsize: '30G'
    root_password: ''
    memory_limit: '9G'
    system_memory: '1G'
obproxy-ce:
  servers:
    - 10.0.10.8
  global:
    listen_port: 10004
    prometheus_listen_port: 10005
    syslog_level: 'WARN'
    home_path: /root/data/obproxy
    root_password: ''
  include: obd/obproxy.include.yaml
  depends:
    - oceanbase-ce

租户配置:

DROP TENANT mysql FORCE;
DROP RESOURCE POOL pool_for_tenant_mysql;

CREATE RESOURCE UNIT 4c7g MAX_CPU 4, MIN_CPU 4, MEMORY_SIZE '7G';
create resource pool pool_test unit='4c7g', unit_num=1, zone_list=('zone1' ,'zone2', 'zone3');
create tenant test resource_pool_list=('pool_test'), primary_zone='RANDOM',comment 'test tenant', charset='utf8' set ob_tcp_invited_nodes='%', recyclebin=OFF, ob_query_timeout=5000000;

Additional Context
我们是来自北京航空航天大学网络空间安全学院的BASS团队,主要从事系统软件安全、操作系统和程序分析研究,研发自动化程序测试框架检测软件缺陷。我们使用自研的数据库漏洞测试工具在OceanBase中找到了上述可能的漏洞。

@r33s3n6 r33s3n6 added the type: bug Something isn't working label May 7, 2024
@hnwyllmm
Copy link
Contributor

hnwyllmm commented May 7, 2024

收到,我们尝试复现一下。

@hnwyllmm hnwyllmm added the status: confirmed bug or feature request is confirmed label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed bug or feature request is confirmed type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants