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

query count(*) failed #9472

Closed
giant-panda666 opened this issue Sep 25, 2024 · 11 comments · Fixed by #9483
Closed

query count(*) failed #9472

giant-panda666 opened this issue Sep 25, 2024 · 11 comments · Fixed by #9483
Assignees
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/storage severity/major type/bug The issue is confirmed as a bug.

Comments

@giant-panda666
Copy link

giant-panda666 commented Sep 25, 2024

A table stored in TiFlash, using this query sometimes works, sometimes not.
image
image

@giant-panda666 giant-panda666 added the type/bug The issue is confirmed as a bug. label Sep 25, 2024
@JaySon-Huang
Copy link
Contributor

Hi @giant-panda666, thank you for pointing out that such an issue exists. Can you provide more information? For example:

  • the tidb cluster version
  • the related error message contains check failure logging in tiflash.log

@giant-panda666
Copy link
Author

giant-panda666 commented Sep 27, 2024

  1. tidb cluster version is v7.5.2 deployed by tidb operator on k8s.
  2. logs.txt

@Lloyd-Pottiger
Copy link
Contributor

@giant-panda666 The following is a workaround:

set tidb_opt_enable_late_materialization = off; <query>; set tidb_opt_enable_late_materialization = on;

Could you please provide the table schema?

@giant-panda666
Copy link
Author

giant-panda666 commented Sep 27, 2024

@giant-panda666 The following is a workaround:

set tidb_opt_enable_late_materialization = off; <query>; set tidb_opt_enable_late_materialization = on;

Could you please provide the table schema?

The table structure contains sensitive data. Can I obfuscate the field names and enum values before providing them? For example, I can rename the ‘price’ field to ‘a’. Also, could you explain why disabling tidb_opt_enable_late_materialization can temporarily resolve this issue?

@Lloyd-Pottiger
Copy link
Contributor

The table structure contains sensitive data. Can I obfuscate the field names and enum values before providing them? For example, I can rename the ‘price’ field to ‘a’.

Yes.

Also, could you explain why disabling tidb_opt_enable_late_materialization can temporarily resolve this issue?

Only late materialization will call hstackBlocks.

@Lloyd-Pottiger Lloyd-Pottiger self-assigned this Sep 27, 2024
@giant-panda666
Copy link
Author

The table structure contains sensitive data. Can I obfuscate the field names and enum values before providing them? For example, I can rename the ‘price’ field to ‘a’.

Yes.

CREATE TABLE separate_order (
id bigint(20) unsigned NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
c0 enum('DEFAULT','E1','E2','E3','E4','E5','E6') NOT NULL DEFAULT 'DEFAULT',
c1 bigint(20) unsigned NOT NULL DEFAULT '0' ,
c2 tinyint(4) NOT NULL DEFAULT '0',
c3 bigint(20) unsigned NOT NULL DEFAULT '0',
c4 bigint(20) unsigned NOT NULL DEFAULT '0',
c5 enum('DEFAULT','E1','E2','E3','E4','E5','E6','E6') NOT NULL DEFAULT 'DEFAULT',
c6 bigint(20) unsigned NOT NULL DEFAULT '0',
c7 varchar(512) NOT NULL DEFAULT '',
c8 varchar(512) NOT NULL DEFAULT '',
c9 enum('DEFAULT','E1','E2','E3','E4','E5','E6','E7','E8','E9') NOT NULL DEFAULT 'DEFAULT',
c10 bigint(20) unsigned NOT NULL DEFAULT '0',
c11 enum('DEFAULT','BALANCE','WX_MCH','GLOBAL_DEPOSIT_ACCOUNT') NOT NULL DEFAULT 'DEFAULT',
c12 timestamp NULL DEFAULT NULL,
c13 bigint(20) unsigned NOT NULL DEFAULT '0',
c14 timestamp NULL DEFAULT NULL ,
c15 decimal(20,4) NOT NULL DEFAULT '0.0000',
c16 decimal(20,4) NOT NULL DEFAULT '0.0000',
c17 decimal(20,4) NOT NULL DEFAULT '0.0000',
c18 enum('E0','E1','E2','E3','E4','E5','E6','E7','E8') NOT NULL DEFAULT 'E0',
c19 int(11) NOT NULL DEFAULT '0',
c20 varchar(1024) NOT NULL DEFAULT '',
c21 varchar(256) NOT NULL DEFAULT '',
c22 smallint(5) unsigned NOT NULL DEFAULT '0',
c23 bigint(20) unsigned NOT NULL DEFAULT '0',
c24 bigint(20) unsigned NOT NULL DEFAULT '0',
c25 bigint(20) unsigned NOT NULL DEFAULT '0',
c26 enum('DEFAULT','E1','E2') NOT NULL DEFAULT 'DEFAULT',
c27 enum('DEFAULT','E1','E2') NOT NULL DEFAULT 'DEFAULT',
c28 enum('DEFAULT','E1','E2') NOT NULL DEFAULT 'DEFAULT',
c29 enum('DEFAULT','E1','E2') NOT NULL DEFAULT 'DEFAULT',
PRIMARY KEY (id) /*T![clustered_index] NONCLUSTERED */,
KEY idx_c1 (c1),
KEY idx_c10 (c10),
KEY idx_c13 (c13),
KEY idx_created_at (created_at),
KEY idx_updated_at (updated_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

@Lloyd-Pottiger
Copy link
Contributor

@giant-panda666 Thanks, you may also need to transform the query.

@giant-panda666
Copy link
Author

@giant-panda666 Thanks, you may also need to transform the query.

SELECT COUNT(*) FROM separate_order WHERE c18 = "E7" AND c5 = "E4" AND c9 = "E5" AND c12 IS NULL AND updated_at > date_add(curdate(), INTERVAL - 2 day);

@giant-panda666
Copy link
Author

So updating to v7.5.3 will be ok?

@Lloyd-Pottiger
Copy link
Contributor

So updating to v7.5.3 will be ok?

Sorry, I made a mistake, I am still working on it.

@giant-panda666
Copy link
Author

It's ok, looking forward to the next version release. Thank you!

ti-chi-bot bot pushed a commit that referenced this issue Sep 29, 2024
…-empty column in the block (#9483)

ref #9472

storage: fix block rows not match when the filter column is the first non-empty column in the block

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

Co-authored-by: JaySon <tshent@qq.com>
ti-chi-bot bot pushed a commit that referenced this issue Sep 29, 2024
…-empty column in the block (#9484)

ref #9472

storage: fix block rows not match when filter column is the first non-empty column in the block

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

Co-authored-by: JaySon <tshent@qq.com>
ti-chi-bot bot pushed a commit that referenced this issue Sep 30, 2024
…-empty column in the block (#9483) (#9493)

ref #9472

storage: fix block rows not match when the filter column is the first non-empty column in the block

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

Co-authored-by: Lloyd-Pottiger <60744015+Lloyd-Pottiger@users.noreply.github.com>
Co-authored-by: Lloyd-Pottiger <yan1579196623@gmail.com>
ti-chi-bot bot pushed a commit that referenced this issue Oct 8, 2024
…-empty column in the block (#9483) (#9495)

ref #9472

storage: fix block rows not match when the filter column is the first non-empty column in the block

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

Co-authored-by: Lloyd-Pottiger <60744015+Lloyd-Pottiger@users.noreply.github.com>
Co-authored-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/storage severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
3 participants