[PR #986] [MERGED] Try to fix sporadic exceptions from SQLite (Error 5: 'database is locked') #994

Closed
opened 2026-02-15 15:57:26 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/RPCS3/discord-bot/pull/986
Author: @13xforever
Created: 3/27/2025
Status: Merged
Merged: 3/27/2025
Merged by: @13xforever

Base: masterHead: vnext


📝 Commits (6)

  • 55f4545 use read/write locking for sqlite to fix Error 5: 'database is locked'
  • 5ef4301 more ValueTask updates
  • 4cc1bbd try to reduce write lock situations
  • 87ce974 try to return game updates from cache when possible
  • 1a9359d switch to AsyncReadWriteLock to support async/await
  • 756c4f6 fix deadlock on botdb

📊 Changes

64 files changed (+546 additions, -335 deletions)

View changed files

📝 CompatBot/Commands/Audit.cs (+3 -2)
📝 CompatBot/Commands/AutoCompleteProviders/BotConfigurationAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/AutoCompleteProviders/ContentFilterAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/AutoCompleteProviders/EventIdAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/AutoCompleteProviders/EventNameAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/AutoCompleteProviders/ExplainAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/AutoCompleteProviders/InviteAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/AutoCompleteProviders/ProductCodeAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/AutoCompleteProviders/WarningAutoCompleteProvider.cs (+1 -1)
📝 CompatBot/Commands/Bot.Configuration.cs (+3 -3)
📝 CompatBot/Commands/Bot.Import.cs (+1 -1)
📝 CompatBot/Commands/Bot.cs (+5 -5)
📝 CompatBot/Commands/BotStatus.cs (+25 -20)
📝 CompatBot/Commands/CommandsManagement.cs (+12 -12)
📝 CompatBot/Commands/CompatList.Latest.cs (+1 -1)
📝 CompatBot/Commands/CompatList.Top.cs (+1 -1)
📝 CompatBot/Commands/CompatList.cs (+9 -8)
📝 CompatBot/Commands/ContentFilters.cs (+6 -6)
📝 CompatBot/Commands/Events.cs (+8 -8)
📝 CompatBot/Commands/Explain.cs (+6 -6)

...and 44 more files

📄 Description

Apparently this happens when read transaction got started as read-only, but then failed to be promoted to write because there was another write in the meantime.

Tracking issue on dotnet/efcore#29514.

So, try to separate reads/writes with a read/write lock per database.
As part of this effort there's been a lot of async code clean up, with some logic and resource management fixes, as well as further switch to ValueTask wherever possible.

Also, game updates are now returned from bot's cache when possible (refreshed once a day if needed).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/RPCS3/discord-bot/pull/986 **Author:** [@13xforever](https://github.com/13xforever) **Created:** 3/27/2025 **Status:** ✅ Merged **Merged:** 3/27/2025 **Merged by:** [@13xforever](https://github.com/13xforever) **Base:** `master` ← **Head:** `vnext` --- ### 📝 Commits (6) - [`55f4545`](https://github.com/RPCS3/discord-bot/commit/55f45457a2f8662ddb95025863de20b58ffe4393) use read/write locking for sqlite to fix Error 5: 'database is locked' - [`5ef4301`](https://github.com/RPCS3/discord-bot/commit/5ef4301bd17fd859f99deed3c720308402bde156) more ValueTask updates - [`4cc1bbd`](https://github.com/RPCS3/discord-bot/commit/4cc1bbd234a021c2e80099f2d312561fc6f615dd) try to reduce write lock situations - [`87ce974`](https://github.com/RPCS3/discord-bot/commit/87ce97450675d742bee535170964f6ed3671e19f) try to return game updates from cache when possible - [`1a9359d`](https://github.com/RPCS3/discord-bot/commit/1a9359d86311ac34842179f6ae75b55a9ba7ee34) switch to AsyncReadWriteLock to support async/await - [`756c4f6`](https://github.com/RPCS3/discord-bot/commit/756c4f6a9f27774bd0ea74296de78972a977d7f0) fix deadlock on botdb ### 📊 Changes **64 files changed** (+546 additions, -335 deletions) <details> <summary>View changed files</summary> 📝 `CompatBot/Commands/Audit.cs` (+3 -2) 📝 `CompatBot/Commands/AutoCompleteProviders/BotConfigurationAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/AutoCompleteProviders/ContentFilterAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/AutoCompleteProviders/EventIdAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/AutoCompleteProviders/EventNameAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/AutoCompleteProviders/ExplainAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/AutoCompleteProviders/InviteAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/AutoCompleteProviders/ProductCodeAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/AutoCompleteProviders/WarningAutoCompleteProvider.cs` (+1 -1) 📝 `CompatBot/Commands/Bot.Configuration.cs` (+3 -3) 📝 `CompatBot/Commands/Bot.Import.cs` (+1 -1) 📝 `CompatBot/Commands/Bot.cs` (+5 -5) 📝 `CompatBot/Commands/BotStatus.cs` (+25 -20) 📝 `CompatBot/Commands/CommandsManagement.cs` (+12 -12) 📝 `CompatBot/Commands/CompatList.Latest.cs` (+1 -1) 📝 `CompatBot/Commands/CompatList.Top.cs` (+1 -1) 📝 `CompatBot/Commands/CompatList.cs` (+9 -8) 📝 `CompatBot/Commands/ContentFilters.cs` (+6 -6) 📝 `CompatBot/Commands/Events.cs` (+8 -8) 📝 `CompatBot/Commands/Explain.cs` (+6 -6) _...and 44 more files_ </details> ### 📄 Description Apparently this happens when read transaction got started as read-only, but then failed to be promoted to write because there was another write in the meantime. Tracking issue on dotnet/efcore#29514. So, try to separate reads/writes with a read/write lock per database. As part of this effort there's been a lot of async code clean up, with some logic and resource management fixes, as well as further switch to `ValueTask` wherever possible. Also, game updates are now returned from bot's cache when possible (refreshed once a day if needed). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 15:57:26 -05:00
yindo closed this issue 2026-02-15 15:57:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: RPCS3/discord-bot#994