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

Count with tag filter returns the unfiltered number of rows #4692

Closed
akhilman opened this issue Sep 6, 2024 · 5 comments · Fixed by #4694
Closed

Count with tag filter returns the unfiltered number of rows #4692

akhilman opened this issue Sep 6, 2024 · 5 comments · Fixed by #4694
Labels
C-bug Category Bugs

Comments

@akhilman
Copy link

akhilman commented Sep 6, 2024

What type of bug is this?

Incorrect result

What subsystems are affected?

Standalone mode

Minimal reproduce step

drop table if exists count_where_bug;
create table count_where_bug (
    tag String,
    ts TimestampMillisecond time index,
    num Int64,
    primary key (tag),
) engine=mito with('append_mode'='true');

insert into count_where_bug (tag, ts, num)
values  ('a', '2024-09-06T06:00:01Z', 1),
        ('a', '2024-09-06T06:00:02Z', 2),
        ('a', '2024-09-06T06:00:03Z', 3),
        ('b', '2024-09-06T06:00:04Z', 4),
        ('b', '2024-09-06T06:00:05Z', 5);

select count(1) from count_where_bug where tag = 'b';

What did you expect to see?

I expect to get 2 as result.

What did you see instead?

But I am getting total number of rows - 5.

What operating system did you use?

ArchLinux x64

What version of GreptimeDB did you use?

0.9.2 from docker.io

Relevant log output and stack trace

2024-09-06T13:32:32.355432Z  INFO LocalManager::submit_root_procedure: common_procedure::local::runner: Runner metasrv-procedure::DropTable-5e18069e-21d2-47ba-b186-257e7f20887e starts
2024-09-06T13:32:32.355587Z  INFO LocalManager::submit_root_procedure: common_meta::ddl::drop_table: Deleted table metadata for table 1083
2024-09-06T13:32:32.355732Z  INFO mito2::worker::handle_drop: Try to drop region: 4651449581568(1083, 0), worker: 3
2024-09-06T13:32:32.360541Z  INFO mito2::region: Stopped region manifest manager, region_id: 4651449581568(1083, 0)
2024-09-06T13:32:32.360602Z  INFO log_store::raft_engine::log_store: Namespace 4651449581568 obsoleted 1 entries, compacted index: 1, span: (None, None)
2024-09-06T13:32:32.360633Z  INFO mito2::worker::handle_drop: Region 4651449581568(1083, 0) is dropped logically, but some files are not deleted yet
2024-09-06T13:32:32.360678Z  INFO LocalManager::submit_root_procedure:RegionInvoker::handle_region_request:RegionServer::handle_region_request{region_id="4651449581568(1083, 0)"}:handle_request{request_type="Drop"}: datanode::region_server: Region 4651449581568(1083, 0) is deregistered from engine mito
2024-09-06T13:32:32.360808Z  INFO LocalManager::submit_root_procedure: common_procedure::local::runner: Procedure metasrv-procedure::DropTable-5e18069e-21d2-47ba-b186-257e7f20887e done
2024-09-06T13:32:32.360880Z  INFO LocalManager::submit_root_procedure: common_procedure::local::runner: Runner metasrv-procedure::DropTable-5e18069e-21d2-47ba-b186-257e7f20887e exits
2024-09-06T13:32:32.360912Z  INFO on_query{protocol="mysql"}:mysql::do_query:do_query:execute_stmt:drop_tables:DdlManager::submit_ddl_task: common_meta::ddl_manager: Table: 1083 is dropped via procedure_id ProcedureId(5e18069e-21d2-47ba-b186-257e7f20887e)
2024-09-06T13:32:32.361322Z  INFO LocalManager::submit_root_procedure: common_procedure::local::runner: Runner metasrv-procedure::CreateTable-965e4502-5989-4e82-901e-aa9cf6f10bf7 starts
2024-09-06T13:32:32.361584Z  INFO mito2::manifest::manager: Checkpoint not found in data/greptime/public/1084/1084_0000000000/manifest/, build manifest from scratch
2024-09-06T13:32:32.361664Z  INFO mito2::manifest::manager: Creating region manifest in data/greptime/public/1084/1084_0000000000/manifest/ with metadata RegionMetadata { column_metadatas: [[tag String null Tag 0], [ts TimestampMillisecond not null time_index metadata={"greptime:time_index": "true"} Timestamp 1], [num Int64 null Field 2]], time_index: 1, primary_key: [0], region_id: 4655744548864(1084, 0), schema_version: 0 }
2024-09-06T13:32:32.367128Z  INFO mito2::worker::handle_create: A new region created, worker: 0, region: RegionMetadata { column_metadatas: [[tag String null Tag 0], [ts TimestampMillisecond not null time_index metadata={"greptime:time_index": "true"} Timestamp 1], [num Int64 null Field 2]], time_index: 1, primary_key: [0], region_id: 4655744548864(1084, 0), schema_version: 0 }
2024-09-06T13:32:32.367195Z  INFO LocalManager::submit_root_procedure:RegionInvoker::handle_region_request:RegionServer::handle_region_request{region_id="4655744548864(1084, 0)"}:handle_request{request_type="Create"}: datanode::region_server: Region 4655744548864(1084, 0) is registered to engine mito
2024-09-06T13:32:32.367364Z  INFO LocalManager::submit_root_procedure: common_meta::ddl::create_table: Created table metadata for table 1084
2024-09-06T13:32:32.367389Z  INFO LocalManager::submit_root_procedure: common_procedure::local::runner: Procedure metasrv-procedure::CreateTable-965e4502-5989-4e82-901e-aa9cf6f10bf7 done
2024-09-06T13:32:32.367442Z  INFO LocalManager::submit_root_procedure: common_procedure::local::runner: Runner metasrv-procedure::CreateTable-965e4502-5989-4e82-901e-aa9cf6f10bf7 exits
2024-09-06T13:32:32.367479Z  INFO on_query{protocol="mysql"}:mysql::do_query:do_query:execute_stmt:create_table:create_table_inner:DdlManager::submit_ddl_task: common_meta::ddl_manager: Table: 1084 is created via procedure_id ProcedureId(965e4502-5989-4e82-901e-aa9cf6f10bf7)
2024-09-06T13:32:32.367497Z  INFO on_query{protocol="mysql"}:mysql::do_query:do_query:execute_stmt:create_table:create_table_inner: operator::statement::ddl: Successfully created table 'greptime.public.count_where_bug' with table id 1084
.
@akhilman akhilman added the C-bug Category Bugs label Sep 6, 2024
@akhilman akhilman changed the title Count with tag filter returns untiltered row count Count with tag filter returns the unfiltered number of rows Sep 6, 2024
@v0y4g3r
Copy link
Contributor

v0y4g3r commented Sep 6, 2024

This issue may be related to #4668 , please try v0.9.3

@akhilman
Copy link
Author

akhilman commented Sep 6, 2024

Issue still present in v0.9.3 from docker.io

@evenyag
Copy link
Contributor

evenyag commented Sep 6, 2024

This is a regression after #4545 and #4564. It should affect the latest version.

@evenyag
Copy link
Contributor

evenyag commented Sep 6, 2024

We'll fix it and release the next version as soon as possible. Thanks for reporting this issue! We need to add a sqlness for this case.

It should only affect count() under append-only table.

@evenyag
Copy link
Contributor

evenyag commented Sep 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants