Skip to content
New issue

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

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

Already on GitHub? # to your account

Sqlite issues at /tmp #280

Closed
zarulizham opened this issue Apr 19, 2024 · 3 comments
Closed

Sqlite issues at /tmp #280

zarulizham opened this issue Apr 19, 2024 · 3 comments

Comments

@zarulizham
Copy link

Hi,

I checked there are lots of mailpit-xxxx.db files inside /tmp.

Most of the file contains sqlite content such below.

My setup

  • ubuntu 22.04
  • run through systemd
  • there are 4 mailpit running on this machine with different --smpt and --listen port.

Systemd config

[Unit]
Description=Mailpit SPAS
After=network.target

[Service]
User=pentadbir
ExecStart=/usr/local/bin/mailpit --smtp=0.0.0.0:1026 --listen=0.0.0.0:8026
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target
SQLite format 3@  .f�
��
  �
   �
    9	�
         �
+	� =     b	      ��B[indexidx_tagsmailboxCREATE INDEX idx_tags ON mailbox (Tags)B[indexidx_readmailboxCREATE INDEX idx_read ON mailbox (Read)W+windexidx_attachmentsmailboxCREATE INDEX idx_attachments ON mailbox (AttachmentCREATE INDEX idx_inline ON mailbox (Inline)B[indexidx_sizemailbox
                                                                 CREATE INDEX idx_size ON mailbox (Size)�F
                                                                                                          �ctablemailboxmailbox
                                                                                                                               CREATE TABLE "mailbox" (
				Created INTEGER NOT NULL,
				ID TEXT NOT NULL,
				MessageID TEXT NOT NULL,
				Subject TEXT NOT NULL,
				Metadata TEXT,
				Size INTEGER NOT NULL,
				Inline INTEGER NOT NULL,
				Attachments INTEGER NOT NULL,
				Read INTEGER,
				Tags TEXT,
				SearchText TEXT
			)W	#%uindexidx_data_idmailbox_data
CREATE UNIQUE INDEX idx_data_id ON mailbox_data (ID)%%�tablemailbox_datamailbox_data	CREATE TABLE mailbox_data (
				ID TEXT KEY NOT NULL,
				Email BLOB
aindexidx_idmailboxCREATE UNIQUE INDEX idx_id ON mailbox (ID)K
                                                              #gindexidx_createdmailboxCREATE INDEX idx_created ON mailbox (Created)P++Ytablesqlite_sequencesqlite_sequenceCREATE TABLE sqlite_sequence(name,seq)�
�)K#gindexidx_subjectmailboCREATE INDEX idx_subject ON mailbox (Subject)S)qindexidx_message_idmailboxCREATE INDEX idx_message_id ON mailbox (MessageID)�e//�ytabledarwin_migrationsdarwin_migrationsCREATE TABLE darwin_migrations
                (
                    id             INTEGER  PRIMARY KEY,
                    version        FLOAT    NOT NULL,
                    description    TEXT     NOT NULL,
                    checksum       TEXT     NOT NULL,
                    applied_at     DATETIME NOT NULL,
                    execution_time FLOAT    NOT NULL,
                    UNIQUE         (version)
$�w$QCM?�333333Creating new mailbox format265f33e95fb5de8471e965eacb96cb27f"d�c��H1M?񙙙���Create tags columnab8248eb39f042eaa54cd0f8b3b825aef"d�NR8=	+MCreating tables131067770038bb8b27bdcb9bbb53946ef"d�I�
����
    ?�333333
            ?񙙙���
@axllent
Copy link
Owner

axllent commented Apr 19, 2024

Hi @zarulizham. When you say "lots", how many (approximately) do you mean?

The way you are starting Mailpit (without specifying a database) means it will create 3 unique temporary SQlite database files in /tmp, for example mailpit-1713565424512699308.db, mailpit-1713565424512699308.db-wal and mailpit-1713565424512699308.db-shm. When Mailpit exists normally, those three files should be automatically deleted (because you're using a temporary database). This means that with 4 running Mailpit instances, you should have 12 /tmp/mailpit-* files in total.

The fact that you have many indicates to me that one (or more) of your Mailpit instances may be failing to start, for instance if either the SMTP or HTTP port you specified in your systemd config are already in use by another service. I have just pushed a fix (unreleased) which will attempt to also remove these temporary files if Mailpit fails to start. In saying this, if you can confirm "lots" then I can get a better idea of whether this is expected (4x3 = 12), or whether you have a crashing service?

@zarulizham
Copy link
Author

zarulizham commented Apr 20, 2024

It was more than million files (total of 40GB). Last time I clear-up was 2 months ago. Every second there are more than 10 *.db files being written to /tmp.

I think one of mailpit service is clashing with mailhog service (port). It might be the reason there are non-stoppable .db files being written.

This issues solved when I specify --db-file in each of service files in systemd.

Thank you for the explanation and hint

@axllent
Copy link
Owner

axllent commented Apr 20, 2024

Oh wow, that is a LOT! Mailpit was exiting (early) most likely because a port was already in use, and leaving the temporary random database behind because of this (the fix for this will be in the next release, thanks for reporting!). In the meantime please check each of your Mailpit services to try identify which of those is being constantly restarted by systemd.

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

No branches or pull requests

2 participants