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

[Enhancement]: Concurrent drop_chunk() #7636

Open
mkindahl opened this issue Jan 30, 2025 · 0 comments
Open

[Enhancement]: Concurrent drop_chunk() #7636

mkindahl opened this issue Jan 30, 2025 · 0 comments
Labels
enhancement An enhancement to an existing feature for functionality

Comments

@mkindahl
Copy link
Contributor

What type of enhancement is this?

Performance

What subsystems and features will be improved?

Command processing

What does the enhancement do?

When dropping a chunk from a hypertable using drop_chunks(), it will take quite heavy locks to be able to drop the chunk:

mats=# start transaction;
START TRANSACTION
mats=*# select drop_chunks('readings', older_than => '2022-06-14');
              drop_chunks               
----------------------------------------
 _timescaledb_internal._hyper_2_1_chunk
 _timescaledb_internal._hyper_2_2_chunk
(2 rows)

Locks taken are:

mats=# select relation::regclass, mode from pg_locks join pg_stat_activity using (pid) where locktype = 'relation' and pid = 1074774;
                      relation                       |        mode         
-----------------------------------------------------+---------------------
 _timescaledb_catalog.dimension_slice                | RowShareLock
 _timescaledb_catalog.dimension_slice                | RowExclusiveLock
 _timescaledb_internal._hyper_2_2_chunk              | AccessExclusiveLock
 _timescaledb_internal."1_1_readings_created_at_key" | AccessExclusiveLock
 _timescaledb_internal."2_2_readings_created_at_key" | AccessExclusiveLock
 _timescaledb_internal._hyper_2_1_chunk              | AccessExclusiveLock
(6 rows)

Having a concurrent version of drop_chunks() that take locks similar to locking done by ALTER TABLE ... DETACH PARTITION (that is SHARE UPDATE EXCLUSIVE) would avoid blocking readers and writers of the hypertable.

Implementation challenges

No response

@mkindahl mkindahl added the enhancement An enhancement to an existing feature for functionality label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to an existing feature for functionality
Projects
None yet
Development

No branches or pull requests

1 participant