Skip to content

Wrong result after drop partition (gap) #117

Closed
@killua001

Description

@killua001

step

1. create a range partition table with 5 min interval. Then fill data into the table.

CREATE TABLE journal (
id SERIAL,
dt TIMESTAMP NOT NULL,
level INTEGER,
msg TEXT);

SELECT create_range_partitions('journal', 'dt', '2017-01-01'::timestamp, '5 min'::interval, 1000);

INSERT INTO journal (dt, level, msg)
SELECT g, random() * 6, md5(g::text)
FROM generate_series('2017-01-01'::timestamp, '2017-01-5'::timestamp, '2 second') as g;

2. drop some partitions for a day's begining

[postgres@cnsz033302:5433/k1 M] [08-28.19:22:37]=# select drop_range_partition('journal_577',true);
 drop_range_partition 
----------------------
 journal_577
(1 row)

Time: 23.144 ms
[postgres@cnsz033302:5433/k1 M] [08-28.19:22:50]=# select drop_range_partition('journal_578',true);
 drop_range_partition 
----------------------
 journal_578
(1 row)

Time: 24.799 ms
[postgres@cnsz033302:5433/k1 M] [08-28.19:22:59]=# select drop_range_partition('journal_579',true);
 drop_range_partition 
----------------------
 journal_579
(1 row)

Time: 18.375 ms

3. wrong result when filter condition contains the droped time range

[postgres@cnsz033302:5433/k1 M] [08-28.19:23:06]=# select count(*) from journal where dt > '2017-01-03'::timestamp;
 count 
-------
     0
(1 row)

Time: 21.987 ms

[postgres@cnsz033302:5433/k1 M] [08-28.19:31:59]=# select count(*) from journal where dt < '2017-01-03 00:05:00'::timestamp;
 count 
-------
     0
(1 row)

Time: 0.535 ms

4. correct result

[postgres@cnsz033302:5433/k1 M] [08-28.19:23:47]=# select count(*) from journal where dt > '2017-01-04'::timestamp;
 count 
-------
 43200
(1 row)

Time: 23.115 ms
[postgres@cnsz033302:5433/k1 M] [08-28.19:23:53]=# select count(*) from journal where dt < '2017-01-03'::timestamp;
 count 
-------
 86400
(1 row)

Time: 47.868 ms
[postgres@cnsz033302:5433/k1 M] [08-28.19:31:43]=# select count(*) from journal where dt < '2017-01-03 05:00'::timestamp;
 count 
-------
 94950
(1 row)

Time: 35.960 ms

Activity

killua001

killua001 commented on Aug 28, 2017

@killua001
Author

partition's min & max value:
journal | journal_576 | 2 | dt | 2017-01-02 23:55:00 | 2017-01-03 00:00:00
journal | journal_577 | 2 | dt | 2017-01-03 00:00:00 | 2017-01-03 00:05:00
journal | journal_578 | 2 | dt | 2017-01-03 00:05:00 | 2017-01-03 00:10:00
journal | journal_579 | 2 | dt | 2017-01-03 00:10:00 | 2017-01-03 00:15:00

journal | journal_580 | 2 | dt | 2017-01-03 00:15:00 | 2017-01-03 00:20:00
journal | journal_581 | 2 | dt | 2017-01-03 00:20:00 | 2017-01-03 00:25:00

changed the title [-]Wrong result after drop partition[/-] [+]Wrong result after drop partition (gap)[/+] on Aug 28, 2017
funbringer

funbringer commented on Aug 28, 2017

@funbringer
Collaborator

Hi @killua001,

thank you for the bug report! We're working on a solution.

funbringer

funbringer commented on Aug 29, 2017

@funbringer
Collaborator

Could you try master_hotfix_issue_117 branch? It looks like everything works fine now:

set pg_pathman.enable = on;
select count(*) from journal where dt > '2017-01-03'::timestamp;
 count
-------
 85951
(1 row)

set pg_pathman.enable = off;
select count(*) from journal where dt > '2017-01-03'::timestamp;
 count
-------
 85951
(1 row)

set pg_pathman.enable = on;
select count(*) from journal where dt < '2017-01-03 00:05:00'::timestamp;
 count
-------
 86400
(1 row)

set pg_pathman.enable = off;
select count(*) from journal where dt < '2017-01-03 00:05:00'::timestamp;
 count
-------
 86400
(1 row)
added this to the Release 1.4.4 milestone on Aug 29, 2017
killua001

killua001 commented on Aug 30, 2017

@killua001
Author

@funbringer
Thank you。
And when the1.4.4 release?

funbringer

funbringer commented on Aug 30, 2017

@funbringer
Collaborator

And when the1.4.4 release?

This week, I suppose.

funbringer

funbringer commented on Aug 31, 2017

@funbringer
Collaborator

Released 1.4.4.

killua001

killua001 commented on Sep 1, 2017

@killua001
Author

Great work!
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @killua001@funbringer

        Issue actions

          Wrong result after drop partition (gap) · Issue #117 · postgrespro/pg_pathman