Use advisory lock around load_message.py
authorMagnus Hagander <magnus@hagander.net>
Thu, 29 Nov 2018 16:01:22 +0000 (17:01 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 29 Nov 2018 16:01:22 +0000 (17:01 +0100)
commit68e8bb7775a846ce7fda3a70395e66778f36a0ed
tree05e43a8310dba8f64e85b745b46c2f4f577ea505
parenta2a9033342105e8f39ae970d6653c428f5dc76d8
Use advisory lock around load_message.py

Avoid loading two messages at the same time. In particular this can
cause issues if it's two copies of the same message on different lists,
which can cause a UNIQUE violation in the loader. It could also be a
problem if two messages on a new thread arrives in parallel, which could
cause two separate threads to be created.

This could be made more efficient by properly ordering the operations on
storage and using ON CONFLICT, but it's a very rare occassion and it
doesn't matter that we have to wait for a second or two for a previous
storage to complete.
loader/load_message.py