Possible data race in psycopg2

Поиск
Список
Период
Сортировка
От Mark Charsley
Тема Possible data race in psycopg2
Дата
Msg-id CAAf4L0eqm6hozAZyKP005a6UEPnnQcQe-=qznbnOr6B-tQSCAw@mail.gmail.com
обсуждение исходный текст
Список psycopg
Hi. I've started a little project that uses psycopg2, and hit a problem when running tests under ThreadSanitizer:

WARNING: ThreadSanitizer: data race (pid=9435)
  Read of size 4 at 0x7b44000aae38 by thread T7:
    #0 psyco_conn_cursor psycopg2/psycopg/connection_type.c:88:15 (_psycopg.abi3.so+0x2a434)

  Previous write of size 4 at 0x7b44000aae38 by thread T6 (mutexes: write M142280395227573736):
    #0 pq_begin_locked psycopg2/psycopg/pqpath.c:377:22 (_psycopg.abi3.so+0x38766)
    #1 _pq_execute_sync psycopg2/psycopg/pqpath.c:819:22 (_psycopg.abi3.so+0x3923e)
    #2 pq_execute psycopg2/psycopg/pqpath.c:947:16 (_psycopg.abi3.so+0x3abd7)
    #3 _psyco_curs_execute psycopg2/psycopg/cursor_type.c:447:11 (_psycopg.abi3.so+0x32820)
    #4 curs_execute psycopg2/psycopg/cursor_type.c:491:13 (_psycopg.abi3.so+0x2f92b)

It's possible that this is caused by an underlying failure in the postgres server, where thread sanitizer panics about a safe-except-under-the-most-insanely-optimising-compiler issue, discussed here: https://www.postgresql.org/message-id/CAAf4L0d5XpgmX%2BnzT2G_F7EPkJb2JODr_QCzOsSvWBnXxLKYVQ%40mail.gmail.com which may have killed the server (the tests I'm running compile everything, including the DB server with tsan), and handling the dead connection causes the issues mentioned above. But can wiser and more experienced heads than mine cast their eyes over the code above, and see if there is indeed a problem with a write to conn_status in pq_begin_lockedand a read from it in psyco_conn_cursor without a memory barrier in-between?

thanks

Mark

В списке psycopg по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: iterating over DictRow
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: psycopg3 and adaptation choices