diced / zipline

A ShareX/file upload server that is easy to use, packed with features, and with an easy setup!
https://zipline.diced.sh/
MIT License
1.31k stars 128 forks source link

Bug: Database randomly deleting itself #550

Closed 4d62 closed 3 months ago

4d62 commented 4 months ago

What happened?

The users table seems to randomly delete itself. Has happened 3 times in the last few weeks

Version

latest (ghcr.io/diced/zipline or ghcr.io/diced/zipline:latest)

What browser(s) are you seeing the problem on?

No response

Zipline Logs

Postgres container logs:

2024-04-22 22:28:44.121 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-04-22 22:28:44.121 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2024-04-22 22:28:44.125 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-04-22 22:28:44.131 UTC [29] LOG:  database system was shut down at 2024-04-22 22:28:43 UTC
2024-04-22 22:28:44.138 UTC [1] LOG:  database system is ready to accept connections
2024-04-22 22:28:47.536 UTC [33] ERROR:  relation "public.User" does not exist at character 370
2024-04-22 22:28:47.536 UTC [33] STATEMENT:  SELECT "public"."User"."id", "public"."User"."uuid", "public"."User"."username", "public"."User"."password", "public"."User"."avatar", "public"."User"."token", "public"."User"."administrator", "public"."User"."superAdmin", "public"."User"."systemTheme", "public"."User"."embed", "public"."User"."ratelimit", "public"."User"."totpSecret", "public"."User"."domains" FROM "public"."User" WHERE "public"."User"."uuid" = $1 LIMIT $2 OFFSET $3

Container Log:

2024-04-22 10:28:47,538 PM info  [server::response] GET /api/user -> 401
PrismaClientKnownRequestError: 
Invalid `prisma.user.count()` invocation:
The table `public.User` does not exist in the current database.
    at fl.handleRequestError (/zipline/node_modules/@prisma/client/runtime/binary.js:187:6819)
    at fl.handleAndLogRequestError (/zipline/node_modules/@prisma/client/runtime/binary.js:187:6207)
    at fl.request (/zipline/node_modules/@prisma/client/runtime/binary.js:187:5927)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async a (/zipline/node_modules/@prisma/client/runtime/binary.js:192:10035)
    at async l (/zipline/.next/server/pages/api/auth/login.js:1:2814) {
  code: 'P2021',
  clientVersion: '5.6.0',
  meta: { table: 'public.User' }
}
2024-04-22 10:28:55,141 PM info  [server::response] POST /api/auth/login -> 500


### Browser Logs

_No response_

### Additional Info

_No response_
4d62 commented 4 months ago

postgres has startup logs cause i tried restarting the container

diced commented 4 months ago

are you running via docker? if you aren't using the provided example docker-compose.yml file you should make sure that the postgres container has a volume or everytime it restarts it loses its data. otherwise I have no idea what's going on here, so I'll have to look into it later.

4d62 commented 4 months ago

Yes, it is running on Docker. The only thing I modified from the suggested docker-compose.yml is the Postgres volume: it is now a file path. It shouldn't cause any issues as i've restarted other Postgres containers without any issues

edit: Db reset even if the container didn't restart

diced commented 4 months ago

if it didn't restart, then there probably a 75% chance that it's not zipline's fault considering you might be sharing the volume with other stuff... i suggest using a separate volume for pg and if the database still deletes its self then we can move on to finding out why

4d62 commented 4 months ago

Ok. I'll try that and reply if it happens again. First time i set Zipline up, it was using the default docker-compose with separate volumes tho.

diced commented 3 months ago

closing as stale, don't really know what the problem is though.