Files
mtusi2026lab4/evidence/storage-layout.txt
T
ArtyomandClaude Opus 5.5 db901d6401 Record level 3 evidence and fill in the report
Evidence comes from the stand started from an empty state and from a
fresh clone: the public smoke, the contract checks, lint and 325 own
tests, the storage layout with an out-of-API comparison of a stored
object against its metadata, failover of each replica under writes, the
upload failover scenario, persistence with StartedAt of every service
including S3, the S3 outage scenario and 22 S3 privacy and bootstrap
checks. The storage evidence script now covers the attachment tables
and the S3 secrets.

REPORT.md follows the lab 4 template: launch from a clean clone,
architecture with the source of truth for each fact, the write order
between PostgreSQL and S3 and what each failure leaves behind, where
each upload limit applies, roles and services, the .env.example
mapping, grade 3 rows and the grade 3 failure table. The design notes
the botocore Expect header that hung uploads behind the port proxy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-28 22:20:10 +03:00

100 lines
5.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
date: 2026-10-28T19:01:15Z commit: 24f9d61
$ docker compose ps --format '{{.Service}} {{.Status}} {{.Ports}}'
api Up 17 seconds (healthy)
api Up 17 seconds (healthy)
lb Up 23 seconds (healthy) 127.0.0.1:18084->8080/tcp, 127.0.0.1:24084->8404/tcp
migrate Exited (0) 17 seconds ago
postgres Up 23 seconds (healthy)
s3 Up 8 seconds (healthy)
s3-init Exited (0) 18 seconds ago
valkey Up 23 seconds (healthy)
$ psql -c '\d attachments'
Table "public.attachments"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
id | uuid | | not null |
chat_id | uuid | | not null |
owner_id | uuid | | not null |
filename | text | | not null |
content_type | text | | not null |
size_bytes | bigint | | not null |
sha256 | text | | not null |
width | integer | | not null |
height | integer | | not null |
object_key | text | C | not null |
status | text | | not null |
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
Indexes:
"attachments_pkey" PRIMARY KEY, btree (id)
"attachments_chat_key" UNIQUE CONSTRAINT, btree (id, chat_id)
"attachments_object_key_key" UNIQUE CONSTRAINT, btree (object_key)
"attachments_pending_idx" btree (created_at) WHERE status = 'pending'::text
Check constraints:
"attachments_content_type_check" CHECK (content_type = ANY (ARRAY['image/png'::text, 'image/jpeg'::text]))
"attachments_filename_check" CHECK (char_length(filename) >= 1 AND char_length(filename) <= 255)
"attachments_height_check" CHECK (height > 0)
"attachments_sha256_check" CHECK (sha256 ~ '^[0-9a-f]{64}$'::text)
"attachments_size_bytes_check" CHECK (size_bytes >= 1 AND size_bytes <= 10485760)
"attachments_status_check" CHECK (status = ANY (ARRAY['pending'::text, 'ready'::text]))
"attachments_width_check" CHECK (width > 0)
Foreign-key constraints:
"attachments_owner_fkey" FOREIGN KEY (chat_id, owner_id) REFERENCES chat_members(chat_id, user_id)
Referenced by:
TABLE "message_attachments" CONSTRAINT "message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
$ psql -c '\d message_attachments'
Table "public.message_attachments"
Column | Type | Collation | Nullable | Default
---------------+----------+-----------+----------+---------
message_id | uuid | | not null |
position | smallint | | not null |
chat_id | uuid | | not null |
attachment_id | uuid | | not null |
Indexes:
"message_attachments_pkey" PRIMARY KEY, btree (message_id, "position")
"message_attachments_attachment_idx" btree (attachment_id)
"message_attachments_message_id_attachment_id_key" UNIQUE CONSTRAINT, btree (message_id, attachment_id)
Check constraints:
"message_attachments_position_check" CHECK ("position" >= 0 AND "position" <= 9)
Foreign-key constraints:
"message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
"message_attachments_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
$ psql: столбцы bytea во всей схеме (хеши токенов и отпечатки, не файлы)
table_name | column_name
------------------+-------------
idempotency_keys | fingerprint
sessions | token_hash
(2 rows)
$ psql: вложения по статусу и максимальный размер строки attachments
status | count | max_row_bytes
---------+-------+---------------
ready | 14 | 256
pending | 1 | 256
(2 rows)
$ rc object list --recursive root/messenger-attachments/attachments/ | count
14
$ rc object list root/messenger-attachments/ (первые 3 объекта, ключи назначены сервером)
[2026-10-28 17:51:13] 109.20 KiB attachments/01a183a3-351f-76fa-aeea-a062669b6d93
[2026-10-28 18:08:05] 109.20 KiB attachments/01a183b2-a436-72cf-be25-cebcbb7b5753
[2026-10-28 18:08:15] 109.20 KiB attachments/01a183b2-cbcf-721b-afae-a1b01f9fdbbd
$ сверка вне API: sha256 и размер последнего ready-вложения в PostgreSQL против байтов объекта в bucket
postgres: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75 111817
s3: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75 111817
$ docker inspect api: ReadonlyRootfs, tmpfs, volumes/bind mounts
196b3a876d81 ro=true tmpfs={"/tmp":""} mounts=bind:/run/secrets/database_url bind:/run/secrets/cache_url bind:/run/secrets/cursor_secret bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key
8bd1d38428d0 ro=true tmpfs={"/tmp":""} mounts=bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key bind:/run/secrets/database_url bind:/run/secrets/cache_url bind:/run/secrets/cursor_secret
$ docker inspect s3: volume данных
volume:mtusi2026lab4_s3data:/data bind::/run/secrets/s3_root_user bind::/run/secrets/s3_root_password
$ секреты сервисов: root-ключи S3 только у s3/s3-init/s3-cli
api ['cache_url', 'cursor_secret', 'database_url', 's3_access_key_id', 's3_secret_access_key']
lb []
migrate ['database_url']
postgres ['postgres_password']
s3 ['s3_root_password', 's3_root_user']
s3-init ['s3_access_key_id', 's3_root_password', 's3_root_user', 's3_secret_access_key']
valkey ['valkey.conf']