Skip to content

Foreign key constraint violation #39

Description

@swjz

I got an error when running put() for many videos in parallel. It looks like the background clips are not in the clip table yet when we insert them into the background table of our metadata db. This is on the master branch.

Traceback (most recent call last):
  File "/home/azureuser/deeplens-cv/distributed/exp10_queue_worker.py", line 70, in <module>
    main()
  File "/home/azureuser/deeplens-cv/distributed/exp10_queue_worker.py", line 65, in main
    channel.start_consuming()
  File "/home/azureuser/.local/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 1865, in start_consuming
    self._process_data_events(time_limit=None)
  File "/home/azureuser/.local/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 2026, in _process_data_events
    self.connection.process_data_events(time_limit=time_limit)
  File "/home/azureuser/.local/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 833, in process_data_events
    self._dispatch_channel_events()
  File "/home/azureuser/.local/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 567, in _dispatch_channel_events
    impl_channel._get_cookie()._dispatch_events()
  File "/home/azureuser/.local/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 1493, in _dispatch_events
    evt.properties, evt.body)
  File "/home/azureuser/deeplens-cv/distributed/exp10_queue_worker.py", line 60, in callback
    runFullPut(body.decode("utf-8"), batch_size=72)
  File "/home/azureuser/deeplens-cv/distributed/exp10_queue_worker.py", line 49, in runFullPut
    put()
  File "/home/azureuser/deeplens-cv/distributed/exp10_queue_worker.py", line 44, in put
    'batch_size': batch_size, 'num_processes': 4, 'background_scale': 1})
  File "/home/azureuser/deeplens-cv/deeplens/full_manager/full_manager.py", line 126, in put
    write_video_single(conn, filename, target, self.local_dir, self.remote_dir, self.content_splitter, tagger, stream=stream, args=args, background_scale=args['background_scale'], rows=rows, hwang=hwang)
  File "/home/azureuser/deeplens-cv/deeplens/full_manager/full_videoio.py", line 367, in write_video_single
    full_width, full_height, start_time, start_time + time_block)
  File "/home/azureuser/deeplens-cv/deeplens/full_manager/full_videoio.py", line 98, in _new_headers_batch
    insert_background_header(conn, ids[0], ids[i], name)
  File "/home/azureuser/deeplens-cv/deeplens/full_manager/full_videoio.py", line 511, in insert_background_header
    c.execute("INSERT INTO background VALUES ('%d', '%d', '%s')" % (background_id, clip_id, video_name))
psycopg2.errors.ForeignKeyViolation: insert or update on table "background" violates foreign key constraint "background_clip_id_fkey"
DETAIL:  Key (clip_id, video_name)=(8458666960472462466, test) is not present in table "clip".

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions