Comments (14)
I'm wrong about the table name:
az485-267","pid":2274,"level":30,"time":"2023-05-13T15:00:42.158+00:00","v":0,"msg":"Exception raised, rolling back query","rollback":true,"query":";\nALTER TABLE pgbench_accounts RENAME to pgosc_op_table_pgbench_accounts;\nALTER TABLE pgosc_st_pgbench_accounts_16727e RENAME to pgbench_accounts;\n\n\n\nALTER TABLE pgosc_st_pgbench_accounts_16727e SET (fillfactor=100);\nDROP TRIGGER IF EXISTS primary_to_audit_table_trigger ON pgbench_accounts;\n","version":"0.7.5"}
2023-05-13T15:00:42.4805123Z +{"name":"pg-online-schema-change","hostname":"fv-az485-267","pid":2274,"level":60,"time":"2023-05-13T15:00:42.159+00:00","v":0,"msg":"Something went wrong: ERROR: relation \"pgosc_st_pgbench_accounts_16727e\" does not exist\n","e":"ERROR: relation \"pgosc_st_pgbench_accounts_16727e\" does not exist\n","version":"0.7.5"}
I'll fix that in my PR.
from pg-osc.
Confirmed working:
jefftest=# create table books (id serial primary key, email text);
CREATE TABLE
Time: 9.127 ms
jefftest=# alter table books SET (fillfactor=50, autovacuum_enabled=false);
ALTER TABLE
Time: 1.107 ms
MacBook-Pro :: ~/git/pg-osc βΉmain*βΊ Β» bundle exec pg-online-schema-change perform \
--alter-statement 'ALTER TABLE books RENAME COLUMN email TO new_email' \
--dbname "jefftest" --host localhost --username jeff
<SNIP>
{"name":"pg-online-schema-change","hostname":"MacBook-Pro.attlocal.net","pid":7755,"level":30,"time":"2023-05-13T15:41:12.159-05:00","v":0,"msg":"Performing ANALYZE!","version":"0.8.1"}
INFO: analyzing "public.books"
INFO: "books": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows
{"name":"pg-online-schema-change","hostname":"MacBook-Pro.attlocal.net","pid":7755,"level":30,"time":"2023-05-13T15:41:12.160-05:00","v":0,"msg":"Validating constraints!","version":"0.8.1"}
{"name":"pg-online-schema-change","hostname":"MacBook-Pro.attlocal.net","pid":7755,"level":30,"time":"2023-05-13T15:41:12.161-05:00","v":0,"msg":"All tasks successfully completed","version":"0.8.1"}
jefftest=# SELECT array_to_string(reloptions, ',') as params FROM pg_class WHERE relname='books';
ββββββββββββββββββββββββββββββββββββββββββ
β params β
ββββββββββββββββββββββββββββββββββββββββββ€
β fillfactor=50,autovacuum_enabled=false β
ββββββββββββββββββββββββββββββββββββββββββ
(1 row)
from pg-osc.
That sounds like a bug! I have some time set out this weekend, so will get to it. Thanks for reporting ππΎ
from pg-osc.
Looks like it should probably. go right here. I guess we should store the state of whether vacuum is enabled/disabled so we only set it back to the previous setting after swap?
from pg-osc.
So, we do capture any primary_table_storage_parameters
so we can re-add them later. We capture it here
pg-osc/lib/pg_online_schema_change/orchestrate.rb
Lines 182 to 183 in 1305877
And then add it back here
pg-osc/lib/pg_online_schema_change/orchestrate.rb
Lines 250 to 257 in 1305877
This is how we fetch the table storage params
pg-osc/lib/pg_online_schema_change/query.rb
Lines 292 to 294 in 1305877
So I think whats happening, the default autovacuum settings may not be getting returned and stored inside primary_table_storage_parameters
. I think the storage params are only returned if its set manually. I will confirm and get back.
Otherwise we will basically need to find a way to "reset" the autovacuum settings.
from pg-osc.
I was thinking a simple MVP would be to just re-enable autovacuum blindly because that would cover most of the cases and add it to the caveats. I can probably whip up a quick PR for that. Then we can see about only restoring it when it was enabled to begin with.
from pg-osc.
Oh, actually, I think I might've found the problem.
from pg-osc.
So, @shayonj your suspicion is correct, this is how a table's storage params with autovacuum set to defaults looks:
jefftest=# SELECT array_to_string(reloptions, ',') as params FROM pg_class WHERE relname='a';
ββββββββββ
β params β
ββββββββββ€
β \N β
ββββββββββ
(1 row)
from pg-osc.
Also, shouldn't this:
https://github.com/shayonj/pg-osc/blob/main/lib/pg_online_schema_change/orchestrate.rb#L256
still be #{shadow_table}
at this point in the process?
I think this gets us part of the way there:
#85
from pg-osc.
New release is out. Thanks for find and fix folks ππΎ
https://github.com/shayonj/pg-osc/releases/tag/v0.8.0
from pg-osc.
Whoops, reopened it by targeting error!
from pg-osc.
woot!!
from pg-osc.
Thanks @jfrost and @shayonj! I appreciate your effort! I promise I'll contribute more in the future. I had hoped/planned to at least get a PR going for this but I just didn't make the time.
from pg-osc.
no worries at all! Thanks for the reporting. It all helps!
from pg-osc.
Related Issues (20)
- Perform drop_and_cleanup! on POSIX signals
- Bulk push remaining rows in audit table before swap
- Ability to modify the SQL used to populate the new table HOT 10
- Add additional safety for custom copy sql HOT 2
- fix something on README about installation HOT 5
- operation_type audit table can conflict with column name on the primary table
- Introduce a PK/id field on audit table for ordered reads
- Deprecate -w option for password and replace with PGPASSWORD env
- race condition between replay and swap
- Add foreign keys to shadow table during swap HOT 1
- Integration/smoke test HOT 2
- Signal handler gets stuck on IO somewhere on SIGINT
- Some issues while working with partitioned table HOT 5
- Re-enable autovacuum and fix sequence naming post swap HOT 1
- Feature Request: We want to make it working with the table with trigger HOT 7
- Set the appropriate next sequence value on the new table HOT 11
- εΎδΈιηε·₯ε · HOT 1
- Potential need for a `pull-batch-delay` option HOT 4
- Views aren't updated after the swap HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg-osc.