Skip to content

rtc: keep update cache eviction order when listing recent disconnects - #4975

Merged
boks1971 merged 1 commit into
livekit:masterfrom
RaphaelFakhri:fix/recently-disconnected-lru-order
Oct 10, 2026
Merged

boks1971 merged 1 commit into
livekit:masterfrom
RaphaelFakhri:fix/recently-disconnected-lru-order

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Problem

GetRecentlyDisconnectedParticipants walks the participant update cache with Get. On the LRU cache, Get moves each entry to the front, so walking the keys from newest to oldest leaves the cache in reverse order. After a reconnect, the next participant updates evict the most recently updated participants instead of the oldest ones.

Once a subscriber has tracked 128 or more participants (a large room, or a long-lived room with churn), this has two effects:

  • A participant that disconnected just before the reconnect is dropped from the cache, so a later reconnect does not report it as disconnected and the client keeps it in its roster.
  • The out-of-order version check in SendParticipantUpdate no longer applies to recently updated participants, so a stale ParticipantInfo can follow a newer one.

Change

Read the entries with Peek, which does not change their recency.

Testing

Added TestRecentlyDisconnectedKeepsUpdateOrder. It fills the update cache, with a disconnect as the last update, lists the recent disconnects, sends one more update for a new participant, and checks that the disconnect is still reported.

  • Without the fix: go test ./pkg/rtc -run TestRecentlyDisconnectedKeepsUpdateOrder -count=1 fails on the second check (no disconnected participants).
  • With the fix: the same command passes, and go test ./pkg/rtc -count=1 passes.

GetRecentlyDisconnectedParticipants walked the participant update cache
with Get, which moves each entry to the front of the LRU. Walking from
newest to oldest left the cache in reverse order, so after a reconnect
the next updates evicted the most recently updated participants first.
In a room where the subscriber has tracked 128 or more participants, a
participant that had just disconnected was then dropped from the cache
and a later reconnect did not report it as disconnected, and the
out-of-order version check was lost for recently updated participants.

Use Peek, which reads an entry without changing its recency.
@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 10, 2026 19:33

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@boks1971 boks1971 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing that.

@boks1971
boks1971 merged commit 09d69da into livekit:master Oct 10, 2026
3 of 6 checks passed
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request Oct 14, 2026
…9 ➔ v1.13.10) (#2338)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` |

---

### Release Notes

<details>
<summary>livekit/livekit (docker.io/livekit/livekit-server)</summary>

### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10)

[Compare Source](livekit/livekit@v1.13.9...v1.13.10)

##### Changed

- sfu: forward the dependency descriptor for VP8 simulcast ([#&#8203;4987](livekit/livekit#4987))
- sfu: keep VP8 descriptor frame numbers across migration ([#&#8203;4989](livekit/livekit#4989))
- sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#&#8203;4991](livekit/livekit#4991))
- sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#&#8203;4976](livekit/livekit#4976))
- sfu: switch VP8 temporal layers up with the dependency descriptor ([#&#8203;4974](livekit/livekit#4974))
- sfu: pad the slot of a filtered packet that follows a sequence number gap ([#&#8203;4983](livekit/livekit#4983))
- sfu: send padding in the slot of a dropped out-of-order packet ([#&#8203;4979](livekit/livekit#4979))
- sfu: parse VP8 and VP9 payload descriptors without an allocation ([#&#8203;4981](livekit/livekit#4981))
- DownTrack: arm key frame requester timer only while a layer lock is pending ([#&#8203;4980](livekit/livekit#4980))
- turn: refuse TCP relays and limit relays to this host to media ports ([#&#8203;4992](livekit/livekit#4992))
- agent endpoints: address an unnamed deployment as "\_" ([#&#8203;4997](livekit/livekit#4997))
- Add OSS Scanner build image and threat model ([#&#8203;4995](livekit/livekit#4995))
- Update golang Docker tag to v1.27.1 ([#&#8203;4985](livekit/livekit#4985))
- Update alpine Docker tag to v3.24.2 ([#&#8203;4984](livekit/livekit#4984))
- Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#&#8203;4915](livekit/livekit#4915))

##### Fixed

- Send NACKs when processing RTX packets ([#&#8203;5000](livekit/livekit#5000))
- sfu: send padding-only packets with no payload ([#&#8203;4993](livekit/livekit#4993))
- rtc: release timed out pending tracks at the pending track limit ([#&#8203;4998](livekit/livekit#4998))
- Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#&#8203;4806](livekit/livekit#4806))
- rtc: keep update cache eviction order when listing recent disconnects ([#&#8203;4975](livekit/livekit#4975))
- fix(cli): return non-zero exit status on command errors ([#&#8203;4888](livekit/livekit#4888))
- Disable AV1 for Firefox clients before 157 ([#&#8203;4962](livekit/livekit#4962))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNTEuMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE1MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/2338
hbjydev pushed a commit to hbjydev/phoebe that referenced this pull request Oct 20, 2026
…v1.13.10) (#884)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` |

---

### Release Notes

<details>
<summary>livekit/livekit (docker.io/livekit/livekit-server)</summary>

### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10)

[Compare Source](livekit/livekit@v1.13.9...v1.13.10)

##### Changed

- sfu: forward the dependency descriptor for VP8 simulcast ([#&#8203;4987](livekit/livekit#4987))
- sfu: keep VP8 descriptor frame numbers across migration ([#&#8203;4989](livekit/livekit#4989))
- sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#&#8203;4991](livekit/livekit#4991))
- sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#&#8203;4976](livekit/livekit#4976))
- sfu: switch VP8 temporal layers up with the dependency descriptor ([#&#8203;4974](livekit/livekit#4974))
- sfu: pad the slot of a filtered packet that follows a sequence number gap ([#&#8203;4983](livekit/livekit#4983))
- sfu: send padding in the slot of a dropped out-of-order packet ([#&#8203;4979](livekit/livekit#4979))
- sfu: parse VP8 and VP9 payload descriptors without an allocation ([#&#8203;4981](livekit/livekit#4981))
- DownTrack: arm key frame requester timer only while a layer lock is pending ([#&#8203;4980](livekit/livekit#4980))
- turn: refuse TCP relays and limit relays to this host to media ports ([#&#8203;4992](livekit/livekit#4992))
- agent endpoints: address an unnamed deployment as "\_" ([#&#8203;4997](livekit/livekit#4997))
- Add OSS Scanner build image and threat model ([#&#8203;4995](livekit/livekit#4995))
- Update golang Docker tag to v1.27.1 ([#&#8203;4985](livekit/livekit#4985))
- Update alpine Docker tag to v3.24.2 ([#&#8203;4984](livekit/livekit#4984))
- Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#&#8203;4915](livekit/livekit#4915))

##### Fixed

- Send NACKs when processing RTX packets ([#&#8203;5000](livekit/livekit#5000))
- sfu: send padding-only packets with no payload ([#&#8203;4993](livekit/livekit#4993))
- rtc: release timed out pending tracks at the pending track limit ([#&#8203;4998](livekit/livekit#4998))
- Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#&#8203;4806](livekit/livekit#4806))
- rtc: keep update cache eviction order when listing recent disconnects ([#&#8203;4975](livekit/livekit#4975))
- fix(cli): return non-zero exit status on command errors ([#&#8203;4888](livekit/livekit#4888))
- Disable AV1 for Firefox clients before 157 ([#&#8203;4962](livekit/livekit#4962))

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/London)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNjcuNSIsInVwZGF0ZWRJblZlciI6IjQ0LjE2Ny41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.hayden.moe/hayden/phoebe/pulls/884
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants