feat: add rolling update with LB drain and rollout load profile
scripts/rolling-update.sh (make rolling_update) replaces API replicas one by one: build, migrations once, new replica UP in HAProxy, old replica drained and put into maintenance through the LB runtime API on loopback, then stopped and removed; the slot is reset once DNS drops the address. Expand migration adds messages.instance_id with a lock timeout. The bench rollout profile runs the same script under constant load, starting from the image of an older commit built with git archive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,8 +23,13 @@ async def insert_message(
|
||||
db_session: AsyncSession,
|
||||
*,
|
||||
message: dataclasses.MessageFullDTO,
|
||||
instance_id: str,
|
||||
) -> dataclasses.MessageFullDTO:
|
||||
await db_session.execute(insert(Message).values(**asdict(message)))
|
||||
"""Вставка сообщения; `instance_id` — реплика, которая его записала
|
||||
(колонка только для диагностики, в DTO и ответ не попадает)."""
|
||||
await db_session.execute(
|
||||
insert(Message).values(**asdict(message), instance_id=instance_id),
|
||||
)
|
||||
return message
|
||||
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ class MessageService:
|
||||
await message_repo.insert_message(
|
||||
db_session=self.db_session,
|
||||
message=message,
|
||||
instance_id=settings.app.instance_id,
|
||||
)
|
||||
# отложенная проверка ссылки ключа на сообщение — здесь
|
||||
await self.db_session.commit()
|
||||
|
||||
@@ -31,3 +31,8 @@ class Message(Base):
|
||||
chat_id: Mapped[UUID]
|
||||
sender_id: Mapped[UUID]
|
||||
text: Mapped[str] = mapped_column(Text)
|
||||
# X-Instance-Id реплики, которая записала сообщение; NULL — запись
|
||||
# версии до этой колонки. Наружу не отдаётся. Колонка добавлена
|
||||
# расширяющей миграцией: прежняя версия её не знает и работает на
|
||||
# новой схеме (design change rolling-update, решение 7)
|
||||
instance_id: Mapped[str | None] = mapped_column(Text)
|
||||
|
||||
Reference in New Issue
Block a user