austinried / subtracks

A music streaming app for Subsonic-compatible servers
GNU General Public License v3.0
703 stars 30 forks source link

Initial sync fails on 2.0.0-alpha.1 #166

Closed fcharlier closed 1 year ago

fcharlier commented 1 year ago

Describe the bug After adding my server to the source, doing the initial sync runs but after it finishes the UI says "No items found".

I can see requests to the API on my server, the last ones are:

"GET /rest/search3.view?v=1.13.0&c=subtracks&u=redacted&s=%28e%29f&t=8b35a78ab3bc179ab9e62eaff8bc3138&query=%22%22&songCount=500&songOffset=41500&artistCount=0&albumCount=0 HTTP/1.0" 200 221820 "-" "subtracks/android"
"GET /rest/search3.view?v=1.13.0&c=subtracks&u=redacted&s=%5B%5EsC&t=dfc113431e137b9533f7990f3b8b2f98&query=%22%22&songCount=500&songOffset=42000&artistCount=0&albumCount=0 HTTP/1.0" 200 215326 "-" "subtracks/android"
"GET /rest/search3.view?v=1.13.0&c=subtracks&u=redacted&s=%40%22Ki&t=c9696f83d2e8792b3b1d0e1a47947f32&query=%22%22&songCount=500&songOffset=42500&artistCount=0&albumCount=0 HTTP/1.0" 200 59040 "-" "subtracks/android"
"GET /rest/getAlbumList2.view?v=1.13.0&c=subtracks&u=redacted&s=redacted&type=newest&size=500&offset=500 HTTP/1.0" 200 145734 "-" "subtracks/android"
"GET /rest/getAlbumList2.view?v=1.13.0&c=subtracks&u=redacted&s=redacted&type=newest&size=500&offset=1000 HTTP/1.0" 200 146106 "-" "subtracks/android"
"GET /rest/getAlbumList2.view?v=1.13.0&c=subtracks&u=redacted&s=redacted&type=newest&size=500&offset=1500 HTTP/1.0" 200 146307 "-" "subtracks/android"
"GET /rest/getAlbumList2.view?v=1.13.0&c=subtracks&u=redacted&s=redacted&type=newest&size=500&offset=2000 HTTP/1.0" 200 146408 "-" "subtracks/android"
"GET /rest/getAlbumList2.view?v=1.13.0&c=subtracks&u=redacted&s=redacted&type=newest&size=500&offset=2500 HTTP/1.0" 200 147273 "-" "subtracks/android"
"GET /rest/getAlbumList2.view?v=1.13.0&c=subtracks&u=redacted&s=redacted&type=newest&size=500&offset=3000 HTTP/1.0" 200 147413 "-" "subtracks/android"
"GET /rest/getAlbumList2.view?v=1.13.0&c=subtracks&u=redacted&s=redacted&type=newest&size=500&offset=3500 HTTP/1.0" 200 1017 "-" "subtracks/android"

I have an error showing in adb logcat, see end of the report.

To Reproduce Steps to reproduce the behavior:

  1. Add my server to sources
  2. Pull down on the "Music note" tab
  3. Wait for the sync to go on
  4. Nothing

Expected behavior There should be items in the music library or an error should be shown

Device

Server

Additional context Logs which appear relevant from adb logcat:

05-02 12:39:58.146 25273 25305 E flutter : [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: SqliteException(1): while preparing statement, too many SQL variables, SQL logic error (code 1)
05-02 12:39:58.146 25273 25305 E flutter :   Causing statement: DELETE FROM "songs" WHERE "source_id" = ? AND "id" NOT IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
05-02 12:39:58.146 25273 25305 E flutter : #0      DriftCommunication.request (package:drift/src/remote/communication.dart:113)
05-02 12:39:58.146 25273 25305 E flutter : #1      _BaseExecutor._runRequest (package:drift/src/remote/client_impl.dart:97)
05-02 12:39:58.146 25273 25305 E flutter : #2      _BaseExecutor.runDelete (package:drift/src/remote/client_impl.dart:114)
05-02 12:39:58.146 25273 25305 E flutter : #3      DeleteStatement.go.<anonymous closure> (package:drift/src/runtime/query_builder/statements/delete.dart:54)
05-02 12:39:58.146 25273 25305 E flutter : #4      DatabaseConnectionUser.doWhenOpened.<anonymous closure> (package:drift/src/runtime/api/connection_user.dart:162)
05-02 12:39:58.146 25273 25305 E flutter : #5      _rootRunUnary (dart:async/zone.dart:1406)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #6      SubtracksDatabase.deleteSongsNotIn (package:subtracks/database/database.dart:254)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #7      SyncService._syncAllSongs (package:subtracks/services/sync_service.dart:79)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #8      DatabaseConnectionUser.transaction.<anonymous closure>.<anonymous closure> (package:drift/src/runtime/api/connection_user.dart:462)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #9      DatabaseConnectionUser.transaction (package:drift/src/runtime/api/connection_user.dart:455)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #10     Future.wait.<anonymous closure> (dart:async/future.dart:522)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #11     SyncService.syncAll.<anonymous closure> (package:subtracks/services/sync_service.dart:19)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #12     DatabaseConnectionUser.transaction.<anonymous closure>.<anonymous closure> (package:drift/src/runtime/api/connection_user.dart:462)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #13     DatabaseConnectionUser.transaction (package:drift/src/runtime/api/connection_user.dart:455)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : #14     SyncService.syncAll (package:subtracks/services/sync_service.dart:18)
05-02 12:39:58.146 25273 25305 E flutter : <asynchronous suspension>
05-02 12:39:58.146 25273 25305 E flutter : 
austinried commented 1 year ago

Thanks for the logs, that helps a lot here. I can see from your last song requests there that you have a little under 43,000 songs, and from my research I'm now seeing that there is apparently a 32,766 parameter limit sqlite queries that we're running into.

So I've worked around that to only pass the IDs we actually need to delete, and switching to that strategy allows chunking the IDs by the limit, which prevent these errors even if the sync needs to delete a large number of items.

Are you able to test the build from my PR here and see if that resolves the sync issue for you? https://github.com/austinried/subtracks/actions/runs/4899059706?pr=167

austinried commented 1 year ago

Fix for this was released in 2.0.0-alpha.2.

fcharlier commented 1 year ago

@austinried hi,

The sync seems to complete successfully now, I can see items in my library.

Thank you for the fix.