Immich android re-uploads files after docker restart
from anytimesoon@feddit.uk to selfhosted@lemmy.world on 18 Jun 19:16
https://feddit.uk/post/13515833

Hello,

I’ve noticed that when I restart my docker compose stack, the app seems to think that the server doesn’t have copies of the latest files and re-uploads them.

The files can be seen in the filesystem of the host, but not through the web interface until they have been re-uploaded. The app uploads duplicates of all the files, at which point the web can see them again, and the fs has duplicates of everything.

This happens when I restart the stack, no upgrades to the system, just docker compose down and docker compose up -d

My set up is using an unmodified compose file from the docs. Any ideas what I could be doing wrong?

#selfhosted

threaded - newest

seang96@spgrn.com on 18 Jun 19:35 next collapse

Are you using a web proxy? I am guessing it may be doing partials because of upload limit of the proxy.

anytimesoon@feddit.uk on 18 Jun 19:42 collapse

It is sitting behind caddy, not sure if that’s considered a proxy

avidamoeba@lemmy.ca on 18 Jun 20:20 collapse

Yes that is a proxy.

anytimesoon@feddit.uk on 18 Jun 20:51 collapse

I haven’t set a Max size, and from what I can understand in the docs, caddy doesn’t have a default Max upload

avidamoeba@lemmy.ca on 18 Jun 21:01 next collapse

I’ve no idea about the max size hypothesis. I’m simply confirming that Caddy is a proxy in this context.

seang96@spgrn.com on 18 Jun 22:31 collapse

caddy.its-em.ma/v1/docs/limits you appear to be correct it’s something else. Reviewing logs of Immich and if the images uploaded can be accessed would be good info to start with.

anytimesoon@feddit.uk on 19 Jun 10:28 collapse

The images are definitely uploaded. They’re on the fs, and in the correct folders

TheButtonJustSpins@infosec.pub on 18 Jun 21:43 next collapse

How are you persisting Immich’s database?

anytimesoon@feddit.uk on 18 Jun 22:02 collapse

Whatever was in the v1.101.0 compose file, which seems to be a docker volume.

69420@lemmy.world on 18 Jun 22:22 collapse

Did you set the UPLOAD_LOCATION variable in your .env file?

anytimesoon@feddit.uk on 19 Jun 07:42 collapse

Yes, it is set. The files persist fine and in the right location. I think Lem453 is along the right track. I think it’s a dB issue

Lem453@lemmy.ca on 19 Jun 00:25 collapse

There is an issue with your database persistence. The file is being uploaded but it’s not being recorded in your database for some reason.

Describe in detail what your hardware and software setup is, particularly the storage and OS.

You can probably check this by trying to upload something and then checking the database files to see the last modified date.

anytimesoon@feddit.uk on 19 Jun 10:25 collapse

I haven’t had time to look into this, but I think this might be the right track. Is it possible for docker to get volumes mixed up? Like, could there be a duplicate dB volume and when the stack gets restarted, docker picks one or the other?

To answer your question, I’m running docker 26.1.1 on Ubuntu server 22.04.4 LTS

The system is on an ssd and the storage is a three disk raid5

MangoPenguin@lemmy.blahaj.zone on 19 Jun 16:36 collapse

Like, could there be a duplicate dB volume and when the stack gets restarted, docker picks one or the other?

I’m not sure that is possible. Once a service has a volume defined it’ll use that unless you manually change it.

But if you don’t have a volume defined, data won’t persist when the service is updated.

If you’re just using the compose stack given by Immich, then everything should be set up properly though.

anytimesoon@feddit.uk on 19 Jun 18:15 collapse

The volume is defined like this at the end of the compose file

database:
    container_name: immich_postgres
    image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

volumes:
  pgdata:
  model-cache:
MangoPenguin@lemmy.blahaj.zone on 19 Jun 19:46 collapse

Yeah that looks fine, odd.

I assume this is a pretty normal install of Ubuntu, and /var/lib/docker hasn’t been messed with at all?

anytimesoon@feddit.uk on 20 Jun 07:40 next collapse

That’s correct. Ubuntu is basically just a platform to run docker, haven’t really touched it. Docker is the same. Just using it to run my containers. Haven’t ventured at all into /var/lib/docker

The weird thing is that it’s intermittent. It’s only happened twice since I started using immich. I’ve been restarting the containers repeatedly for a few days now and it hasnt happened again.

anytimesoon@feddit.uk on 20 Jun 15:40 collapse

It’s really weird. I think there are somehow two database volumes on my system.

The reason I think this is because:

  1. I am the only user
  2. there is only one user in the user table
  3. there are two folders in the upload folders. Both have a uuid as their name and one of the uuids matches with the user id in the database
  4. the user_token table has tokens no tokens from before this happened to me a couple days ago

So, where did this other user come from? Why have none of my log ins been tracked in the database before the incident?