signup: close two concurrency holes from final review
(1) RegisterAnonymousViewer now catches the unique-violation
race (SQLSTATE 23505 on Postgres / code 19 on SQLite) and
re-reads by UDID, returning the existing row instead of
surfacing 500 to the second concurrent /tool/signup caller.
New repo test exercises the back-to-back register path.
(2) Add unique index on SocialAccountConnection (AccountType,
AccountId). The auth handler's find-or-link path claimed
this index existed as the dedup backstop; the claim was
accurate as design intent but the schema was missing. Now
matched. Comment in handler updated.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
3271
SVSim.Database/Migrations/20260527184324_AddSocialAccountConnectionUniqueIndex.Designer.cs
generated
Normal file
3271
SVSim.Database/Migrations/20260527184324_AddSocialAccountConnectionUniqueIndex.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SVSim.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddSocialAccountConnectionUniqueIndex : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SocialAccountConnection_AccountType_AccountId",
|
||||
table: "SocialAccountConnection",
|
||||
columns: new[] { "AccountType", "AccountId" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_SocialAccountConnection_AccountType_AccountId",
|
||||
table: "SocialAccountConnection");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2923,6 +2923,9 @@ namespace SVSim.Database.Migrations
|
||||
|
||||
b1.HasKey("ViewerId", "Id");
|
||||
|
||||
b1.HasIndex("AccountType", "AccountId")
|
||||
.IsUnique();
|
||||
|
||||
b1.ToTable("SocialAccountConnection");
|
||||
|
||||
b1.WithOwner("Viewer")
|
||||
|
||||
Reference in New Issue
Block a user