mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-22 13:40:56 +08:00
This change makes two changes to address issues with processes doing concurrent inserts and `drop_chunks` calls: - When a new chunk is created, any dimension slices that existed prior to creating the new chunk are locked to prevent them from being dropped before the chunk-creating process commits. - When a chunk is being dropped, concurrent inserts into the chunk that is being dropped will try to lock the dimension slices of the chunk. In case the locking fails (due to the slices being concurrently deleted), the insert process will treat the chunk as not existing and will instead recreate it. Previously, the chunk slices (and thus chunk) would be found, but the insert would fail when committing since the chunk was concurrently deleted. A prior commit (PR #2150) partially solved a related problem, but didn't lock all the slices of a chunk. That commit also threw an error when a lock on a slice could not be taken due to the slice being deleted by another transaction. This is now changed to treat that case as a missing slice instead, causing it to be recreated. Fixes #1986