Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubring.db.lock after unclean shutdown breaks gpg related actions #30781

Open
Janhouse opened this issue Apr 30, 2024 · 5 comments
Open

pubring.db.lock after unclean shutdown breaks gpg related actions #30781

Janhouse opened this issue Apr 30, 2024 · 5 comments
Labels

Comments

@Janhouse
Copy link

Janhouse commented Apr 30, 2024

Description

Commits page loads for a very, very long time if unclean shutdown has happened before.

Reason:

Since gpg creates lock file in /var/lib/gitea/home/.gnupg/public-keys.d/ , which is on a persistent volume, unclean shutdown leaves pubring.db.lock, and after following startup gpg operations fail because of the locked database.

Proposed fix:

I would suggest checking for the gpg database lock file during container startup, and remove it if it exists.

Gitea Version

1.21.11

Can you reproduce the bug on the Gitea demo site?

No, requires ability to crash the container

How are you running Gitea?

Docker compose with /var/lib/gitea persisted in volume

@JDI-Developers
Copy link

Can confirm.

Downgrading to previous version (for us that was 1.21.5) didn't resolve issue.
Removing lockfiles manually resolved the issue.

@xyhhx
Copy link

xyhhx commented May 17, 2024

fwiw i experienced this on forgejo too. a workaround that worked for me was to specify a different $GNUPGHOME, i.e.:

services:
  gitea:
    image: gitea/gitea:latest
    environment:
      GNUPGHOME: /.gnupg
# ...
    volumes:
      - ./data/gitea/gnupg:/.gnupg

@lunny
Copy link
Member

lunny commented May 21, 2024

Maybe we can have a check to delete these lock files when Gitea startup.

@MrMeeb
Copy link

MrMeeb commented Aug 4, 2024

I run into this sporadically as well, despite not having an unclean shutdown (from my perspective). The Gitea server is stopped every night for backup using docker compose stop. So maybe it's unclean there, but that would be an issue in itself.

A check for stale lock files would be very useful

@jdejaegh
Copy link

jdejaegh commented Nov 19, 2024

I also have this issue when I do docker compose stop to shutdown the container. I am using the image gitea/gitea:1.22.3.

My current setup is based on the docker-compose.yml file from the Installation with Docker page. I solved the issue by deleting the lock file at the startup of the container. I added this to the service definition:

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.22.3
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
+   command: sh -c "rm /data/gitea/home/.gnupg/public-keys.d/pubring.db.lock; /bin/s6-svscan /etc/s6"

The path /data/gitea/home/.gnupg/public-keys.d/pubring.db.lock is my problematic lock file. Then it runs the command that starts the container: /bin/s6-svscan /etc/s6.

When the lock file does not exist, it just logs a message and continues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants