neondatabase / neon

Neon: Serverless Postgres. We separated storage and compute to offer autoscaling, code-like database branching, and scale to zero.
https://neon.tech
Apache License 2.0
14.26k stars 407 forks source link

wal_craft: tests leak 56 bytes of shmem #6441

Open koivunej opened 7 months ago

koivunej commented 7 months ago

Reproduction on 1aea65eb9da46030f2b9740f3694b821663e0a90:

  1. ipcs to verify there are no shmem segments
  2. cargo nextest run -p wal_craft v14::xlog_utils_test::test_encode_logical_message
  3. ipcs to confirm it DID NOT leak anything
  4. cargo nextest run -p wal_craft wal_craft v14::xlog_utils_test::test_find_end_of_wal_simple
  5. ipcs to confirm it leaked one 56 byte segment
$ ipcs
------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x0028367b 66027524   admin      600        56         0

------ Semaphore Arrays --------
key        semid      owner      perms      nsems

For v14::xlog_utils_test::test_update_next_xid it seemed to happen at least once, for the rest it happens always, so ipcs will list 3 segments after cargo nextest run -p wal_craft v14::xlog_utils_test::test_find_end_of_wal_simple v14::xlog_utils_test::test_find_end_of_wal_last_crossing_segment v14::xlog_utils_test::test_find_end_of_wal_crossing_segment_followed_by_small_one.

Sometimes the v15 tests do not leak, similarly to v16.

Found on https://github.com/neondatabase/neon/issues/6373#issuecomment-1904687987.

koivunej commented 7 months ago

Interestingly enough, when running the tests in a loop a ipcrm -a was not enough and raw test logs still has for example:

2024-01-22 19:58:36.042 UTC [326426] FATAL:  could not resize shared memory segment "/PostgreSQL.1638637514" to 10976 bytes: No space left on device

After many successful iterations.