b310-digital / teammapper

Mindmapping made simple: Host and create your own mindmaps. Share your mindmap sessions with your team and collaborate on mindmaps.
https://teammapper.org
MIT License
264 stars 21 forks source link

bug: investigate why addNodes method often throws FK violations #457

Open JannikStreek opened 2 months ago

JannikStreek commented 2 months ago

Describe the bug Method addNodes in maps.service.ts:

[Nest] 54  - 09/13/2024, 6:20:04 AM   ERROR [WsExceptionsHandler] insert or update on table "mmp_node" violates foreign key constraint "FK_336300b82c56a05f0317f229420"
2024-09-13 08:20:03.972 
    at async MapsService.updateMap (/home/node/app/teammapper-backend/src/map/services/maps.service.ts:176:5)
2024-09-13 08:20:03.972 
    at async MapsService.addNodesFromClient (/home/node/app/teammapper-backend/src/map/services/maps.service.ts:80:12)
2024-09-13 08:20:03.972 
    at async reducer (/home/node/app/teammapper-backend/src/map/services/maps.service.ts:93:31)
2024-09-13 08:20:03.972 
    at async reducer (/home/node/app/teammapper-backend/src/map/services/maps.service.ts:95:40)

This method is called for pasting and importing a whole map. Investigate possible causes. Potential problems could be multiple concurrent json imports and a race condition, or the paste/cut functions.

Possible solutions Importing a map should be a mutual exclusive operation, therefore, the map should be locked during this time. We could kill all socket connections to the map before and then do the import. And reload after the import is finished on the client side.

sorenjohanson commented 2 months ago

It's used when importing, copy/pasting but also when duplicating the map. Tried to reproduce with 3 clients, but I never managed to get this error even once. Maybe this'll be fixed once we merge #467.