fix: disable drop_all in init_db to fix startup hang
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 3s
Deploy to Testnet / deploy-testnet (push) Has started running
Integration Tests / test-service-integration (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Successful in 14s
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 3s
Deploy to Testnet / deploy-testnet (push) Has started running
Integration Tests / test-service-integration (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Successful in 14s
SQLModel.metadata.drop_all was causing 45+ second startup delays when database was large. Disabled the drop operation for faster startup.
This commit is contained in:
@@ -70,12 +70,13 @@ def init_db() -> Engine:
|
||||
engine = get_engine()
|
||||
|
||||
# DEVELOPMENT ONLY: Try to drop all tables first to ensure clean schema.
|
||||
# DISABLED: This causes startup hangs when database is large
|
||||
# If drop fails due to FK constraints or missing tables, ignore and continue.
|
||||
if "sqlite" in str(engine.url):
|
||||
try:
|
||||
SQLModel.metadata.drop_all(engine)
|
||||
except Exception as e:
|
||||
logger.warning(f"Drop all failed (non-fatal): {e}")
|
||||
# if "sqlite" in str(engine.url):
|
||||
# try:
|
||||
# SQLModel.metadata.drop_all(engine)
|
||||
# except Exception as e:
|
||||
# logger.warning(f"Drop all failed (non-fatal): {e}")
|
||||
|
||||
# Ensure data directory exists for SQLite (consistent with blockchain-node pattern)
|
||||
if "sqlite" in str(engine.url):
|
||||
|
||||
Reference in New Issue
Block a user