Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a8c64ed
Track datasource level by channel, ignore head rollbacks
droserasprout Oct 1, 2021
78f6e92
Docs
droserasprout Oct 1, 2021
71f8648
Typo
droserasprout Oct 1, 2021
f3cbc89
Changelog, fix level check
droserasprout Oct 1, 2021
7996333
Merge branch 'master' into fix/ignore-head-rollback
droserasprout Oct 1, 2021
d64eeba
Rollback tests WIP
droserasprout Oct 1, 2021
096a51b
Single queue WIP
droserasprout Oct 2, 2021
4e07521
Refactor OperationIndex
droserasprout Oct 2, 2021
e881efa
Fix tests
droserasprout Oct 2, 2021
169ca3f
Refactoring
droserasprout Oct 2, 2021
4cbba24
Refactor `_extract_message_data` method
droserasprout Oct 2, 2021
1c6acae
Allow "zero level" rollbacks, refactor `_on_rollback` callback
droserasprout Oct 2, 2021
df38dab
Zero level rollbacks special case, more refactoring
droserasprout Oct 2, 2021
8b586f4
Refactoring, docs, fix integrity checks
droserasprout Oct 2, 2021
754dc55
Replace some lists with deques
droserasprout Oct 2, 2021
f3c5e58
test_rollback WIP
droserasprout Oct 2, 2021
0a6842f
Another test
droserasprout Oct 2, 2021
14e6adb
Another test
droserasprout Oct 2, 2021
7ad955d
Fix realtime atomicity
droserasprout Oct 2, 2021
a221c88
More tests
droserasprout Oct 2, 2021
7a5c8ce
Update changelog
droserasprout Oct 2, 2021
514ffa2
Disable logger
droserasprout Oct 2, 2021
dda73d1
Warn on rollbacks
droserasprout Oct 2, 2021
d2a229a
Optimizations
droserasprout Oct 2, 2021
9d1ad0f
Moar
droserasprout Oct 2, 2021
65c3526
Changelog
droserasprout Oct 2, 2021
6684650
Ability to pass additional context on reindexing
droserasprout Oct 3, 2021
9f5c880
Fix tests, enqueue single level rollback
droserasprout Oct 3, 2021
df988cd
InitializationRequiredError on create_package failure
droserasprout Oct 3, 2021
bcfb62b
Final touches, changelog
droserasprout Oct 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@

## [unreleased]

### Improved

* A significant increase in indexing speed.

### Fixed

* Removed unnecessary file IO calls, improved logging
* Fixed unexpected reindexing caused by the bug in processing zero- and single-level rollbacks.
* Removed unnecessary file IO calls that could cause `PermissionError` exception in Docker environments.
* Fixed possible violation of block-level atomicity during real-time indexing.

### Changes

* Public methods of `TzktDatasource` now return immutable sequences.

## 3.0.3 - 2021-10-01

### Fixed

* Fixed processing of single level rollbacks emitted before rolled back head
* Fixed processing of single-level rollbacks emitted before rolled back head.

## 3.0.2 - 2021-09-30

Expand Down
7 changes: 5 additions & 2 deletions src/dipdup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from dipdup.codegen import DEFAULT_DOCKER_ENV_FILE, DEFAULT_DOCKER_IMAGE, DEFAULT_DOCKER_TAG, DipDupCodeGenerator
from dipdup.config import DipDupConfig, LoggingConfig, PostgresDatabaseConfig
from dipdup.dipdup import DipDup
from dipdup.exceptions import ConfigurationError, DeprecatedHandlerError, DipDupError, MigrationRequiredError
from dipdup.exceptions import ConfigurationError, DeprecatedHandlerError, DipDupError, InitializationRequiredError, MigrationRequiredError
from dipdup.hasura import HasuraGateway
from dipdup.migrations import DipDupMigrationManager, deprecated_handlers
from dipdup.utils.database import set_decimal_context, tortoise_wrapper
Expand Down Expand Up @@ -113,7 +113,10 @@ async def cli(ctx, config: List[str], env_file: List[str], logging_config: str):
_config = DipDupConfig.load(config)
init_sentry(_config)

await DipDupCodeGenerator(_config, {}).create_package()
try:
await DipDupCodeGenerator(_config, {}).create_package()
except Exception as e:
raise InitializationRequiredError from e

if _config.spec_version not in spec_version_mapping:
raise ConfigurationError(f'Unknown `spec_version`, correct ones: {", ".join(spec_version_mapping)}')
Expand Down
18 changes: 11 additions & 7 deletions src/dipdup/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,26 @@ async def restart(self) -> None:
sys.argv.remove('--reindex')
os.execl(sys.executable, sys.executable, *sys.argv)

async def reindex(self, reason: Optional[Union[str, ReindexingReason]] = None) -> None:
async def reindex(self, reason: Optional[Union[str, ReindexingReason]] = None, **context) -> None:
"""Drop all tables or whole database and restart with the same CLI arguments"""
reason_str = reason.value if isinstance(reason, ReindexingReason) else 'unknown'
self.logger.warning('Reindexing initialized, reason: %s', reason_str)

if not reason or isinstance(reason, str):
if not reason:
reason = ReindexingReason.MANUAL
elif isinstance(reason, str):
context['message'] = reason
reason = ReindexingReason.MANUAL

reason_str = reason.value + f' ({context["message"]})' if "message" in context else ''
self.logger.warning('Reindexing initialized, reason: %s', reason_str)
self.logger.info('Additional context: %s', context)

if forbid_reindexing:
schema = await Schema.filter().get()
if schema.reindex:
raise ReindexingRequiredError(schema.reindex)
raise ReindexingRequiredError(schema.reindex, context)

schema.reindex = reason
await schema.save()
raise ReindexingRequiredError(schema.reindex)
raise ReindexingRequiredError(schema.reindex, context)

database_config = self.config.database
if isinstance(database_config, PostgresDatabaseConfig):
Expand Down
10 changes: 5 additions & 5 deletions src/dipdup/datasources/datasource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from abc import abstractmethod
from typing import Awaitable, Callable, List, Set
from typing import Awaitable, Callable, Set, Tuple

from dipdup.config import HTTPConfig
from dipdup.http import HTTPGateway
Expand All @@ -11,8 +11,8 @@


HeadCallbackT = Callable[['IndexDatasource', HeadBlockData], Awaitable[None]]
OperationsCallbackT = Callable[['IndexDatasource', List[OperationData]], Awaitable[None]]
BigMapsCallbackT = Callable[['IndexDatasource', List[BigMapData]], Awaitable[None]]
OperationsCallbackT = Callable[['IndexDatasource', Tuple[OperationData, ...]], Awaitable[None]]
BigMapsCallbackT = Callable[['IndexDatasource', Tuple[BigMapData, ...]], Awaitable[None]]
RollbackCallbackT = Callable[['IndexDatasource', int, int], Awaitable[None]]


Expand Down Expand Up @@ -57,11 +57,11 @@ async def emit_head(self, head: HeadBlockData) -> None:
for fn in self._on_head:
await fn(self, head)

async def emit_operations(self, operations: List[OperationData]) -> None:
async def emit_operations(self, operations: Tuple[OperationData, ...]) -> None:
for fn in self._on_operations:
await fn(self, operations)

async def emit_big_maps(self, big_maps: List[BigMapData]) -> None:
async def emit_big_maps(self, big_maps: Tuple[BigMapData, ...]) -> None:
for fn in self._on_big_maps:
await fn(self, big_maps)

Expand Down
Loading