trakman icon indicating copy to clipboard operation
trakman copied to clipboard

fatal error: duplicate key value violates unique constraint "maps_pkey"

Open Skorlok opened this issue 11 months ago • 5 comments

Hi, i'm having some issues with one of my servers running trakman 1.6.0

<FATAL> [24 Dec 2024 01:55:51] (Logger.js:85) Unhandled rejection occured: 
	duplicate key value violates unique constraint "maps_pkey"
	error: duplicate key value violates unique constraint "maps_pkey"
	    at Parser.parseErrorMessage (/app/controller/node_modules/pg-protocol/dist/parser.js:283:98)
	    at Parser.handlePacket (/app/controller/node_modules/pg-protocol/dist/parser.js:122:29)
	    at Parser.parse (/app/controller/node_modules/pg-protocol/dist/parser.js:35:38)
	    at Socket.<anonymous> (/app/controller/node_modules/pg-protocol/dist/index.js:11:42)
	    at Socket.emit (node:events:518:28)
	    at addChunk (node:internal/streams/readable:561:12)
	    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
	    at Readable.push (node:internal/streams/readable:392:5)
	    at TCP.onStreamRead (node:internal/stream_base_commons:189:23)

this error is happening at every new map at the "Play" event

as this issue seems related to a duplicated map in the database I search it and found nothing

skservertmu=# \d
                   List of relations
 Schema |          Name           |   Type   |  Owner   
--------+-------------------------+----------+----------
 public | banlist                 | table    | postgres
 public | best_checkpoint_records | table    | postgres
 public | best_sector_records     | table    | postgres
 public | blacklist               | table    | postgres
 public | chat                    | table    | postgres
 public | checkpoint_records      | table    | postgres
 public | donations               | table    | postgres
 public | guestlist               | table    | postgres
 public | map_ids                 | table    | postgres
 public | map_ids_id_seq          | sequence | postgres
 public | maps                    | table    | postgres
 public | mutelist                | table    | postgres
 public | players                 | table    | postgres
 public | players_id_seq          | sequence | postgres
 public | privileges              | table    | postgres
 public | records                 | table    | postgres
 public | records_multilap        | table    | postgres
 public | sector_records          | table    | postgres
 public | votes                   | table    | postgres
(19 rows)

skservertmu=# SELECT uid, COUNT(*) FROM map_ids GROUP BY uid HAVING COUNT(*) > 1;
 uid | count 
-----+-------
(0 rows)

skservertmu=# SELECT id, COUNT(*) FROM map_ids GROUP BY id HAVING COUNT(*) > 1;
 id | count 
----+-------
(0 rows)

skservertmu=# SELECT id, COUNT(*) FROM maps GROUP BY id HAVING COUNT(*) > 1;
 id | count 
----+-------
(0 rows)

If you have a solution I take because the controller is restarting at every new map

Skorlok avatar Dec 24 '24 02:12 Skorlok

Theres no duplicates in the database because table constraints prevent the map from being added, so controller basically thinks the map is not in db but it is for some reason. This kinda stuff happening on every play event is really weird. Are you using manualMapLoading (its disabled by default)? Were there any errors in the log prior to the fatal error?

lythx avatar Dec 27 '24 08:12 lythx

image I use the updateMatchSettingsOnChange: true but not the manual map loading (I presume it's the infinite map mode)

Skorlok avatar Jan 02 '25 13:01 Skorlok

have you tried the same on an empty db?

wsrvn avatar Jan 06 '25 20:01 wsrvn

it works one time when deleting everything from maps, but after restarting it breaks again

Skorlok avatar Jan 17 '25 20:01 Skorlok

TMUF.tar.gz here is a backup of my server (personal info removed), it crashs on empty new database

Skorlok avatar Jan 17 '25 21:01 Skorlok

I fixed it myself by removing A1, A2 and B3

Skorlok avatar Oct 26 '25 00:10 Skorlok