Skip to content

Commit

Permalink
Fix concurrency issue when using get_or_create method
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Aug 7, 2024
1 parent 7e34379 commit aea9624
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic

- cli: Fixed progress estimation when there are indexes with `last_level` option set.
- cli: Don't save reports for successful test runs.
- database: Fixed concurrency issue when using `get_or_create` method.
- evm: Fixed crash when contract ABI contains overloaded methods.
- tezos.operations: Fixed `sr_cement` operation index subscription.

Expand Down
1 change: 1 addition & 0 deletions docs/9.release-notes/_8.0_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- config: Allow `sentry.dsn` to be empty string.
- config: Fixed (de)serialization of hex strings in config.
- config: Fixed setting logging levels according to the config.
- database: Fixed concurrency issue when using `get_or_create` method.
- evm.events: Fixed matching logs when filtering by topic0.
- evm.events: Improve fetching event batches from node.
- evm.subsquid: Fixed typo in `iter_events` method name.
Expand Down
4 changes: 3 additions & 1 deletion src/dipdup/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ def __post_init__(self) -> None:

@property
def connection_string(self) -> str:
# NOTE: `maxsize=1` is important! Concurrency will be broken otherwise.
# NOTE: https://github.com/tortoise/tortoise-orm/issues/792
connection_string = (
f'{self.kind}://{self.user}:{quote_plus(self.password)}@{self.host}:{self.port}/{self.database}'
f'{self.kind}://{self.user}:{quote_plus(self.password)}@{self.host}:{self.port}/{self.database}?maxsize=1'
)
if self.schema_name != DEFAULT_POSTGRES_SCHEMA:
connection_string += f'&schema={self.schema_name}'
Expand Down

0 comments on commit aea9624

Please sign in to comment.