fixed conflict with two cursors when one is reading and another is commiting

This commit is contained in:
Lex Berezhny 2020-07-06 09:18:22 -04:00
parent 7d9bf03574
commit 34a9dff141

View file

@ -341,12 +341,11 @@ def process_claims(starting_height: int, blocks_added: Optional[Tuple[int, int]]
).order_by(TXO.c.claim_hash)
)
streaming_connection = p.ctx.connection.execution_options(stream_results=True)
with p.ctx.engine.connect().execution_options(stream_results=True) as c:
# all channels need to be inserted first because channel short_url will needed to
# set the contained claims canonical_urls when those are inserted next
done = insert_claims_with_lbrycrd(
done, chain, p, streaming_connection.execute(
done, chain, p, c.execute(
select_claims.select_from(TXO.join(TX)).where(
(TXO.c.txo_type == TXO_TYPES['channel']) &
(TXO.c.spent_height == 0) &
@ -376,8 +375,9 @@ def process_claims(starting_height: int, blocks_added: Optional[Tuple[int, int]]
)
)
with p.ctx.engine.connect().execution_options(stream_results=True) as c:
done = insert_claims_with_lbrycrd(
done, chain, p, streaming_connection.execute(
done, chain, p, c.execute(
select_claims.where(
(TXO.c.txo_type.in_(list(set(CLAIM_TYPE_CODES) - {TXO_TYPES['channel']}))) &
(TXO.c.spent_height == 0) &