Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ Legend:
? = Other stuff
```

(29/10/26): Version 2.2.10-srcdslab
-----------------------
```
01. + sbpp_main no longer re-sets the database charset (a blocking
round trip on the main thread) on every admin cache rebuild;
it is set once per connection

(29/10/26): Version 2.2.9-srcdslab
-----------------------
```
Expand Down
25 changes: 16 additions & 9 deletions game/addons/sourcemod/scripting/sbpp_main.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,18 +1177,25 @@ public void GotDatabase(Database db, const char[] error, any data)
return;
}

DB = db;

char query[1024];

// Set character set to UTF8MB4 in the database
// Use SetCharset to ensure charset is set synchronously before any operations
if (!DB.SetCharset("utf8mb4"))
// OnRebuildAdminCache() calls this again with the current handle for every cache part.
// Only a new connection needs its charset set: SetCharset() is a blocking round trip on
// the main thread that also waits for any threaded query in flight, and the charset it
// sets stays on the handle (also across the driver's automatic reconnects).
if (db != DB)
{
LogToFile(logFile, "Failed to set database charset to utf8mb4, trying async method");
// Fallback to async method
Format(query, sizeof(query), "SET NAMES utf8mb4");
DB.Query(ErrorCheckCallback, query);
DB = db;

// Set character set to UTF8MB4 in the database
// Use SetCharset to ensure charset is set synchronously before any operations
if (!DB.SetCharset("utf8mb4"))
{
LogToFile(logFile, "Failed to set database charset to utf8mb4, trying async method");
// Fallback to async method
Format(query, sizeof(query), "SET NAMES utf8mb4");
DB.Query(ErrorCheckCallback, query);
}
}

// The database can be ready before the first ReadConfig() (OnMapStart), and every
Expand Down