Skip to content

Commit 0027d4d

Browse files
committed
BUGFIX:
- Fresh installation caused 2 database errors due to missing tables.
1 parent 6f9163a commit 0027d4d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

core/data/impl/nodeimpl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,9 @@ async def check_nodes():
898898
except FatalException as ex:
899899
self.log.critical(ex)
900900
exit(SHUTDOWN)
901+
except InFailedSqlTransaction:
902+
# we should only be here when the CLUSTER table does not exist yet
903+
raise
901904
except Exception as ex:
902905
self.log.exception(ex)
903906
raise

plugins/monitoring/commands.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,13 @@ async def install(self) -> bool:
8181
if await super().install():
8282
try:
8383
async with self.apool.connection() as conn:
84-
await conn.execute("""
85-
UPDATE plugins
86-
SET version = (
87-
SELECT version FROM plugins WHERE plugin = 'serverstats'
88-
)
89-
WHERE plugin = 'monitoring'
90-
""")
91-
cursor = await conn.execute("DELETE FROM plugins WHERE plugin = 'serverstats' RETURNING plugin")
84+
cursor = await conn.execute("SELECT version FROM plugins WHERE plugin = 'serverstats'")
9285
row = await cursor.fetchone()
9386
if row:
87+
async with conn.transaction():
88+
await conn.execute("UPDATE plugins SET version = %s WHERE plugin = 'monitoring'",
89+
(row[0], ))
90+
await conn.execute("DELETE FROM plugins WHERE plugin = 'serverstats'")
9491
self.log.info(" => Migrating serverstats to monitoring. Restart triggered ...")
9592
await self.node.restart()
9693
return True

0 commit comments

Comments
 (0)