v2rayA/v2rayA · error
failed to get last insert id for subscription %d: %w
Error message
failed to get last insert id for subscription %d: %w
What it means
Raised in migrateSubscriptions when res.LastInsertId fails after a successful subscription insert — the row was written but its new SQLite rowid cannot be retrieved (driver or database error), so the BoltDB-index→SQLite-id mapping needed to migrate the subscription's servers cannot be built.
Source
Thrown at service/db/migrate.go:311
for i, r := range results {
address := r.Get("address").String()
remarks := r.Get("remarks").String()
status := r.Get("status").String()
info := r.Get("info").String()
autoSelect := 0
if r.Get("autoSelect").Bool() {
autoSelect = 1
}
res, err := subStmt.Exec(address, remarks, status, info, autoSelect, i)
if err != nil {
return nil, fmt.Errorf("failed to insert subscription %d: %w", i, err)
}
subID, err := res.LastInsertId()
if err != nil {
return nil, fmt.Errorf("failed to get last insert id for subscription %d: %w", i, err)
}
// Record the mapping: BoltDB index (0-based) -> SQLite subscription ID
subIDMap[int64(i)] = subID
// Migrate servers within this subscription
servers := r.Get("servers").Array()
for j, s := range servers {
configJSON := s.Raw
if _, err := serverStmt.Exec(subID, configJSON, j); err != nil {
return nil, fmt.Errorf("failed to insert subscription server %d/%d: %w", i, j, err)
}
}
log.Info("Migrated subscription %d with %d servers", i, len(servers))
}
return subIDMap, nilView on GitHub (pinned to 71e5442fc5)
Solutions
- Retry migration from a clean SQLite file
- Check SQLite driver/database health
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at service/db/migrate.go:311 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of v2rayA/v2rayA@71e5442fc5 (2026-09-05).
Data as JSON: /api/errors/d4cac8b89e40cb0d.
Report an issue: GitHub.