Skip to content

fix(proxy): avoid registration insert readback - #259

Merged
shenjinti merged 1 commit into
restsend:mainfrom
dengxiayehu:fix/registration_issue
Aug 26, 2026
Merged

fix(proxy): avoid registration insert readback#259
shenjinti merged 1 commit into
restsend:mainfrom
dengxiayehu:fix/registration_issue

Conversation

@dengxiayehu

Copy link
Copy Markdown
Contributor

Problem

A new SIP registration could return 503 Service Unavailable even though the locator row had already been
inserted successfully.

The database-backed locator used ActiveModel::insert(). On MySQL, SeaORM executes the INSERT and then
immediately queries the inserted row by its generated ID to return the complete model. If that follow-up read
does not observe the row yet, SeaORM returns:

RecordNotFound Error: Failed to find inserted item

The registrar treated this as a storage failure and returned SIP 503, although it never used the returned
model.

Reproduction

A regression test reproduces the exact database sequence:

  1. The existing-registration lookup returns no row.
  2. The INSERT succeeds with one affected row and a generated ID.
  3. The immediate read-back returns no row.

Before the fix, the test fails with the same Failed to find inserted item error observed at runtime.

Fix

Use Entity::insert(active_model).exec() for new locator rows.

This checks that the INSERT succeeds without fetching the complete row afterward. Real insert errors are still
propagated; no retry, delay, or error suppression is introduced.

Verification

The regression test was verified with a red-green cycle:

  • Before the fix: fails with RecordNotFound Error: Failed to find inserted item.
  • After the fix: registration succeeds.

@shenjinti
shenjinti merged commit a9d6d43 into restsend:main Aug 26, 2026
3 checks passed
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