Skip to content

Commit 234c1d9

Browse files
committed
fix: update environment and operations for performance tests
1 parent 1a87ed6 commit 234c1d9

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

backend/src/platform/isolationEngine/environment.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,30 @@ def _copy_custom_indexes(self, src_schema: str, dst_schema: str) -> None:
6565
).fetchall()
6666
for idx_name, idx_def in rows:
6767
# Rewrite the CREATE INDEX to target the new schema
68-
new_def = idx_def.replace(
69-
f" ON {src_schema}.", f" ON {dst_schema}."
70-
)
68+
new_def = idx_def.replace(f" ON {src_schema}.", f" ON {dst_schema}.")
7169
# Avoid name collisions by prefixing with target schema
7270
new_idx_name = f"{dst_schema}_{idx_name}"
71+
# Handle both CREATE INDEX and CREATE UNIQUE INDEX
72+
new_def = new_def.replace(
73+
f"CREATE UNIQUE INDEX {idx_name}",
74+
f"CREATE UNIQUE INDEX IF NOT EXISTS {new_idx_name}",
75+
)
7376
new_def = new_def.replace(
7477
f"CREATE INDEX {idx_name}",
7578
f"CREATE INDEX IF NOT EXISTS {new_idx_name}",
7679
)
7780
try:
78-
conn.execute(text(new_def))
81+
# Use a savepoint so a single index failure doesn't abort
82+
# the entire transaction and block subsequent indexes.
83+
nested = conn.begin_nested()
84+
try:
85+
conn.execute(text(new_def))
86+
nested.commit()
87+
except Exception as exc:
88+
nested.rollback()
89+
logger.warning(
90+
f"Could not copy index {idx_name} to {dst_schema}: {exc}"
91+
)
7992
except Exception as exc:
8093
logger.warning(
8194
f"Could not copy index {idx_name} to {dst_schema}: {exc}"

backend/src/services/box/database/operations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ def update_folder(
547547
)
548548
old_path = folder.path or "/"
549549
folder.parent_id = parent_id
550+
folder.parent = new_parent # Keep ORM relationship in sync with FK
550551
folder.path = _compute_folder_path(new_parent)
551552
# Cascade path changes to all descendants
552553
_cascade_path_update(session, folder, old_path)
@@ -1019,6 +1020,7 @@ def update_file(
10191020
conflicts=[{"type": "file", "id": existing.id, "name": existing.name}],
10201021
)
10211022
file.parent_id = parent_id
1023+
file.parent = new_parent # Keep ORM relationship in sync with FK
10221024
file.path = _compute_folder_path(new_parent) # new_parent.path + new_parent.id
10231025
if tags is not None:
10241026
file.tags = tags

0 commit comments

Comments
 (0)