ibp-network / ibp-monitor

15 stars 10 forks source link

Error related to gossip messages from unregistered monitors #44

Closed paulormart closed 1 year ago

paulormart commented 1 year ago

My ibp-monitor with id 12D3KooWQv2KCogXS3qmJL1ND1gPMzmRwiGAtEAEsMSMmW4G9L4c doesn't have the monitorId 12D3KooWEhSdbKnDJ4T8Gu57fcqrMyRyHQwh5FkcJ6P9ryi55j1G registered.

When gossip messages arrive from unregistered monitors the following exception is raised:

ibp-monitor-server         | /ibp/healthCheck from 12D3K...55j1G for westmint-rpc null                                                                                                                                                                                                                                                                                      
ibp-monitor-server         | Member service not found: gatotech westmint-rpc                                                                                                                                                                                                                                                                                                
ibp-monitor-server         | /ibp/healthCheck from 12D3K...55j1G for westmint-rpc 12D3KooWDiGuSZqv1uqsJ3URodiaNriAPToi5LJEipR4XCne7pqs                                                                                                                                                                                                                                      
ibp-monitor-server         | node:internal/event_target:1011                                                                                                                                                                                                                                                                                                                
ibp-monitor-server         |   process.nextTick(() => { throw err; });                                                                                                                                                                                                                                                                                                      
ibp-monitor-server         |                            ^                                                                                                                                                                                                                                                                                                                   
ibp-monitor-server         |                                                                                                                                                                                                                                                                                                                                                
ibp-monitor-server         | Error                                                                                                                                                                                                                                                                                                                                          
ibp-monitor-server         |     at Query.run (/home/ibp/node_modules/sequelize/lib/dialects/mariadb/query.js:53:25)                                                                                                                                                                                                                                                        
ibp-monitor-server         |     at /home/ibp/node_modules/sequelize/lib/sequelize.js:315:28                                                                                                                                                                                                                                                                                
ibp-monitor-server         |     at processTicksAndRejections (node:internal/process/task_queues:96:5)                                                                                                                                                                                                                                                                      
ibp-monitor-server         |     at async MySQLQueryInterface.insert (/home/ibp/node_modules/sequelize/lib/dialects/abstract/query-interface.js:308:21)                                                                                                                                                                                                                     
ibp-monitor-server         |     at async model.save (/home/ibp/node_modules/sequelize/lib/model.js:2490:35)                                                                                                                                                                                                                                                                
ibp-monitor-server         |     at async Function.create (/home/ibp/node_modules/sequelize/lib/model.js:1362:12)                                                                                                                                                                                                                                                           
ibp-monitor-server         |     at async MessageHandler.handleMessage (file:///home/ibp/lib/message-handler.js:137:9)                                                                                                                                                                                                                                                      
ibp-monitor-server         |     at async EventTarget.<anonymous> (file:///home/ibp/server.js:204:5) {                                                                                                                                                                                                                                                                      
ibp-monitor-server         |   name: 'SequelizeForeignKeyConstraintError',                                                                                                                                                                                                                                                                                                  
ibp-monitor-server         |   parent: SqlError: (conn=2058, no: 1452, SQLState: 23000) Cannot add or update a child row: a foreign key constraint fails (`ibp_monitor`.`health_check`, CONSTRAINT `fk_health_check_monitor` FOREIGN KEY (`monitorId`) REFERENCES `monitor` (`id`))                                                                                         
ibp-monitor-server         |   sql: INSERT INTO `health_check` (`id`,`monitorId`,`serviceId`,`memberId`,`peerId`,`source`,`type`,`status`,`responseTimeMs`,`record`,`createdAt`) VALUES (DEFAULT,?,?,?,?,?,?,?,?,?,now()); - parameters:['12D3KooWEhSdbKnDJ4T8Gu57fcqrMyRyHQwh5FkcJ6P9ryi55j1G','wes...]                                                                    
ibp-monitor-server         |       at Object.module.exports.createError (/home/ibp/node_modules/mariadb/lib/misc/errors.js:57:10)                                                                                                                                                                                                                                           
ibp-monitor-server         |       at PacketNodeEncoded.readError (/home/ibp/node_modules/mariadb/lib/io/packet.js:572:19)                                                                                                                                                                                                                                                  
ibp-monitor-server         |       at Query.readResponsePacket (/home/ibp/node_modules/mariadb/lib/cmd/parser.js:55:28)                                                                                                                                                                                                                                                     
ibp-monitor-server         |       at PacketInputStream.receivePacketBasic (/home/ibp/node_modules/mariadb/lib/io/packet-input-stream.js:80:9)                                                                                                                                                                                                                              
ibp-monitor-server         |       at PacketInputStream.onData (/home/ibp/node_modules/mariadb/lib/io/packet-input-stream.js:130:20)                                                                                                                                                                                                                                        
ibp-monitor-server         |       at Socket.emit (node:events:513:28)                                                                                                                                                                                                                                                                                                      
ibp-monitor-server         |       at addChunk (node:internal/streams/readable:315:12)                                                                                                                                                                                                                                                                                      
ibp-monitor-server         |       at readableAddChunk (node:internal/streams/readable:289:9)                                                                                                                                                                                                                                                                               
ibp-monitor-server         |       at Socket.Readable.push (node:internal/streams/readable:228:10)                                                                                                                                                                                                                                                                          
ibp-monitor-server         |       at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {                                                                                                                                                                                                                                                                         
ibp-monitor-server         |     text: 'Cannot add or update a child row: a foreign key constraint fails (`ibp_monitor`.`health_check`, CONSTRAINT `fk_health_check_monitor` FOREIGN KEY (`monitorId`) REFERENCES `monitor` (`id`))',                                                                                                                                       
ibp-monitor-server         |     sql: 'INSERT INTO `health_check` (`id`,`monitorId`,`serviceId`,`memberId`,`peerId`,`source`,`type`,`status`,`responseTimeMs`,`record`,`createdAt`) VALUES (DEFAULT,?,?,?,?,?,?,?,?,?,now());',                                                                                                                                             
ibp-monitor-server         |     fatal: false,                                                                                                                                                                                                                                                                                                                              
ibp-monitor-server         |     errno: 1452,                                                                                                                                                                                                                                                                                                                               
ibp-monitor-server         |     sqlState: '23000',                                                                                                                                                                                                                                                                                                                         
ibp-monitor-server         |     code: 'ER_NO_REFERENCED_ROW_2',                                                                                                                                                                                                                                                                                                            
ibp-monitor-server         |     parameters: [                                                                                                                                                                                                                                                                                                                              
ibp-monitor-server         |       '12D3KooWEhSdbKnDJ4T8Gu57fcqrMyRyHQwh5FkcJ6P9ryi55j1G',                                                                                                                                                                                                                                                                                  
ibp-monitor-server         |       'westmint-rpc',                                                                                                                                                                                                                                                                                                                          
ibp-monitor-server         |       'helikon',                                                                                                                                                                                                                                                                                                                               
ibp-monitor-server         |       '12D3KooWDiGuSZqv1uqsJ3URodiaNriAPToi5LJEipR4XCne7pqs',                                                                                                                                                                                                                                                                                  
ibp-monitor-server         |       'gossip',                                                                                                                                                                                                                                                                                                                                
ibp-monitor-server         |       'service_check',                                                                                                                                                                                                                                                                                                                         
ibp-monitor-server         |       'success',                                                                                                                                                                                                                                                                                                                               
ibp-monitor-server         |       53.175424098968506,                                                                                                                                                                                                                                                                                                                      
ibp-monitor-server         |       '{"monitorId":"12D3KooWEhSdbKnDJ4T8Gu57fcqrMyRyHQwh5FkcJ6P9ryi55j1G","memberId":"helikon","serviceId":"westmint-rpc","endpoint":"wss://sys.dotters.network/westmint","ipAddress":"82.222.18.146","chain":"Westmint","chainType":{"live":null},"health":{"peers":13,"isSyncing":false,"shouldHavePeers":true},"syncState":{"startingBlock"
:4498546,"currentBlock":4548509,"highestBlock":4548509},"version":"0.9.400-269fb073caf","performance":53.175424098968506}'                                                                                                                                                                                                                                                  
ibp-monitor-server         |     ]                                                                                                                                                                                                                                                                                                                                          
ibp-monitor-server         |   },  
paulormart commented 1 year ago

fixed by #45