Closed annlund closed 1 year ago
Hi Annika!
Thank you for your report. It should never insert a new value for system_identifier because the identifier doesn't change for a cluster. Maybe system identifier can change during your restore operation.. However pg_profile must check this and the error message should say that identifier is changed. Anyway right now it seems like a bug. Can you check if the system identifier of your development database gets changed during restore? Use the this query to check it:
select system_identifier from pg_control_system()
Please run it before restore procedure and right after it. Check if the values are the same.
Hi!
Yes, you are right, the system identifier changes when I delete and restore the db.
Do you think there are any workarounds, other than changing the restoration procedure so that the system identifier doesn't change?
Thanks for the support!
Hi Annika!
This bug will be fixed in the next release - the error message will point directly to system_identifier change.
This behavior of pg_profile is necessary because pg_profile is able to collect samples from remote servers. Due to changes in configuration of DHCP or DNS services (or something else) it is possible that old connection string is pointing to the different cluster now. In such cases we can't continue statistics collection and we should throw an exception. This is checked during take_sample execution (and here is a bug in 4.1) and there is a constraint on pg_profile tables for sure - you've bumped in it.
You can add recreation of pg_profile remote server to your restore procedure. If you want to save previous samples, you can disable old remote server and create a new one. take_sample() won't collect samples for disabled server, so you'll avoid this error. But you'll need to take care of remote servers naming and retention - pg_profile won't delete obsolete samples (and servers) in such case. Anyway, it seems there is no convenient solution in your case.
Hi,
Thank you for the suggestion. I'll consider changing the way I restore the db to preserve the system identifier, so that I can use pg_profile the way it was intended.
Thank you for the support!
In 4.2 the error message in such case should be much more clear, but system identifier is still strictly controlled. You should create a new server if the system identifier was changed.
Hi, and thanks for a great project!
In my setup pg_profile v4.1 is running in a docker container with postgres 14.3, and collecting samples from 2 dbs on remote servers. For one of the dbs it's working perfectly fine. For the other db, I get errors when taking a sample. This specific db is a development db meant for testing and trying out stuff, and is completely deleted each night and then restored from a backup of the production db. My guess is that this error has something to do with that? If I drop the server in pg_profile and create it again, samples can be taken for the rest of the day (until the db is deleted in the night again).
What is the cause of the error? Is there any workaround I can use?
Thanks!