beetbox / beetbox/beets

mbsync not doing anything when called with a query

Open
#6,120 1 comment 1 reaction 0 assignees View on GitHub
mbsync
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

Hi! I've been using mbsync for quite some time now (years!). My use pattern has historically been to sync any files which have not been modified in the last 30 days; which is done in an airflow job nightly. This has always run in <60 seconds; which i thought was impressive given the size of my library (~59000 items).

Today i tried running mbsync without a query and noticed that the output looked totally different; and it took more than an hour. This makes me wonder what is actually happening in the case when i call mbsync with a query.

### Problem

Today is October 22. So running mbsync with query `mtime:1900-01-01..2025-10-23` should theoretically apply to all items.
```
$ beet -vv mbsync --nomove 'mtime:1900-01-01..2025-10-23'
user configuration: /home/squidward/.config/beets/config.yaml
data directory: /home/squidward/.config/beets
plugin paths:
fetchart: google: Disabling art source due to missing key
fetchart: lastfm: Disabling art source due to missing key
Sending event: pluginload
library database: /home/squidward/.config/beets/musiclibrary.db
library directory: /home/squidward/Music
Sending event: library_opened
Parsed query: AndQuery([DateQuery('mtime', '1900-01-01..2025-10-23', fast=True), NoneQuery('album_id', True)])
Parsed sort: NullSort()
Sending event: mb_track_extract
Sending event: trackinfo_received
Sending event: write
error reading , >
Sending event: database_change
Sending event: mb_track_extract
Sending event: trackinfo_received
Sending event: write
...

...

Sending event: write
Sending event: after_write
Sending event: database_change
Parsed query: AndQuery([SubstringQuery('mtime', '1900-01-01..2025-10-23', fast=True)])
Parsed sort: NullSort()
Sending event: cli_exit
```

That ran in 43 seconds.

But this runs for over an hour, and prints out quite a few updates to my database:
```
$ beet -vv mbsync --nomove
user configuration: /home/squidward/.config/beets/config.yaml
data directory: /home/squidward/.config/beets
plugin paths:
fetchart: google: Disabling art source due to missing key
fetchart: lastfm: Disabling art source due to missing key
Sending event: pluginload
library database: /home/squidward/.config/beets/musiclibrary.db
library directory: /home/squidward/Music
Sending event: library_opened
Parsed query: AndQuery([NoneQuery('album_id', True)])
Parsed sort: NullSort()
Sending event: mb_track_extract
Sending event: trackinfo_received
Sending event: write
error reading , >
Sending event: database_change
Sending event: mb_track_extract
Sending event: trackinfo_received
Sending event: write
error reading , >
Sending event: database_change
Sending event: mb_track_extract
Sending event: trackinfo_received
...
Sending event: database_change
Sending event: mb_track_extract
Sending event: trackinfo_received
Sending event: write
error reading , >
Sending event: database_change
Sending event: mb_track_extract
...
Sending event: database_change
Sending event: mb_track_extract
Sending event: trackinfo_received
Sending event: write
Sending event: after_write
Sending event: database_change
Parsed query: AndQuery([TrueQuery()])
Parsed sort: NullSort()
Requesting MusicBrainz release e11fb4c8-8294-4ed0-a4e9-4e82ee266931
Sending event: mb_track_extract
...
Sending event: mb_album_extract
Sending event: albuminfo_received
mbsync: applying changes to .380 - Gangsta Mack
Requesting MusicBrainz release 939add49-680b-4783-928a-b7caf4e8921f
Sending event: mb_track_extract
...
Sending event: albuminfo_received
mbsync: applying changes to 03 Greedo & Kenny Beats - Netflix & Deal
03 Greedo & Kenny Beats - Netflix & Deal - Traffic
albumstatus: Official -> Withdrawn
Sending event: write
Sending event: after_write
Sending event: database_change
03 Greedo & Kenny Beats - Netflix & Deal - Paid in Full
albumstatus: Official -> Withdrawn
Sending event: write
Sending event: after_write
Sending event: database_change
03 Greedo & Kenny Beats - Netflix & Deal - Maria
albumstatus: Official -> Withdrawn
Sending event: write
Sending event: after_write
...
```

I suppose i am wondering whether this is the expected behavior? Am i not thinking about the query correctly?

### Setup

```
➜ beet version
beets version 2.3.1
Python version 3.12.3
plugins: fetchart, lyrics, mbsync
```

My configuration (output of `beet config`) is:

```yaml
plugins: fetchart lyrics mbsync
discogs:
user_token: ...
lyrics:
google_API_key: REDACTED
auto: yes
translate:
api_key: REDACTED
from_languages: []
to_language:
dist_thresh: 0.11
google_engine_ID: REDACTED
genius_api_key: REDACTED
fallback:
force: no
local: no
print: no
synced: no
sources:
- lrclib
- google
- genius
- tekstowo
fetchart:
auto: yes
minwidth: 0
maxwidth: 0
quality: 0
max_filesize: 0
enforce_ratio: no
cautious: no
cover_names:
- cover
- front
- art
- album
- folder
sources:
- filesystem
- coverart
- itunes
- amazon
- albumart
- cover_art_url
store_source: no
high_resolution: no
deinterlace: no
cover_format:
google_key: REDACTED
google_engine: REDACTED
fanarttv_key: REDACTED
lastfm_key: REDACTED
```

Contributor guide

Open the contributing guide

Research direction

Start at the mbsync command entry point and trace how the supplied query is parsed versus the no-query path; compare the logged Parsed query and MusicBrainz requests. Confirm whether the two invocations are expected to differ, or reproduce a fix so the bounded query has the intended effect.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.