Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
12.78k stars 1.46k forks source link

SQL error upon updating actor #6385

Open kontrollanten opened 2 months ago

kontrollanten commented 2 months ago

Describe the current behavior

We see a lot of the following errors in our postgres logs. Some times they come multiple times per our and some times it's some hours between.

2024-05-08 11:03:31.239 UTC [3800318] [10.1.0.193(42088)] peertube@peertube_prod ERROR:  duplicate key value violates unique constraint "actor_url"
2024-05-08 11:03:31.239 UTC [3800318] [10.1.0.193(42088)] peertube@peertube_prod DETAIL:  Key (url)=(https://REMOTE_INSTANCE/accounts/peertube) already exists.
2024-05-08 11:03:31.239 UTC [3800318] [10.1.0.193(42088)] peertube@peertube_prod STATEMENT:  UPDATE "actor" SET "type"=$1,"preferredUsername"=$2,"url"=$3,"publicKey"=$4,"followingCount"=$5,"inboxUrl"=$6,"outboxUrl"=$7,"followersUrl"=$8,"followingUrl"=$9,"remoteCreatedAt"=$10,"updatedAt"=$11 WHERE "id" = $12

The REMOTE_INSTANCE variable is a Peertube instance who's following ours, and that instance is running Peertube 6.0.4. Some of the errors is logged at the same timestamp as when activity-pub-refresher job has been ran (succesfully). These jobs has a payload that looks like:

{
  "type": "actor",
  "url": "https://REMOTE_INSTANCE/accounts/SOME_USERNAME"
}

Steps to reproduce

1. 2. 3.

Describe the expected behavior

No response

Additional information

Chocobozzz commented 2 months ago

Hi,

Are you able to check in your database the current url of the row "id" = $12? I suspect the remote instance updated its URL, that you already have in your database.

kontrollanten commented 2 months ago

When I check the current url it's the same URL as the one it's trying to update with. I checked if there's any other rows with the same url, but it's just one. Sounds weird. I'm getting the id from this log statement https://github.com/Chocobozzz/PeerTube/blob/5dd0721bee82efe3cb5852bde9c2b5e91ef45b4c/server/core/lib/activitypub/actors/refresh.ts#L70