ericberman / MyFlightbookWeb

The website and service for MyFlightbook
49 stars 18 forks source link

Crash - FK constraint deleting a flight with telemetry #1074

Closed ericberman closed 1 year ago

ericberman commented 1 year ago

Exception moving telemetry for flight 18491444

Message: Exception DoNonQuery: Code = -2147467259 Cannot add or update a child row: a foreign key constraint fails (logbook.flighttelemetry, CONSTRAINT idflighttelemetry FOREIGN KEY (idFlight) REFERENCES flights (idFlight) ON DELETE CASCADE) REPLACE INTO flighttelemetry SET idflight=?idf, distance=?d, flightpath=?path, telemetrytype=?tt, metadata=?md Source: MyFlightbook.Web Target site Boolean DoNonQuery(MyFlightbook.DBHelperCommandArgs, System.Action`1[MySql.Data.MySqlClient.MySqlCommand])

Stack trace: at MyFlightbook.DBHelper.DoNonQuery(DBHelperCommandArgs args, Action1 initCommand) in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Utility\DBHelper.cs:line 320 at MyFlightbook.DBHelper.DoNonQuery(Action1 initCommand) in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Utility\DBHelper.cs:line 345 at MyFlightbook.Telemetry.TelemetryReference.Commit() in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Places\FlightData.cs:line 1818 at MyFlightbook.LogbookEntryBase.MoveTelemetryFromFlightEntry() in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Flights\LogbookEntry.cs:line 2179 at MyFlightbook.LogbookEntryBase.b__92_0() in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Flights\LogbookEntry.cs:line 1701OverallData: MyFlightbook.MyFlightbookException: Exception DoNonQuery: Code = -2147467259 Cannot add or update a child row: a foreign key constraint fails (logbook.flighttelemetry, CONSTRAINT idflighttelemetry FOREIGN KEY (idFlight) REFERENCES flights (idFlight) ON DELETE CASCADE) REPLACE INTO flighttelemetry SET idflight=?idf, distance=?d, flightpath=?path, telemetrytype=?tt, metadata=?md ---> MySql.Data.MySqlClient.MySqlException: Cannot add or update a child row: a foreign key constraint fails (logbook.flighttelemetry, CONSTRAINT idflighttelemetry FOREIGN KEY (idFlight) REFERENCES flights (idFlight) ON DELETE CASCADE) at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() at MyFlightbook.DBHelper.DoNonQuery(DBHelperCommandArgs args, Action1 initCommand) in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Utility\DBHelper.cs:line 312 --- End of inner exception stack trace --- at MyFlightbook.DBHelper.DoNonQuery(DBHelperCommandArgs args, Action1 initCommand) in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Utility\DBHelper.cs:line 320 at MyFlightbook.DBHelper.DoNonQuery(Action`1 initCommand) in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Utility\DBHelper.cs:line 345 at MyFlightbook.Telemetry.TelemetryReference.Commit() in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Places\FlightData.cs:line 1818 at MyFlightbook.LogbookEntryBase.MoveTelemetryFromFlightEntry() in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Flights\LogbookEntry.cs:line 2179 at MyFlightbook.LogbookEntryBase.b__92_0() in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Flights\LogbookEntry.cs:line 1701

Occured at: 03/20/2023 16:16:11 (UTC)

Moving to next exception down...

Message: Cannot add or update a child row: a foreign key constraint fails (logbook.flighttelemetry, CONSTRAINT idflighttelemetry FOREIGN KEY (idFlight) REFERENCES flights (idFlight) ON DELETE CASCADE) Source: MySql.Data Target site MySql.Data.MySqlClient.MySqlPacket ReadPacket()

Stack trace: at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() at MyFlightbook.DBHelper.DoNonQuery(DBHelperCommandArgs args, Action1 initCommand) in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Utility\DBHelper.cs:line 312OverallData: MySql.Data.MySqlClient.MySqlException (0x80004005): Cannot add or update a child row: a foreign key constraint fails (logbook.flighttelemetry, CONSTRAINTidflighttelemetryFOREIGN KEY (idFlight) REFERENCESflights(idFlight) ON DELETE CASCADE) at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() at MyFlightbook.DBHelper.DoNonQuery(DBHelperCommandArgs args, Action1 initCommand) in C:\Users\ericb\GitHub\MyFlightbookWeb\MyFlightbook.Web\AppCode\Utility\DBHelper.cs:line 312

Data key Server Error Code: 1452

Occured at: 03/20/2023 16:16:11 (UTC)

Moving to next exception down...

ericberman commented 1 year ago

Huh, now not happening. Not sure why this would ever violate the fK constraint