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

Corrupt database caused by server crash without saving data properly #126

Closed
nonfreegithub opened this issue Dec 13, 2023 · 6 comments · Fixed by #143
Closed

Corrupt database caused by server crash without saving data properly #126

nonfreegithub opened this issue Dec 13, 2023 · 6 comments · Fixed by #143
Labels
Bug Something isn't working Release blocker No release until this is closed
Milestone

Comments

@nonfreegithub
Copy link
Contributor

When I receive more than 1 email, all of these appear in my inbox, but I can only read one of them, when I try to read another, the email body of the first one that I opened appears as the email body of all the other emails

example:

I receive 3 different emails from 3 different people with different subjects:

  • mail 1 body: 1
  • mail 2 body: 2
  • mail 3 body: 3

If I open mail 1, in the formspec GUI I read the body of mail 1.
Now I open mail 2, and I see the body of mail 1.

If I restart the server, and check my inbox, I only see 1 email (mail 1), the others have disappeared!

I suspect this is because the database (pgsql mod storage) is corrupt, probably due to a forced restart of the server (for reasons unrelated to this mod) where the data was not saved correctly.

I assume there will be a lua table with some corrupted element:

local mails_table = {}

mails_table[1] = "mail1"
mails_table[2] = "mail2"
--mails_table[3] = "mail3" -- was corrupt, probably due to a forced restart of the server where the data was not saved correctly.
mails_table[4] = "mail4"
mails_table[5] = "mail5"

This is an example that I don't know if it helps or confuses.

In summary, I think that my email database in the mod storage is corrupted for reasons unrelated to this mod, and I think it could be fixed by adding something to the mod code without needing to delete my corrupt database

@Athozus
Copy link
Member

Athozus commented Dec 13, 2023

That might be the 1 second storage update. @Bastrabun noticed an equivalent bug in #122 , with some different initial conditions. Thanks for giving a lot of information. I consider both issue as not the same, however my upcoming fix will probably fix both.

@BuckarooBanzay
Copy link
Member

I suspect this is because the database (pgsql mod storage) is corrupt

somehow i doubt that 🤔 can you extract the relevant data from the database and post it here if possible?

@BuckarooBanzay BuckarooBanzay added the Bug Something isn't working label Dec 14, 2023
@nonfreegithub
Copy link
Contributor Author

nonfreegithub commented Dec 14, 2023

can you extract the relevant data from the database and post it here if possible?

I could spend some time studying my database and separating what information could be relevant or not, I would have to learn to do that and how this mod stores the information in the database to know where and how to locate it.

I think it would take a lot of time

@BuckarooBanzay
Copy link
Member

Maybe I could spend some time studying my database and separating what information could be relevant or not

someone else did the work for you:

# extract the json-value for the mail-entry in the modstorage
sqlite3 mod_storage.sqlite "select value from entries where modname = 'mail' and key = cast('mail/BuckarooBanzai' as blob);"

# (optional, but looks prettier) parse the output with `jq`
sqlite3 mod_storage.sqlite "select value from entries where modname = 'mail' and key = cast('mail/BuckarooBanzai' as blob);" | jq

@nonfreegithub
Copy link
Contributor Author

sqlite3 mod_storage.sqlite "select value from entries where modname = 'mail' and key = cast('mail/BuckarooBanzai' as blob);"

nice! how can I do for postgresql?

@BuckarooBanzay
Copy link
Member

nice! how can I do for postgresql?

right, i forgot this is possible now, here you go:

select convert_from(value, 'utf-8') from mod_storage where modname = 'mail' and key = 'mail/BuckarooBanzai';

@Athozus Athozus added this to the 1.4.0 milestone Dec 16, 2023
@Athozus Athozus pinned this issue Dec 17, 2023
@Athozus Athozus added the Release blocker No release until this is closed label Dec 26, 2023
@Athozus Athozus linked a pull request Apr 1, 2024 that will close this issue
@Athozus Athozus unpinned this issue Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Release blocker No release until this is closed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants