Seeding mock data into the db on subsequent docker runs results in an IntegrityError
Testing our docker dev setup (see: #79 (closed)) we can see something like
tor_weather_app_server | sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "relay_fingerprint_key"
tor_weather_app_server | DETAIL: Key (fingerprint)=(AGcueNXWPlMqgqZBuspZQRInaHtixckVWpMwylNI) already exists.
tor_weather_app_server |
tor_weather_app_server | [SQL: INSERT INTO relay (is_exit, fingerprint, first_seen, last_seen, version, recommended_version, is_up) SELECT p0::BOOLEAN, p1::VARCHAR, p2::TIMESTAMP WITHOUT TIME ZONE, p3::TIMESTAMP WITHOUT TIME ZONE, p4::VARCHAR, p5::BOOLEAN, p6::BOOLEAN FROM (VALUES ... 151131 characters truncated ... (p0, p1, p2, p3, p4, p5, p6, sen_counter) ORDER BY sen_counter RETURNING relay.id, relay.id AS id__1]
tor_weather_app_server | [parameters: {'is_up__0': False, 'first_seen__0': '2023-09-27 06:17:53.749079', 'fingerprint__0': 'AGcueNXWPlMqgqZBuspZQRInaHtixckVWpMwylNI', 'version__0': '5.2.4', 'last_seen__0': '2023-09-27 06:17:53.749079', 'is_exit__0': True, 'recommended_version__0': True, 'is_up__1': True, 'first_seen__1': '2023-09-27 06:17:53.749079', 'fingerprint__1': 'fSzJxtFuvNUeCdZFzQlWDgnXiqelolJfiGoVhPXo', 'version__1': '4.40', 'last_seen__1': '2023-09-27 06:17:53.749079', 'is_exit__1': False, 'recommended_version__1': True, 'is_up__2': True, 'first_seen__2': '2023-09-27 06:17:53.749079', 'fingerprint__2': 'cVvvkqAMkKczjfSTFkyefzidjzLuEKCzzuvlSLEd', 'version__2': '2.6', 'last_seen__2': '2023-09-27 06:17:53.749079', 'is_exit__2': True, 'recommended_version__2': True, 'is_up__3': False, 'first_seen__3': '2023-09-27 06:17:53.749079', 'fingerprint__3': 'HTkiLDPdeZWvzUFlLBJgVwCRRVECteHhJOyFbYVi', 'version__3': '4.71', 'last_seen__3': '2023-09-27 06:17:53.749079', 'is_exit__3': True, 'recommended_version__3': True, 'is_up__4': True, 'first_seen__4': '2023-09-27 06:17:53.749079', 'fingerprint__4': 'ikRadsqGTExNVDXPycbeyVRxvBJSceowMJzkgXfA', 'version__4': '7.0', 'last_seen__4': '2023-09-27 06:17:53.749079', 'is_exit__4': True, 'recommended_version__4': False, 'is_up__5': True, 'first_seen__5': '2023-09-27 06:17:53.749079', 'fingerprint__5': 'YqHfUlzDeWFJwkSnMLnJKVxgaXgzNatApWPutmNc', 'version__5': '0.5.7', 'last_seen__5': '2023-09-27 06:17:53.749079', 'is_exit__5': False, 'recommended_version__5': False, 'is_up__6': True, 'first_seen__6': '2023-09-27 06:17:53.749079', 'fingerprint__6': 'ENGymciLwKyLzfxeIJFQsHcDjfzwnsuZwcTxhbwJ', 'version__6': '0.50', 'last_seen__6': '2023-09-27 06:17:53.749079', 'is_exit__6': True, 'recommended_version__6': True, 'is_up__7': True ... 6900 parameters truncated ... 'recommended_version__992': False, 'is_up__993': True, 'first_seen__993': '2023-09-27 06:17:53.749079', 'fingerprint__993': 'ANhEvoQHfpCGBRepJlqVFVwJKMrcCmMTwTBVBRam', 'version__993': '0.3.4', 'last_seen__993': '2023-09-27 06:17:53.749079', 'is_exit__993': True, 'recommended_version__993': True, 'is_up__994': True, 'first_seen__994': '2023-09-27 06:17:53.749079', 'fingerprint__994': 'YRpKlaBNsVvtmSerLuBQwBauNkFowkgYaVzQFRkN', 'version__994': '0.4.5', 'last_seen__994': '2023-09-27 06:17:53.749079', 'is_exit__994': False, 'recommended_version__994': True, 'is_up__995': False, 'first_seen__995': '2023-09-27 06:17:53.749079', 'fingerprint__995': 'dnMlybGxbYxYjzdfAJixEhNnNvtUltSeowbQNWqx', 'version__995': '5.76', 'last_seen__995': '2023-09-27 06:17:53.749079', 'is_exit__995': False, 'recommended_version__995': True, 'is_up__996': False, 'first_seen__996': '2023-09-27 06:17:53.749079', 'fingerprint__996': 'FzFEMBFbEIysniXTqqdcsPDCIYKtQcWenmZBQTuD', 'version__996': '0.89', 'last_seen__996': '2023-09-27 06:17:53.749079', 'is_exit__996': True, 'recommended_version__996': False, 'is_up__997': True, 'first_seen__997': '2023-09-27 06:17:53.749079', 'fingerprint__997': 'nVztwuBuiNOskhBWFGKlLQgDoXKgAVIGLZPtDuwn', 'version__997': '0.90', 'last_seen__997': '2023-09-27 06:17:53.749079', 'is_exit__997': True, 'recommended_version__997': False, 'is_up__998': True, 'first_seen__998': '2023-09-27 06:17:53.749079', 'fingerprint__998': 'hLWxRRSCuvaICVEyqQinGyVKGVGSvdIEIjaLpFgG', 'version__998': '0.8.0', 'last_seen__998': '2023-09-27 06:17:53.749079', 'is_exit__998': True, 'recommended_version__998': False, 'is_up__999': False, 'first_seen__999': '2023-09-27 06:17:53.749079', 'fingerprint__999': 'iILrxtuFOkkXDzZLYOvIJcaYyOtfEzuaWTiWlezU', 'version__999': '6.05', 'last_seen__999': '2023-09-27 06:17:53.749079', 'is_exit__999': True, 'recommended_version__999': False}]
tor_weather_app_server | (Background on this error at: https://sqlalche.me/e/20/gkpj)
That's because the startup script is seeding mock data into the db. We should find a way to avoid this on subsequent launches. For now those errors can get ignored or one can remove the db container before starting over with docker-compose up
.