-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
[mailpit+rqlite] FOREIGN KEY constraint failed error on deleting messages #374
Comments
@hpoznanski I think I found the issue (assuming you are using the tenant ID option?). Could you please test using the latest |
I have released a v1.20.7 with the fix for this (I believe) so I'm closing this issue. If the problem persists then please feel free to re-open this. |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [axllent/mailpit](https://github.com/axllent/mailpit) | patch | `v1.20.6` -> `v1.20.7` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>axllent/mailpit (axllent/mailpit)</summary> ### [`v1.20.7`](https://github.com/axllent/mailpit/blob/HEAD/CHANGELOG.md#v1207) [Compare Source](axllent/mailpit@v1.20.6...v1.20.7) ##### Chore - Update caniemail database ##### Fix - SQL error deleting a tag while using tenant-id ([#​374](axllent/mailpit#374)) ##### Testing - Add tenantIDs to tests </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Same issue here. Always on GKE. Mailpit: v1.21.6 |
@matteovivona I am unable to reproduce this error, so I do not think it is actually the same issue. Can you please provide more information to help me understand the error you have, what you were trying to do at the time, the error message etc? Thanks. |
I'm trying to delete some emails, either globally or for a specific tag, but I ran into an error message about the FOREIGN KEY constraint failing. I'm not sure if this info will be useful for troubleshooting, but I have rqlite set up with 3 instances |
It actually may be useful - the fact that you have 3 instances (I assume you mean replicated?) could mean that the replicated changes are potentially happening in an unexpected order. Leave this with me and I'll see if I can work on a solution 👍 |
This doesn't really make much sense. All changes e.g. As long as you wait for the HTTP 200 from a given write request, any subsequent write will take place against a system that reflects the first write. It doesn't matter which nodes you send the write to, since all writes go through the Leader. A node will transparently redirect its write to the Leader if necessary. As for reads, just use weak consistency (the default). That way all reads will go through the Leader too, and result in generally consistent results. And, if a node receives a read request, and it's not the Leader, that node will transparently forward the request to the Leader. |
If this issue is reproducible I would try it with a single-node cluster, just to remove the clustering complexity. I'm not saying that clustering isn't an issue here (though I doubt it). This feels more like a rqlite client issue, where the client i.e. mailpit thinks it has deleted some records (deletes the wrong records, is ignoring an error from rqlite, is not waiting for a response to write request, something like that), goes to delete more, only to hit an FK constraint. But this can't be caused by some "unexpected replication" since rqlite is 100% deterministic when it comes to replicating changes across the cluster, and does do in a very robust manner. Writes are always serialized on the cluster. They cannot overlap, and are never re-ordered relative to the order in which the client sends them. |
Thanks for the clarification @otoolep - I suspected that was the case, however in saying that, the message_tags table does have two (unused) |
rqlite supports wrapping a single HTTP request in a transaction. https://rqlite.io/docs/api/api/#transactions If you are putting the "series of deletes" in such a transaction they will all succeed, or none will succeed. |
If you are doing explicit |
To give you an example. If a HTTP request , which does not set the It's safe to set the |
From my understanding the transaction would not work the way I'm using it, and that rqlite handles that as completely separate requests. Furthermore, the I suspect that the I could change the order the tables are deleted from, however the safest and best solution here would be for me to simply remove those unused |
…374) This SQL patch rebuilds the message_tags table to remove the unused ID & TagID REFERENCES that was sometimes causing FOREIGN KEY errors when deleting messages (with tags) using the rqlite database. This is not a bug in rqlite, but rather a limitation of how Mailpit integrated with rqlite as an optional alternative database.
@matteovivona I have just released v.1.21.8 with a fix for this (I'm pretty confident it will at least). I'd appreciate if you could test and report back whether it resolves your issue. Thanks again for your input @otoolep - as always appreciated to get input from the top! I realise I could go down the path to get the this transaction to work with rqlite, however this was the cleaner solution as those two REFERENCES weren't being used anyway and had the potential to cause other issues down the track. If the message deletions were being cascaded through to the message tags table (my original plan) it may have worked as originally intended, however it's a fancy feature I wasn't using. |
Ack, got it. Yes those calls probably don't do anything in the driver, since they are not supported by rqlite at this time. I have ideas, but it would be major work. |
@axllent thanks for the speed! I confirm that the patch works |
Excellent! Thanks again for bringing this to my attention @matteovivona. |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [axllent/mailpit](https://github.com/axllent/mailpit) | patch | `v1.21.6` -> `v1.21.8` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>axllent/mailpit (axllent/mailpit)</summary> ### [`v1.21.8`](https://github.com/axllent/mailpit/blob/HEAD/CHANGELOG.md#v1218) [Compare Source](axllent/mailpit@v1.21.7...v1.21.8) ##### Chore - Update node dependencies - Update Go dependencies ##### Fix - **db:** Remove unused FOREIGN KEY REFERENCES in message_tags table ([#​374](axllent/mailpit#374)) ### [`v1.21.7`](https://github.com/axllent/mailpit/blob/HEAD/CHANGELOG.md#v1217) [Compare Source](axllent/mailpit@v1.21.6...v1.21.7) ##### Chore - Update node dependencies - Update Go dependencies - Bump Go version for automated testing - Move smtpd & pop3 modules to internal - Stricter SMTP 'MAIL FROM' & 'RCPT TO' handling ([#​409](axllent/mailpit#409)) - Display "To" details in mobile messages list - Display "From" details in message sidebar (desktop) ([#​403](axllent/mailpit#403)) ##### Fix - Ignore unsupported optional SMTP 'MAIL FROM' parameters ([#​407](axllent/mailpit#407)) - Prevent splitting multi-byte characters in message snippets ([#​404](axllent/mailpit#404)) ##### Testing - Add smtpd tests </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS42NC4wIiwidXBkYXRlZEluVmVyIjoiMzkuNzUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
I've deployed mailpit on my GKE cluster with rqlitedb. Everything works fine but theres a problem after I will add tags to mail. Im not able to delete them because im getting: "FOREIGN KEY constraint failed". Im not able to remove all or even one by one.
mailpit: v1.20.6
rqlite: 8.31.2
The text was updated successfully, but these errors were encountered: