[GH-ISSUE #3] GUI not loading all messages #3

Closed
opened 2026-03-15 11:59:08 +03:00 by kerem · 27 comments
Owner

Originally created by @sandervanzutphen on GitHub (Aug 4, 2022).
Original GitHub issue: https://github.com/axllent/mailpit/issues/3

When opening the webclient not all messages are displayed.
The behavior seems a very random. At each refresh different messages are shown. Only very few occasions show all messages.

First pageload;
image

Second pageload;
image

Third pageload
image

v0.0.7, using -d parameter for datastorage.

Originally created by @sandervanzutphen on GitHub (Aug 4, 2022). Original GitHub issue: https://github.com/axllent/mailpit/issues/3 When opening the webclient not all messages are displayed. The behavior seems a very random. At each refresh different messages are shown. Only very few occasions show all messages. First pageload; ![image](https://user-images.githubusercontent.com/39266300/182885298-34b691fe-6731-4e6a-9a39-0b08bda028ba.png) Second pageload; ![image](https://user-images.githubusercontent.com/39266300/182885519-b2936b0b-a295-4236-b821-6a08b7f1e08d.png) Third pageload ![image](https://user-images.githubusercontent.com/39266300/182885683-26c775e1-79e0-4709-833e-97439863d6a7.png) v0.0.7, using -d parameter for datastorage.
kerem closed this issue 2026-03-15 11:59:14 +03:00
Author
Owner

@axllent commented on GitHub (Aug 4, 2022):

Thanks for the bug report. I have done plenty tests and never encountered this, so please can you please tell me what browser and OS you are using? Does the total number of displayed messages get fixed when you change the 50 (too right) to something else?

<!-- gh-comment-id:1205687533 --> @axllent commented on GitHub (Aug 4, 2022): Thanks for the bug report. I have done plenty tests and never encountered this, so please can you please tell me what browser and OS you are using? Does the total number of displayed messages get fixed when you change the 50 (too right) to something else?
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

Ahh, I think I possibly found the bug - when an email doesn't get stored correctly (eg: too large for the in-memory storage [1MB]) Mailpit rolls back the insert (there is a summary table and a raw email table). When rolling back it would always deduct the values from the "stats" (total number of messages, unread count etc), even when rolling back wasn't necessary. Is there a chance that one or two of your test emails were larger than 1MB and that you are using the memory storage (ie: not specifying a data directory) - OR could 1 or 2 of your test emails have been invalid emails (ie: not accepted by the SMTP server)?

I will release a new version later today which hopefully addresses the issue you are having. If, after the update (to the release I haven't made yet), you still continue to get this issue, you can have a look at http://0.0.0.0:8025/api/catchall/messages (adjust for your IP/port) which should give you the JSON response that is generating those values in the web UI, in particular the first few values in that response eg: "total":9,"unread":9,"count":9,"start":0, - I would be very interested to see what that says, and whether those values change when you refresh the link.

<!-- gh-comment-id:1206002267 --> @axllent commented on GitHub (Aug 5, 2022): Ahh, I think I possibly found the bug - when an email doesn't get stored correctly (eg: too large for the in-memory storage [1MB]) Mailpit rolls back the insert (there is a summary table and a raw email table). When rolling back it would always deduct the values from the "stats" (total number of messages, unread count etc), even when rolling back wasn't necessary. Is there a chance that one or two of your test emails were larger than 1MB and that you are using the memory storage (ie: not specifying a data directory) - OR could 1 or 2 of your test emails have been invalid emails (ie: not accepted by the SMTP server)? I will release a new version later today which hopefully addresses the issue you are having. If, after the update (to the release I haven't made yet), you still continue to get this issue, you can have a look at `http://0.0.0.0:8025/api/catchall/messages` (adjust for your IP/port) which should give you the JSON response that is generating those values in the web UI, in particular the first few values in that response eg: `"total":9,"unread":9,"count":9,"start":0,` - I would be very interested to see what that says, and whether those values change when you refresh the link.
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

GUI is Chrome on Win10.
Mailpit is on Ubuntu 20.04

Updated to 0.0.8, got some errors on the datastore, so i deleted the entire datastore dir.
Sent two testmails using smtper.net.
GUI AJAX result to api/catchall/messages; {"total":2,"unread":2,"count":0,"start":0,"items":[]}

Request;

GET /api/catchall/messages?limit=50 HTTP/1.1
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate
Accept-Language: nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7
Authorization: Basic ******
Connection: keep-alive
Host: *******:8025
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Response;

HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Type: application/json
Date: Fri, 05 Aug 2022 08:01:31 GMT
Content-Length: 70

{"total":2,"unread":2,"count":0,"start":0,"items":[]}
<!-- gh-comment-id:1206165949 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): GUI is Chrome on Win10. Mailpit is on Ubuntu 20.04 Updated to 0.0.8, got some errors on the datastore, so i deleted the entire datastore dir. Sent two testmails using smtper.net. GUI AJAX result to api/catchall/messages; `{"total":2,"unread":2,"count":0,"start":0,"items":[]}` Request; ``` GET /api/catchall/messages?limit=50 HTTP/1.1 Accept: application/json, text/plain, */* Accept-Encoding: gzip, deflate Accept-Language: nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7 Authorization: Basic ****** Connection: keep-alive Host: *******:8025 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 ``` Response; ``` HTTP/1.1 200 OK Content-Encoding: gzip Content-Type: application/json Date: Fri, 05 Aug 2022 08:01:31 GMT Content-Length: 70 {"total":2,"unread":2,"count":0,"start":0,"items":[]} ```
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

That is very strange. Does the Mailpit server report any issues?

<!-- gh-comment-id:1206182416 --> @axllent commented on GitHub (Aug 5, 2022): That is very strange. Does the Mailpit server report any issues?
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

On startup it crashes agien. Claiming memory shortage, but 2GB RAM available.

****@*****:~$ /data/mailpit/bin/mailpit -d /data/mailpit/datastore -a /data/mailpit/authdata
INFO[2022/08/05 10:35:35] [db] initialising data storage: /data/mailpit/datastore
badger 2022/08/05 10:35:35 ERROR: Received err: Error while creating log file in valueLog.open error: while opening file: /data/mailpit/datastore/000004.vlog error: cannot allocate memory
while mmapping /data/mailpit/datastore/000004.vlog with size: 2147483646
github.com/dgraph-io/ristretto/z.OpenMmapFileUsing
        /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:59
github.com/dgraph-io/ristretto/z.OpenMmapFile
        /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:86
github.com/dgraph-io/badger/v3.(*logFile).open
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/memtable.go:556
github.com/dgraph-io/badger/v3.(*valueLog).createVlogFile
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:519
github.com/dgraph-io/badger/v3.(*valueLog).open
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:619
github.com/dgraph-io/badger/v3.Open
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:368
github.com/ostafen/clover/v2.(*storageImpl).Open
        /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/storage.go:96
github.com/ostafen/clover/v2.Open
        /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/db.go:84
github.com/axllent/mailpit/storage.InitDB
        /github/workspace/storage/database.go:54
github.com/axllent/mailpit/cmd.glob..func1
        /github/workspace/cmd/root.go:33
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
github.com/axllent/mailpit/cmd.Execute
        /github/workspace/cmd/root.go:50
main.main
        /github/workspace/main.go:19
runtime.main
        /usr/local/go/src/runtime/proc.go:250
runtime.goexit
        /usr/local/go/src/runtime/asm_386.s:1326. Cleaning up...
ERRO[2022/08/05 10:35:35] During db.vlog.open error: Error while creating log file in valueLog.open error: while opening file: /data/mailpit/datastore/000004.vlog error: cannot allocate memory
while mmapping /data/mailpit/datastore/000004.vlog with size: 2147483646
github.com/dgraph-io/ristretto/z.OpenMmapFileUsing
        /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:59
github.com/dgraph-io/ristretto/z.OpenMmapFile
        /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:86
github.com/dgraph-io/badger/v3.(*logFile).open
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/memtable.go:556
github.com/dgraph-io/badger/v3.(*valueLog).createVlogFile
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:519
github.com/dgraph-io/badger/v3.(*valueLog).open
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:619
github.com/dgraph-io/badger/v3.Open
        /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:368
github.com/ostafen/clover/v2.(*storageImpl).Open
        /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/storage.go:96
github.com/ostafen/clover/v2.Open
        /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/db.go:84
github.com/axllent/mailpit/storage.InitDB
        /github/workspace/storage/database.go:54
github.com/axllent/mailpit/cmd.glob..func1
        /github/workspace/cmd/root.go:33
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
github.com/axllent/mailpit/cmd.Execute
        /github/workspace/cmd/root.go:50
main.main
        /github/workspace/main.go:19
runtime.main
        /usr/local/go/src/runtime/proc.go:250
runtime.goexit
        /usr/local/go/src/runtime/asm_386.s:1326
<!-- gh-comment-id:1206195570 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): On startup it crashes agien. Claiming memory shortage, but 2GB RAM available. ``` ****@*****:~$ /data/mailpit/bin/mailpit -d /data/mailpit/datastore -a /data/mailpit/authdata INFO[2022/08/05 10:35:35] [db] initialising data storage: /data/mailpit/datastore badger 2022/08/05 10:35:35 ERROR: Received err: Error while creating log file in valueLog.open error: while opening file: /data/mailpit/datastore/000004.vlog error: cannot allocate memory while mmapping /data/mailpit/datastore/000004.vlog with size: 2147483646 github.com/dgraph-io/ristretto/z.OpenMmapFileUsing /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:59 github.com/dgraph-io/ristretto/z.OpenMmapFile /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:86 github.com/dgraph-io/badger/v3.(*logFile).open /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/memtable.go:556 github.com/dgraph-io/badger/v3.(*valueLog).createVlogFile /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:519 github.com/dgraph-io/badger/v3.(*valueLog).open /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:619 github.com/dgraph-io/badger/v3.Open /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:368 github.com/ostafen/clover/v2.(*storageImpl).Open /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/storage.go:96 github.com/ostafen/clover/v2.Open /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/db.go:84 github.com/axllent/mailpit/storage.InitDB /github/workspace/storage/database.go:54 github.com/axllent/mailpit/cmd.glob..func1 /github/workspace/cmd/root.go:33 github.com/spf13/cobra.(*Command).execute /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876 github.com/spf13/cobra.(*Command).ExecuteC /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 github.com/spf13/cobra.(*Command).Execute /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918 github.com/axllent/mailpit/cmd.Execute /github/workspace/cmd/root.go:50 main.main /github/workspace/main.go:19 runtime.main /usr/local/go/src/runtime/proc.go:250 runtime.goexit /usr/local/go/src/runtime/asm_386.s:1326. Cleaning up... ERRO[2022/08/05 10:35:35] During db.vlog.open error: Error while creating log file in valueLog.open error: while opening file: /data/mailpit/datastore/000004.vlog error: cannot allocate memory while mmapping /data/mailpit/datastore/000004.vlog with size: 2147483646 github.com/dgraph-io/ristretto/z.OpenMmapFileUsing /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:59 github.com/dgraph-io/ristretto/z.OpenMmapFile /go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/file.go:86 github.com/dgraph-io/badger/v3.(*logFile).open /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/memtable.go:556 github.com/dgraph-io/badger/v3.(*valueLog).createVlogFile /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:519 github.com/dgraph-io/badger/v3.(*valueLog).open /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/value.go:619 github.com/dgraph-io/badger/v3.Open /go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:368 github.com/ostafen/clover/v2.(*storageImpl).Open /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/storage.go:96 github.com/ostafen/clover/v2.Open /go/pkg/mod/github.com/ostafen/clover/v2@v2.0.0-alpha.2/db.go:84 github.com/axllent/mailpit/storage.InitDB /github/workspace/storage/database.go:54 github.com/axllent/mailpit/cmd.glob..func1 /github/workspace/cmd/root.go:33 github.com/spf13/cobra.(*Command).execute /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876 github.com/spf13/cobra.(*Command).ExecuteC /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 github.com/spf13/cobra.(*Command).Execute /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918 github.com/axllent/mailpit/cmd.Execute /github/workspace/cmd/root.go:50 main.main /github/workspace/main.go:19 runtime.main /usr/local/go/src/runtime/proc.go:250 runtime.goexit /usr/local/go/src/runtime/asm_386.s:1326 ```
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

Fresh datastore, happens agien. No errors on the server.

<!-- gh-comment-id:1206197728 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): Fresh datastore, happens agien. No errors on the server.
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

Ahh, that starts to make more sense. I believe the 2GB is not RAM (despite the message), but rather physical file (in the datastore). What is /data/mailpit/? Is it a remote (nfs?) mount, does that mount have > 2GB? I actually wrote a wiki article on this very thing earlier today. It sounds to me like the physical database cannot write reliability to the folder, so so becomes corrupt - which would explain the inconsistencies.

<!-- gh-comment-id:1206203787 --> @axllent commented on GitHub (Aug 5, 2022): Ahh, that starts to make more sense. I believe the 2GB is not RAM (despite the message), but rather physical file (in the datastore). What is `/data/mailpit/`? Is it a remote (nfs?) mount, does that mount have > 2GB? I actually wrote a [wiki article](https://github.com/axllent/mailpit/wiki/Email-storage) on this very thing earlier today. It sounds to me like the physical database cannot write reliability to the folder, so so becomes corrupt - which would explain the inconsistencies.
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

/data/mailpit is a regular disk, with plenty of free diskspace.

*****@****:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1       144G  106G   31G  78% /

<!-- gh-comment-id:1206207049 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): `/data/mailpit` is a regular disk, with plenty of free diskspace. ``` *****@****:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 144G 106G 31G 78% / ```
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

FYI: CloverDB (actually BadgerDB) creates a 2GB file in the folder (a 00000*.vlog file) in amongst the other files - this gets removed again when Mailpit exists normally. Is your Ubuntu server/machine maybe a 32bit machine? What filesystem is /data/mailpit on?

<!-- gh-comment-id:1206214543 --> @axllent commented on GitHub (Aug 5, 2022): FYI: CloverDB (actually BadgerDB) creates a 2GB file in the folder (a `00000*.vlog` file) in amongst the other files - this gets removed again when Mailpit exists normally. Is your Ubuntu server/machine maybe a 32bit machine? What filesystem is `/data/mailpit` on?
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

$ uname -m
x86_64

$ mount | column -t
/dev/vda1                              on  /                                type  ext4        (rw,relatime)
<!-- gh-comment-id:1206219456 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): ``` $ uname -m x86_64 $ mount | column -t /dev/vda1 on / type ext4 (rw,relatime) ```
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

I am also running Ubuntu 20 on amd64, and I have extensively tested on this hardware, as well as via Github Actions (virtual hardware in the cloud) and I cannot reproduce your error (inserting / deleting / searching 1000 messages in both RAM and physical). I found a few references of similar errors via Google, but they don't seem appropriate given your storage and architecture, so I really have no idea at this stage.

  1. Have you tried to reproduce the error with the memory mode (ie: not setting a data dir)?
  2. Have you tried a different path (not that I think this will help if your entire HD is mounted on the same volume) eg: -d /tmp/mailpit?
  3. Have you checked dmesg to see if there are any kernel errors being reported (eg: hardware issues) shortly after getting the error?

I am just trying to narrow down why you are getting this problems.

<!-- gh-comment-id:1206264330 --> @axllent commented on GitHub (Aug 5, 2022): I am also running Ubuntu 20 on amd64, and I have extensively tested on this hardware, as well as via Github Actions (virtual hardware in the cloud) and I cannot reproduce your error (inserting / deleting / searching 1000 messages in both RAM and physical). I found a few references of similar errors via Google, but they don't seem appropriate given your storage and architecture, so I really have no idea at this stage. 1. Have you tried to reproduce the error with the memory mode (ie: not setting a data dir)? 2. Have you tried a different path (not that I think this will help if your entire HD is mounted on the same volume) eg: `-d /tmp/mailpit`? 3. Have you checked `dmesg` to see if there are any kernel errors being reported (eg: hardware issues) shortly after getting the error? I am just trying to narrow down why you are getting this problems.
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

  1. Also happend with in-memory storage. {"total":2,"unread":2,"count":0,"start":0,"items":[]}
  2. It's a VM, all storage ending in same disk. /tmp/mailpit same result.
  3. No kernel errors in sight.
<!-- gh-comment-id:1206272684 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): 1. Also happend with in-memory storage. `{"total":2,"unread":2,"count":0,"start":0,"items":[]}` 2. It's a VM, all storage ending in same disk. /tmp/mailpit same result. 3. No kernel errors in sight.
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

@ostafen Sorry to pull you into this, but have you come across this issue before, or something similar? I don't think this has anything to do with Mailpit, but rather something to do with either CloverDB or BadgerDB (occurring in both in RAM & physical storage). I suspect there is an issue with the memory/data mapping corruption which badger only discovers/displays on save/restart.

From what I can tell, @sandervanzutphen is storing two emails (in the later responses), clover returns no error (they saved successfully), but then they aren't found in the database (total and unread in the JSON are values stored in memory for quick lookup, and in this case should be matching the count and items length here because it's the first paginated page of only 2 results). Those in-memory values and are only set after successful writes via CloverDB to two catalogues(email summary / email data). count is the len(items), and items should be the the two results of the emails.

The very first post in this issue explains inconsistencies, where CloverDB is returning different results on page load (2, then 3, then 2 again) - so I am suspecting data corruption.

Restarting results in:

ERROR: Received err: Error while creating log file in valueLog.open error: while opening file: /data/mailpit/datastore/000004.vlog error: cannot allocate memory
while mmapping /data/mailpit/datastore/000004.vlog with size: 2147483646

Do you have any ideas? PS: this is using v2 of CloverDB.

<!-- gh-comment-id:1206294694 --> @axllent commented on GitHub (Aug 5, 2022): @ostafen Sorry to pull you into this, but have you come across this issue before, or something similar? I don't think this has anything to do with Mailpit, but rather something to do with either CloverDB or BadgerDB (occurring in both in RAM & physical storage). I suspect there is an issue with the memory/data mapping corruption which badger only discovers/displays on save/restart. From what I can tell, @sandervanzutphen is storing two emails (in the later responses), clover returns no error (they saved successfully), but then they aren't found in the database (`total` and `unread` in the JSON are values stored in memory for quick lookup, and in this case should be matching the `count` and `items` length here because it's the first paginated page of only 2 results). Those in-memory values and are only set after successful writes via CloverDB to two catalogues(email summary / email data). `count` is the `len(items)`, and `items` should be the the two results of the emails. The very first post in this issue explains inconsistencies, where CloverDB is returning different results on page load (2, then 3, then 2 again) - so I am suspecting data corruption. Restarting results in: ``` ERROR: Received err: Error while creating log file in valueLog.open error: while opening file: /data/mailpit/datastore/000004.vlog error: cannot allocate memory while mmapping /data/mailpit/datastore/000004.vlog with size: 2147483646 ``` Do you have any ideas? PS: this is using v2 of CloverDB.
Author
Owner

@ostafen commented on GitHub (Aug 5, 2022):

@axllent, do you ensure to call db.Close() every time the server shutdowns or gets killed?

<!-- gh-comment-id:1206300775 --> @ostafen commented on GitHub (Aug 5, 2022): @axllent, do you ensure to call `db.Close()` every time the server shutdowns or gets killed?
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

@ostafen Yes, I have a listener which closes the database. The issue of missing results however also happens when running memory though.

<!-- gh-comment-id:1206304104 --> @axllent commented on GitHub (Aug 5, 2022): @ostafen Yes, I have [a listener](https://github.com/axllent/mailpit/blob/2d221a6b67c39c0f96f2f864e9edc5f91fed3616/storage/database.go#L59-L74) which closes the database. The issue of missing results however also happens when running memory though.
Author
Owner

@ostafen commented on GitHub (Aug 5, 2022):

Is the available RAM 2GB? Maybe, badger is trying to allocate too much memory, so it gets the cannot allocate memory error. It could be useful to be able to reproduce the problem.
@sandervanzutphen, how much RAM do you have in your VM? Which golang version?

@sandervanzutphen, can you download the clover repo at this link: https://github.com/ostafen/clover and try to run tests?
If the error is due to clover, than I think that some tests should fail

<!-- gh-comment-id:1206311631 --> @ostafen commented on GitHub (Aug 5, 2022): Is the available RAM 2GB? Maybe, badger is trying to allocate too much memory, so it gets the `cannot allocate memory` error. It could be useful to be able to reproduce the problem. @sandervanzutphen, how much RAM do you have in your VM? Which golang version? @sandervanzutphen, can you download the clover repo at this link: https://github.com/ostafen/clover and try to run tests? If the error is due to clover, than I think that some tests should fail
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

FYI: @sandervanzutphen To test you will need "go" installed sudo apt install golang-go ca-certificates, then check out the clover repo and in the clover folder run go test ./...

<!-- gh-comment-id:1206335219 --> @axllent commented on GitHub (Aug 5, 2022): FYI: @sandervanzutphen To test you will need "go" installed `sudo apt install golang-go ca-certificates`, then check out the clover repo and in the clover folder run `go test ./...`
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

@ostafen

top - 13:48:47 up 43 days, 15:43,  2 users,  load average: 1.17, 0.44, 0.24
Tasks: 170 total,   1 running, 169 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.0 us,  1.0 sy,  0.0 ni, 96.9 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   3936.1 total,    345.1 free,    797.6 used,   2793.4 buff/cache
MiB Swap:   5160.0 total,   4720.1 free,    439.9 used.   2711.6 avail Mem
go test ./...
go: downloading github.com/google/orderedcode v0.0.1
go: downloading github.com/vmihailenco/msgpack/v5 v5.3.5
go: downloading github.com/dgraph-io/badger/v3 v3.2103.2
go: downloading github.com/stretchr/testify v1.7.1
go: downloading github.com/satori/go.uuid v1.2.0
go: downloading github.com/brianvoe/gofakeit/v6 v6.17.0
go: extracting github.com/vmihailenco/msgpack/v5 v5.3.5
go: extracting github.com/satori/go.uuid v1.2.0
go: extracting github.com/stretchr/testify v1.7.1
go: downloading github.com/vmihailenco/tagparser/v2 v2.0.0
go: extracting github.com/google/orderedcode v0.0.1
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: extracting github.com/vmihailenco/tagparser/v2 v2.0.0
go: extracting github.com/pmezard/go-difflib v1.0.0
go: extracting github.com/davecgh/go-spew v1.1.1
go: extracting gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: extracting github.com/brianvoe/gofakeit/v6 v6.17.0
go: extracting github.com/dgraph-io/badger/v3 v3.2103.2
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/dustin/go-humanize v1.0.0
go: downloading golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10
go: downloading github.com/google/flatbuffers v2.0.6+incompatible
go: downloading github.com/dgraph-io/ristretto v0.1.0
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading go.opencensus.io v0.23.0
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/klauspost/compress v1.15.9
go: extracting github.com/pkg/errors v0.9.1
go: extracting github.com/dustin/go-humanize v1.0.0
go: downloading github.com/golang/snappy v0.0.4
go: downloading golang.org/x/net v0.0.0-20220728211354-c7608f3a8462
go: extracting go.opencensus.io v0.23.0
go: extracting github.com/golang/snappy v0.0.4
go: extracting github.com/golang/protobuf v1.5.2
go: downloading github.com/cespare/xxhash v1.1.0
go: extracting github.com/dgraph-io/ristretto v0.1.0
go: downloading github.com/golang/glog v1.0.0
go: extracting github.com/cespare/xxhash v1.1.0
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: extracting github.com/golang/glog v1.0.0
go: extracting github.com/cespare/xxhash/v2 v2.1.2
go: extracting github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: downloading google.golang.org/protobuf v1.28.1
go: extracting golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10
go: extracting github.com/google/flatbuffers v2.0.6+incompatible
go: extracting golang.org/x/net v0.0.0-20220728211354-c7608f3a8462
go: extracting google.golang.org/protobuf v1.28.1
go: extracting github.com/gogo/protobuf v1.3.2
go: extracting github.com/klauspost/compress v1.15.9
go: finding github.com/dgraph-io/badger/v3 v3.2103.2
go: finding github.com/google/orderedcode v0.0.1
go: finding github.com/satori/go.uuid v1.2.0
go: finding github.com/vmihailenco/msgpack/v5 v5.3.5
go: finding github.com/dgraph-io/ristretto v0.1.0
go: finding github.com/gogo/protobuf v1.3.2
go: finding github.com/vmihailenco/tagparser/v2 v2.0.0
go: finding github.com/cespare/xxhash v1.1.0
go: finding github.com/dustin/go-humanize v1.0.0
go: finding github.com/pkg/errors v0.9.1
go: finding github.com/golang/protobuf v1.5.2
go: finding github.com/cespare/xxhash/v2 v2.1.2
go: finding github.com/google/flatbuffers v2.0.6+incompatible
go: finding github.com/golang/glog v1.0.0
go: finding go.opencensus.io v0.23.0
go: finding github.com/golang/snappy v0.0.4
go: finding golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10
go: finding google.golang.org/protobuf v1.28.1
go: finding github.com/klauspost/compress v1.15.9
go: finding github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: finding golang.org/x/net v0.0.0-20220728211354-c7608f3a8462
go: finding github.com/stretchr/testify v1.7.1
go: finding github.com/brianvoe/gofakeit/v6 v6.17.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
ok      github.com/ostafen/clover/v2    21.626s
?       github.com/ostafen/clover/v2/examples/collections       [no test files]
?       github.com/ostafen/clover/v2/examples/import-export     [no test files]
?       github.com/ostafen/clover/v2/examples/insert    [no test files]
?       github.com/ostafen/clover/v2/examples/sort      [no test files]
?       github.com/ostafen/clover/v2/examples/update    [no test files]
ok      github.com/ostafen/clover/v2/internal   0.809s
?       github.com/ostafen/clover/v2/util       [no test files]

<!-- gh-comment-id:1206363486 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): @ostafen ``` top - 13:48:47 up 43 days, 15:43, 2 users, load average: 1.17, 0.44, 0.24 Tasks: 170 total, 1 running, 169 sleeping, 0 stopped, 0 zombie %Cpu(s): 2.0 us, 1.0 sy, 0.0 ni, 96.9 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 3936.1 total, 345.1 free, 797.6 used, 2793.4 buff/cache MiB Swap: 5160.0 total, 4720.1 free, 439.9 used. 2711.6 avail Mem ``` ``` go test ./... go: downloading github.com/google/orderedcode v0.0.1 go: downloading github.com/vmihailenco/msgpack/v5 v5.3.5 go: downloading github.com/dgraph-io/badger/v3 v3.2103.2 go: downloading github.com/stretchr/testify v1.7.1 go: downloading github.com/satori/go.uuid v1.2.0 go: downloading github.com/brianvoe/gofakeit/v6 v6.17.0 go: extracting github.com/vmihailenco/msgpack/v5 v5.3.5 go: extracting github.com/satori/go.uuid v1.2.0 go: extracting github.com/stretchr/testify v1.7.1 go: downloading github.com/vmihailenco/tagparser/v2 v2.0.0 go: extracting github.com/google/orderedcode v0.0.1 go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c go: downloading github.com/davecgh/go-spew v1.1.1 go: downloading github.com/pmezard/go-difflib v1.0.0 go: extracting github.com/vmihailenco/tagparser/v2 v2.0.0 go: extracting github.com/pmezard/go-difflib v1.0.0 go: extracting github.com/davecgh/go-spew v1.1.1 go: extracting gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c go: extracting github.com/brianvoe/gofakeit/v6 v6.17.0 go: extracting github.com/dgraph-io/badger/v3 v3.2103.2 go: downloading github.com/pkg/errors v0.9.1 go: downloading github.com/dustin/go-humanize v1.0.0 go: downloading golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 go: downloading github.com/google/flatbuffers v2.0.6+incompatible go: downloading github.com/dgraph-io/ristretto v0.1.0 go: downloading github.com/gogo/protobuf v1.3.2 go: downloading go.opencensus.io v0.23.0 go: downloading github.com/golang/protobuf v1.5.2 go: downloading github.com/klauspost/compress v1.15.9 go: extracting github.com/pkg/errors v0.9.1 go: extracting github.com/dustin/go-humanize v1.0.0 go: downloading github.com/golang/snappy v0.0.4 go: downloading golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 go: extracting go.opencensus.io v0.23.0 go: extracting github.com/golang/snappy v0.0.4 go: extracting github.com/golang/protobuf v1.5.2 go: downloading github.com/cespare/xxhash v1.1.0 go: extracting github.com/dgraph-io/ristretto v0.1.0 go: downloading github.com/golang/glog v1.0.0 go: extracting github.com/cespare/xxhash v1.1.0 go: downloading github.com/cespare/xxhash/v2 v2.1.2 go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da go: extracting github.com/golang/glog v1.0.0 go: extracting github.com/cespare/xxhash/v2 v2.1.2 go: extracting github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da go: downloading google.golang.org/protobuf v1.28.1 go: extracting golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 go: extracting github.com/google/flatbuffers v2.0.6+incompatible go: extracting golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 go: extracting google.golang.org/protobuf v1.28.1 go: extracting github.com/gogo/protobuf v1.3.2 go: extracting github.com/klauspost/compress v1.15.9 go: finding github.com/dgraph-io/badger/v3 v3.2103.2 go: finding github.com/google/orderedcode v0.0.1 go: finding github.com/satori/go.uuid v1.2.0 go: finding github.com/vmihailenco/msgpack/v5 v5.3.5 go: finding github.com/dgraph-io/ristretto v0.1.0 go: finding github.com/gogo/protobuf v1.3.2 go: finding github.com/vmihailenco/tagparser/v2 v2.0.0 go: finding github.com/cespare/xxhash v1.1.0 go: finding github.com/dustin/go-humanize v1.0.0 go: finding github.com/pkg/errors v0.9.1 go: finding github.com/golang/protobuf v1.5.2 go: finding github.com/cespare/xxhash/v2 v2.1.2 go: finding github.com/google/flatbuffers v2.0.6+incompatible go: finding github.com/golang/glog v1.0.0 go: finding go.opencensus.io v0.23.0 go: finding github.com/golang/snappy v0.0.4 go: finding golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 go: finding google.golang.org/protobuf v1.28.1 go: finding github.com/klauspost/compress v1.15.9 go: finding github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da go: finding golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 go: finding github.com/stretchr/testify v1.7.1 go: finding github.com/brianvoe/gofakeit/v6 v6.17.0 go: finding github.com/davecgh/go-spew v1.1.1 go: finding github.com/pmezard/go-difflib v1.0.0 go: finding gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c ok github.com/ostafen/clover/v2 21.626s ? github.com/ostafen/clover/v2/examples/collections [no test files] ? github.com/ostafen/clover/v2/examples/import-export [no test files] ? github.com/ostafen/clover/v2/examples/insert [no test files] ? github.com/ostafen/clover/v2/examples/sort [no test files] ? github.com/ostafen/clover/v2/examples/update [no test files] ok github.com/ostafen/clover/v2/internal 0.809s ? github.com/ostafen/clover/v2/util [no test files] ```
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

@sandervanzutphen That seemed to pass all tests. Can you please run the storage tests for Mailpit (check out Mailpit, and run go test ./storage -v in the mailpit directory)?

<!-- gh-comment-id:1206386827 --> @axllent commented on GitHub (Aug 5, 2022): @sandervanzutphen That seemed to pass all tests. Can you please run the storage tests for Mailpit (check out Mailpit, and run `go test ./storage -v` in the mailpit directory)?
Author
Owner

@sandervanzutphen commented on GitHub (Aug 5, 2022):

go test ./storage -v
../../go/pkg/mod/github.com/mattn/go-runewidth@v0.0.13/runewidth.go:6:2: found packages uniseg (doc.go) and main (gen_breaktest.go) in /home/*****/go/pkg/mod/github.com/rivo/uniseg@v0.3.1

<!-- gh-comment-id:1206391953 --> @sandervanzutphen commented on GitHub (Aug 5, 2022): ``` go test ./storage -v ../../go/pkg/mod/github.com/mattn/go-runewidth@v0.0.13/runewidth.go:6:2: found packages uniseg (doc.go) and main (gen_breaktest.go) in /home/*****/go/pkg/mod/github.com/rivo/uniseg@v0.3.1 ```
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

Oh damn, I forgot you can't test Mailpit with your version of Go (default is v1.13 on Ubuntu, this project requires v1.18). Thanks anyway for trying. OK, at this stage I still have absolutely no idea what is going wrong, I'm really sorry but it's past midnight so I'll have to think about it more tomorrow. Maybe ostafen has some other ideas in the meantime, but right now I need some sleep :)

<!-- gh-comment-id:1206403278 --> @axllent commented on GitHub (Aug 5, 2022): Oh damn, I forgot you can't test Mailpit with your version of Go (default is v1.13 on Ubuntu, this project requires v1.18). Thanks anyway for trying. OK, at this stage I still have absolutely no idea what is going wrong, I'm really sorry but it's past midnight so I'll have to think about it more tomorrow. Maybe ostafen has some other ideas in the meantime, but right now I need some sleep :)
Author
Owner

@ostafen commented on GitHub (Aug 5, 2022):

@axllent, @sandervanzutphen, unfortunately I'm not able to currently reproduce this problem on my machine. Emails are displayed correctly

<!-- gh-comment-id:1206427317 --> @ostafen commented on GitHub (Aug 5, 2022): @axllent, @sandervanzutphen, unfortunately I'm not able to currently reproduce this problem on my machine. Emails are displayed correctly
Author
Owner

@axllent commented on GitHub (Aug 7, 2022):

@sandervanzutphen I also cannot reproduce this issue at all. I have tried multiple things today, including sending well over 300,000 emails (over 10GB of data) several times to Mailpit (running the release binary), and I haven't had any issues at all, even after a restart. I'm almost out of ideas here. What method are you using to send those emails to Mailpit?

<!-- gh-comment-id:1207363230 --> @axllent commented on GitHub (Aug 7, 2022): @sandervanzutphen I also cannot reproduce this issue at all. I have tried multiple things today, including sending well over 300,000 emails (over 10GB of data) several times to Mailpit (running the release binary), and I haven't had any issues at all, even after a restart. I'm almost out of ideas here. What method are you using to send those emails to Mailpit?
Author
Owner

@ostafen commented on GitHub (Aug 7, 2022):

@axllent, @sandervanzutphen Also tested on a VM with 2GB of RAM, running ubuntu 20. All is working fine.
@sandervanzutphen If you could give us specific instruction on setting up a VM environment identical to your one, it could be of help

<!-- gh-comment-id:1207370504 --> @ostafen commented on GitHub (Aug 7, 2022): @axllent, @sandervanzutphen Also tested on a VM with 2GB of RAM, running ubuntu 20. All is working fine. @sandervanzutphen If you could give us specific instruction on setting up a VM environment identical to your one, it could be of help
Author
Owner

@axllent commented on GitHub (Aug 30, 2022):

@sandervanzutphen I have just released a beta version which I believe will solve your problem, as the new application/database memory requirements are now fraction of what it used to be (documented in #10). Please let me know if this solves your issue?

@ostafen I have to say that I feel really guilty switching to SQLite, especially because of all the help and support you have provided me with CloverDB (thank you so much again!). I still think CloverDB is a really awesome idea, however in the end BadgerDB turned out to be far more hungry for RAM than I was expecting, which isn't a good fit for Mailpit. We use Mailpit for email testing in different self-contained development environments (docker), which, when running 6 or 8 containers at the same time, just wasn't feasible considering Badger requires 50-125 times more RAM than SQLite. An active instance of Mailpit now uses between 8-20MB of RAM in total.

<!-- gh-comment-id:1231557849 --> @axllent commented on GitHub (Aug 30, 2022): @sandervanzutphen I have just released a [beta version](https://github.com/axllent/mailpit/releases/tag/1.0.0-beta1) which I believe will solve your problem, as the new application/database memory requirements are now fraction of what it used to be (documented in #10). Please let me know if this solves your issue? @ostafen I have to say that I feel really guilty switching to SQLite, especially because of all the help and support you have provided me with CloverDB (thank you so much again!). I still think CloverDB is a really awesome idea, however in the end BadgerDB turned out to be **far** more hungry for RAM than I was expecting, which isn't a good fit for Mailpit. We use Mailpit for email testing in different self-contained development environments (docker), which, when running 6 or 8 containers at the same time, just wasn't feasible considering Badger requires 50-125 times more RAM than SQLite. An active instance of Mailpit now uses between 8-20MB of RAM in total.
Author
Owner

@ostafen commented on GitHub (Oct 4, 2022):

@axllent Sorry for the late response, but I've been very busy in the last months. I completely agree your choice. Your experience also convinced me that BadgerDB is not the perfect storage backend for clover. It is not the first time that a clover user complains about db size and memory usage. Considering that clover has been developed for simple embedded projects, this is a severe drawback. This is why I'm going to switch to bbolt, which looks like a better option. I would be happy if you'll consider switching again to clover in future, once these issues are fixed :)

<!-- gh-comment-id:1266817165 --> @ostafen commented on GitHub (Oct 4, 2022): @axllent Sorry for the late response, but I've been very busy in the last months. I completely agree your choice. Your experience also convinced me that **BadgerDB** is not the perfect storage backend for **clover**. It is not the first time that a clover user complains about db size and memory usage. Considering that clover has been developed for simple embedded projects, this is a severe drawback. This is why I'm going to switch to **[bbolt](https://github.com/etcd-io/bbolt)**, which looks like a better option. I would be happy if you'll consider switching again to clover in future, once these issues are fixed :)
Author
Owner

@axllent commented on GitHub (Oct 5, 2022):

@ostafen thanks for the reply (I thought you were ignoring me :)). I agree with your thinking - CloverDB as a lightweight embedded database isn't lightweight at all due to BadgerDB's requirements. Assuming that bbolt is in fact lightweight, I think something like that would be a very good move for CloverDB.

Whilst I would love to say I'll switch to the new CloverDB (once released), I can't and I won't unfortunately. One major database change is already one more than I like, and SQLite is working exceptionally well for this purpose, and provides additional features which are now part of the core search / filtering in Mailpit. That doesn't mean I won't seriously consider using CloverDB for future projects though (I develop quite a bit of software)!

Just a thought, but depending on your target audience/use database size, you may also want to consider at least looking whether SQLite could potentially serve as your backend database instead of bbolt (I'm using this native go version of SQLite in Mailpit). It is not quite as full-featured as the official SQLite, however I do not think that CloverDB would require any of that missing functionality anyway. It is pretty fast & very lightweight, and CloverDB just acts as a layer on top of it anyway. It may not have the same OS/arch support as bbolt though (but all the main ones are covered). If you did decide to try it and have questions (that I can help with), the you can just reach out to me directly via email (axllent @ gmail) - or just tag me in something.

I'll close this issue now as I'm not getting a response from @sandervanzutphen (I think he's moved on / given up), and this conversation is leading far from the original issue, and I believe it was fully resolved quite a while ago ;-)

<!-- gh-comment-id:1267913171 --> @axllent commented on GitHub (Oct 5, 2022): @ostafen thanks for the reply (I thought you were ignoring me :)). I agree with your thinking - CloverDB as a lightweight embedded database isn't lightweight at all due to BadgerDB's requirements. Assuming that bbolt is in fact lightweight, I think something like that would be a very good move for CloverDB. Whilst I would love to say I'll switch to the new CloverDB (once released), I can't and I won't unfortunately. One major database change is already one more than I like, and SQLite is working exceptionally well for this purpose, and provides additional features which are now part of the core search / filtering in Mailpit. That doesn't mean I won't seriously consider using CloverDB for future projects though (I develop quite a bit of software)! Just a thought, but depending on your target audience/use database size, you may also want to consider at least looking whether SQLite could potentially serve as your backend database instead of bbolt (I'm using [this native go version](https://gitlab.com/cznic/sqlite) of SQLite in Mailpit). It is not quite as full-featured as the official SQLite, however I do not think that CloverDB would require any of that missing functionality anyway. It is pretty fast & very lightweight, and CloverDB just acts as a layer on top of it anyway. It may not have the same [OS/arch support](https://pkg.go.dev/modernc.org/sqlite#hdr-Supported_platforms_and_architectures) as bbolt though (but all the main ones are covered). If you did decide to try it and have questions (that I can help with), the you can just reach out to me directly via email (axllent @ gmail) - or just tag me in something. I'll close this issue now as I'm not getting a response from @sandervanzutphen (I think he's moved on / given up), and this conversation is leading far from the original issue, and I believe it was fully resolved quite a while ago ;-)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#3
No description provided.