fix(bot): 🐛 Messages not being flushed to the DB after asyncpg.exceptions.InterfaceError.
This commit is contained in:
@@ -143,7 +143,10 @@ class Calls(base.Cog):
|
||||
await models.Message.bulk_create(message_rows, batch_size=500)
|
||||
break
|
||||
|
||||
except asyncpg.exceptions.DeadlockDetectedError:
|
||||
except (
|
||||
asyncpg.exceptions.PostgresError,
|
||||
asyncpg.exceptions.InterfaceError,
|
||||
):
|
||||
continue
|
||||
|
||||
for _ in range(3):
|
||||
@@ -153,7 +156,10 @@ class Calls(base.Cog):
|
||||
)
|
||||
break
|
||||
|
||||
except asyncpg.exceptions.DeadlockDetectedError:
|
||||
except (
|
||||
asyncpg.exceptions.PostgresError,
|
||||
asyncpg.exceptions.InterfaceError,
|
||||
):
|
||||
continue
|
||||
|
||||
@commands.command(aliases=["c"])
|
||||
@@ -950,8 +956,7 @@ class Calls(base.Cog):
|
||||
pass
|
||||
|
||||
message_replies = await redis.hget(
|
||||
constants.CALL_MESSAGE_REPLIES_TEMPLATE % channel.call_id,
|
||||
message.id
|
||||
constants.CALL_MESSAGE_REPLIES_TEMPLATE % channel.call_id, message.id
|
||||
)
|
||||
|
||||
if message_replies is None:
|
||||
|
||||
@@ -9,6 +9,7 @@ import discord
|
||||
from discord import errors
|
||||
from discord.ext import commands
|
||||
|
||||
import tortoise
|
||||
from tortoise import transactions, expressions
|
||||
|
||||
from payphone import bot
|
||||
@@ -301,6 +302,8 @@ class Mods(base.Cog):
|
||||
|
||||
await self.bot.get_cog("Calls").flush_messages()
|
||||
|
||||
await tortoise.Tortoise.close_connections()
|
||||
|
||||
await ctx.send("⚡ Messages were flushed, payphone will shut down.")
|
||||
|
||||
sys.exit()
|
||||
|
||||
@@ -9,6 +9,8 @@ from payphone.core import config
|
||||
async def init() -> None:
|
||||
"""Initialize the database and it's connections."""
|
||||
|
||||
await tortoise.Tortoise.close_connections()
|
||||
|
||||
await tortoise.Tortoise.init(config.TORTOISE_ORM, use_tz=True)
|
||||
|
||||
await tortoise.Tortoise.generate_schemas(safe=True)
|
||||
|
||||
Reference in New Issue
Block a user