Reopen of #264 — still reproducible on build-1.7.9a (SQLite). Root cause identified.
Stack
System.OverflowException: Arithmetic operation resulted in an overflow.
at Deserialize<…>(DbDataReader)
at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command)
at CS2_SimpleAdmin.Managers.CacheManager.InitializeCacheAsync()
at CS2_SimpleAdmin.Managers.CacheManager.InitializeCacheAsync()
Root cause
sa_players_ips.steamid is declared INTEGER and stores SteamID64 values
(e.g. 76561197989223530), which exceeds Int32.MaxValue (2147483647).
The Dapper deserializer in CacheManager.InitializeCacheAsync maps that column
to int, so it throws OverflowException on every cache init after at least
one real player has connected and SA has written a row.
Schema (head)
CREATE TABLE sa_players_ips (
steamid INTEGER NOT NULL,
address INTEGER NOT NULL,
used_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
name VARCHAR(64),
PRIMARY KEY (steamid, address)
);
Repro
Fresh SA-managed SQLite DB:
INSERT INTO sa_players_ips
VALUES (76561197989223530, 0, CURRENT_TIMESTAMP, 'x');
Next server start → OverflowException in CacheManager.InitializeCacheAsync.
Fix
The POCO / Dapper mapping for sa_players_ips.steamid (and any other steamid
columns currently typed as int server-side) needs to be long / ulong.
Same applies to address if SA ever stores IPs with the high bit set as
unsigned — currently only IPs < 128.0.0.0 happen to fit into signed int32.
Workaround for affected users
Set "CheckMultiAccountsByIp": false in CS2-SimpleAdmin.json — this skips
the failing query path. Multi-account-by-IP detection is then disabled.
Environment
- CS2-SimpleAdmin: build-1.7.9a
- DB: SQLite
- Repro confirmed on a vanilla DB with a single connecting Steam account.
Reopen of #264 — still reproducible on build-1.7.9a (SQLite). Root cause identified.
Stack
Root cause
sa_players_ips.steamidis declaredINTEGERand stores SteamID64 values(e.g.
76561197989223530), which exceedsInt32.MaxValue(2147483647).The Dapper deserializer in
CacheManager.InitializeCacheAsyncmaps that columnto
int, so it throwsOverflowExceptionon every cache init after at leastone real player has connected and SA has written a row.
Schema (head)
Repro
Fresh SA-managed SQLite DB:
Next server start →
OverflowExceptioninCacheManager.InitializeCacheAsync.Fix
The POCO / Dapper mapping for
sa_players_ips.steamid(and any other steamidcolumns currently typed as
intserver-side) needs to belong/ulong.Same applies to
addressif SA ever stores IPs with the high bit set asunsigned — currently only IPs
< 128.0.0.0happen to fit into signed int32.Workaround for affected users
Set
"CheckMultiAccountsByIp": falseinCS2-SimpleAdmin.json— this skipsthe failing query path. Multi-account-by-IP detection is then disabled.
Environment