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

[db] sql: Scan error on column index 0, name \"SUM(Size)\": converting NULL to int64 is unsupported", mailpit | panic: runtime error: integer divide by zero #263

Closed
alexszilagyi opened this issue Mar 9, 2024 · 4 comments

Comments

@alexszilagyi
Copy link

alexszilagyi commented Mar 9, 2024

Hi there,

I have encountered the following issue:

mailpit         | time="2024/03/09 06:40:08" level=error msg="[db] sql: Scan error on column index 0, name \"SUM(Size)\": converting NULL to int64 is unsupported"
mailpit         | panic: runtime error: integer divide by zero
mailpit         | 
mailpit         | goroutine 6 [running]:
mailpit         | github.com/axllent/mailpit/internal/storage.dbCron()
mailpit         | 	/app/internal/storage/cron.go:30 +0x18f
mailpit         | created by github.com/axllent/mailpit/internal/storage.InitDB in goroutine 1
mailpit         | 	/app/internal/storage/database.go:94 +0x4a5
mailpit exited with code 2

It seems that the issues is somewhere at those lines:
https://github.com/axllent/mailpit/blob/develop/internal/storage/cron.go#L30

INSERT INTO settings (Key, Value) VALUES("DeletedSize", (SELECT SUM(Size)/2 FROM mailbox));`,

Select("SUM(Size)").To(&result).

Any ideas how to fix this?

I am using the latest version of mailpit. axllent/mailpit:latest docker image, with the following config:

   image: axllent/mailpit:latest
    container_name: mailpit
    environment:
       - TZ=Europe/Bucharest
       - MP_DATA_FILE=/data/mailpit.db
       - MP_UI_BIND_ADDR=0.0.0.0:9025
       - MP_SMTP_BIND_ADDR=0.0.0.0:1025
       - MP_MAX_MESSAGES=0
@axllent
Copy link
Owner

axllent commented Mar 9, 2024

Can you please tell me when this error happens... Is it immediately when Mailpit is started, or after running for 5 minutes?

@alexszilagyi
Copy link
Author

@axllent I am using in a CI/CD pipeline, after a certain amount of time. Can’t tell you exactly sure. Definitely not immediately

@axllent
Copy link
Owner

axllent commented Mar 9, 2024

I have just released a new version which should fix this error. Once you have updated it should be fairly easy to test - after 5 minutes of inactivity (ie: not using Mailpit) it runs a background process (which was crashing in your case). If Mailpit doesn't crash after 5 minutes of inactivity then it is fixed 👍

@alexszilagyi
Copy link
Author

Thank you @axllent , I can confirm that its fixed in v1.14.3.

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

No branches or pull requests

2 participants