Description
Official Instance
- The bug is reproducible on the official hosted instance, or is API-related.
Describe the bug
I have a private instance and have a playlist with 30 videos or so on my account. The videos are all distinct (no duplicates). On this playlist, attempting to remove some videos fails with a database error (see logs below).
Some videos, however, do delete just fine. Seemingly, it's the videos that were added last to the playlist (the last couple of them) that don't display this behavior, while the videos that were added earlier do.
I suspect the amount of videos on the playlist might also play a part on this as I did a test where I deleted the videos that never displayed an error, and then attempted to delete the videos that previously erred, and they deleted fine.
For some context on timelines, I start seeing the error on videos added about 2 days ago.
I did a quick sanity test with the below reproduction steps on the official instance and wasn't able to replicate the issue, unfortunately.
To Reproduce
As mentioned, you might not see the error specifically with these reproduction steps. Playlist video count and time since added may play into this problem.
- Create playlist
- Add videos (presumably, a fair few of them)
- Attempt to delete ones at the top of the playlist (the earliest videos added to the playlist)
- Error as above
Expected behavior
No error, video is removed from the playlist
Logs/Errors
Here's the full error as displayed in the backend server:
I am running the backend on commit 69757fd
.
ERROR: ERROR: duplicate key value violates unique constraint "playlists_videos_ids_pkey"
Detail: Key (playlist_id, videos_order)=(6, 21) already exists.
An error occoured in the path: /user/playlists/remove
org.hibernate.exception.ConstraintViolationException: JDBC exception executing SQL [UPDATE playlists_videos_ids SET videos_order = videos_order - 1 WHERE playlist_id = ? AND videos_order > ?] [ERROR: duplicate key value violates unique constraint "playlists_videos_ids_pkey"
Detail: Key (playlist_id, videos_order)=(6, 21) already exists.] [n/a]
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:95)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:94)
at org.hibernate.sql.exec.internal.StandardJdbcMutationExecutor.execute(StandardJdbcMutationExecutor.java:96)
at org.hibernate.query.sql.internal.NativeNonSelectQueryPlanImpl.executeUpdate(NativeNonSelectQueryPlanImpl.java:76)
at org.hibernate.query.sql.internal.NativeQueryImpl.doExecuteUpdate(NativeQueryImpl.java:834)
at org.hibernate.query.spi.AbstractQuery.executeUpdate(AbstractQuery.java:637)
at me.kavin.piped.server.handlers.auth.AuthPlaylistHandlers.removeFromPlaylistResponse(AuthPlaylistHandlers.java:350)
at me.kavin.piped.server.ServerLauncher.lambda$mainServlet$50(ServerLauncher.java:484)
at io.activej.http.AsyncServlet.lambda$ofBlocking$0(AsyncServlet.java:43)
at io.activej.promise.Promise.lambda$ofBlocking$12(Promise.java:249)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "playlists_videos_ids_pkey"
Detail: Key (playlist_id, videos_order)=(6, 21) already exists.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:152)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.hibernate.sql.exec.internal.StandardJdbcMutationExecutor.execute(StandardJdbcMutationExecutor.java:83)
... 10 more
Browser, and OS with Version.
Brave Version 1.56.20
Windows 11 22H2 22621.2134
Additional context
No response