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

RAISE on zbx_drop_old_partitions #2

Open
melodous opened this issue Jul 19, 2017 · 5 comments
Open

RAISE on zbx_drop_old_partitions #2

melodous opened this issue Jul 19, 2017 · 5 comments

Comments

@melodous
Copy link

Hi Ryan,

First of all sorry if I'm bothering you and thanks for share these scripts :)

I have a problem with them and maybe you can give me a hand with a doubt. They work really well, but It fail in my environment dropping the old tables. This is an example of the execution, adding some debugging output.

zabbix-server=> SELECT zbx_drop_old_partitions('history_log', '2017-07-15'::TIMESTAMP);
NOTICE:  Current now: 2017-07-19 20:36:04.070907+02 - childbond: 2017-07-15 00:00:00 - cutoff: 2017-07-15 00:00:00+02 - relname history_log_2017_07_14
NOTICE:  Dropped partition: partitions.history_log_2017_07_14
NOTICE:  Current now: 2017-07-19 20:36:04.070907+02 - childbond: 2017-07-16 00:00:00 - cutoff: 2017-07-15 00:00:00+02 - relname history_log_2017_07_15
NOTICE:  Current now: 2017-07-19 20:36:04.070907+02 - childbond: 2017-07-17 00:00:00 - cutoff: 2017-07-15 00:00:00+02 - relname history_log_2017_07_16
NOTICE:  Current now: 2017-07-19 20:36:04.070907+02 - childbond: 2017-07-18 00:00:00 - cutoff: 2017-07-15 00:00:00+02 - relname history_log_2017_07_17
NOTICE:  Current now: 2017-07-19 20:36:04.070907+02 - childbond: 2017-07-19 00:00:00 - cutoff: 2017-07-15 00:00:00+02 - relname history_log_2017_07_18
NOTICE:  Current now: 2017-07-19 20:36:04.070907+02 - childbond: 2017-07-20 00:00:00 - cutoff: 2017-07-15 00:00:00+02 - relname history_log_2017_07_19
ERROR:  Current timestamp is earlier than upper bound for partition partitions.history_log_2017_07_19
CONTEXT:  función PL/pgSQL zbx_drop_old_partitions(text,timestamp with time zone,text) en la línea 34 en RAISE

It work correctly but when it go through the last table and execute the code to protect the current partition, It raise an error and I think that make a rollback, so doesn't drop any table. If I drop this part of code it works, but I’m really asking my self why this code doesn’t works in my environment but it does for yours.

-- protect current partition
IF NOW() < child_bound THEN
      RAISE 'Current timestamp is earlier than upper bound for partition %.%', child.child_nspname, child.child_relname;
END IF;

Thanks in advance.

@alexmirtoff
Copy link

Change RAISE to RAISE NOTICE.

cavaliercoder added a commit that referenced this issue Aug 5, 2017
The `zbx_drop_old_partitions` function was failing as the current
partition would always be evaulated, was seen to expire in the
future and would cause an exception to be raised. This logic is now
only executed if the partion is actually scehduled for deletion.
@cavaliercoder
Copy link
Collaborator

Can you please try the fix in #3 in non-production? I don't have access to a test environment at the moment.

@ComBin
Copy link

ComBin commented Jul 31, 2018

@cavaliercoder, hello! Why this fix is still no in master?

@cavaliercoder
Copy link
Collaborator

No-one has validated the fix in #3. I no longer have the means to test changes to this package and rely on feedback from users.

@ComBin
Copy link

ComBin commented Jul 31, 2018

I tested it. #3 is fix this issue. The old parts are deleted. But i did not test case when current partitions fell into the specified range.

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

No branches or pull requests

4 participants