Skip to content

Commit 2bd8fdd

Browse files
authored
fix: rollback prefix migration (#770)
1 parent b66adbd commit 2bd8fdd

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
DROP TRIGGER IF EXISTS objects_delete_cleanup ON storage.objects;
2+
DROP TRIGGER IF EXISTS prefixes_delete_cleanup ON storage.prefixes;
3+
DROP TRIGGER IF EXISTS objects_update_cleanup ON storage.objects;
4+
DROP TRIGGER IF EXISTS objects_update_level_trigger ON storage.objects;
5+
6+
CREATE OR REPLACE TRIGGER "objects_insert_create_prefix"
7+
BEFORE INSERT ON "storage"."objects"
8+
FOR EACH ROW
9+
EXECUTE FUNCTION "storage"."objects_insert_prefix_trigger"();
10+
11+
CREATE OR REPLACE TRIGGER "objects_update_create_prefix"
12+
BEFORE UPDATE ON "storage"."objects"
13+
FOR EACH ROW
14+
WHEN (NEW.name != OLD.name)
15+
EXECUTE FUNCTION "storage"."objects_insert_prefix_trigger"();
16+
17+
CREATE OR REPLACE TRIGGER "objects_delete_delete_prefix"
18+
AFTER DELETE ON "storage"."objects"
19+
FOR EACH ROW
20+
EXECUTE FUNCTION "storage"."delete_prefix_hierarchy_trigger"();
21+
22+
CREATE OR REPLACE TRIGGER "objects_update_create_prefix"
23+
BEFORE UPDATE ON "storage"."objects"
24+
FOR EACH ROW
25+
WHEN (NEW.name != OLD.name OR NEW.bucket_id != OLD.bucket_id)
26+
EXECUTE FUNCTION "storage"."objects_update_prefix_trigger"();
27+
28+
-- "storage"."prefixes"
29+
CREATE OR REPLACE TRIGGER "prefixes_delete_hierarchy"
30+
AFTER DELETE ON "storage"."prefixes"
31+
FOR EACH ROW
32+
EXECUTE FUNCTION "storage"."delete_prefix_hierarchy_trigger"();
File renamed without changes.

src/test/prefixes.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe('Prefix Hierarchy Race Condition Tests', () => {
166166
})
167167

168168
describe('Race Condition Scenario 1: Concurrent Deletes of Related Objects', () => {
169-
it('should handle concurrent deletion of objects in same folder without leaving dangling prefixes', async () => {
169+
it.skip('should handle concurrent deletion of objects in same folder without leaving dangling prefixes', async () => {
170170
// Create multiple objects in the same folder structure
171171
await createObject('shared/folder/file1.txt')
172172
await createObject('shared/folder/file2.txt')
@@ -198,7 +198,7 @@ describe('Prefix Hierarchy Race Condition Tests', () => {
198198
expect(prefixes).toHaveLength(0)
199199
})
200200

201-
it('should handle partial concurrent deletion correctly', async () => {
201+
it.skip('should handle partial concurrent deletion correctly', async () => {
202202
// Create objects in multiple subfolders
203203
await createObject('race/test/file1.txt')
204204
await createObject('race/test/file2.txt')
@@ -400,7 +400,7 @@ describe('Prefix Hierarchy Race Condition Tests', () => {
400400
})
401401

402402
describe('Stress Test: High Concurrency', () => {
403-
it('should handle many concurrent operations without corruption', async () => {
403+
it.skip('should handle many concurrent operations without corruption', async () => {
404404
// Create many objects in overlapping folder structures
405405
const objects: string[] = []
406406
const folders = ['stress1', 'stress2', 'stress3']
@@ -539,7 +539,7 @@ describe('Prefix Hierarchy Race Condition Tests', () => {
539539
expect(prefixes).toHaveLength(0)
540540
})
541541

542-
it('should handle concurrent moves from the same source folder without dangling prefixes', async () => {
542+
it.skip('should handle concurrent moves from the same source folder without dangling prefixes', async () => {
543543
await createObject('race-move/src/f1.txt')
544544
await createObject('race-move/src/f2.txt')
545545
await createObject('race-move/src/f3.txt')
@@ -564,7 +564,7 @@ describe('Prefix Hierarchy Race Condition Tests', () => {
564564
})
565565
})
566566

567-
it('should handle deadlock scenario in concurrent cross-prefix moves without hanging', async () => {
567+
it.skip('should handle deadlock scenario in concurrent cross-prefix moves without hanging', async () => {
568568
// This test reproduces the deadlock scenario where two transactions
569569
// try to move files between overlapping top-level prefixes in opposite directions:
570570
// Transaction 1: photos/* -> docs/* (locks photos -> docs)
@@ -699,7 +699,7 @@ describe('Prefix Hierarchy Race Condition Tests', () => {
699699
})
700700

701701
describe('Stress Test: Move Operations', () => {
702-
it('should handle many concurrent moves and clean old prefixes correctly', async () => {
702+
it.skip('should handle many concurrent moves and clean old prefixes correctly', async () => {
703703
const sources = ['mvstress/src1', 'mvstress/src2', 'mvstress/src3']
704704
const subs = ['sub1', 'sub2', 'sub3']
705705
const countPerSub = 5

0 commit comments

Comments
 (0)