Skip to content

Conversation

@odesenfans
Copy link
Collaborator

@odesenfans odesenfans commented May 18, 2022

We now use unordered bulk inserts when processing the results
of the pending txs and messages jobs. Unordered writes guarantee
that all the writes will be attempted even if errors occur.

This property help fixing a long-standing issue with capped
collections. Given the design of the messages job, it is possible
that the job will handle the same message several times in parallel,
resulting in multiple updates to the same document.
This is problematic for the CappedMessage collection as capped
collections do not support updates that increase the size of
a document.

We now make the assumption that we do not care if bulk writes
to capped collections fail, and the unordered write guarantees
that we do not fail to insert a message because an error occurred.

Introduced two new context managers in the toolkit module:

  • the new Timer class allows to measure the time needed to run
    some operations
  • ignore_exceptions allows to ignore one or more exceptions
    in a block of code.

@odesenfans odesenfans force-pushed the od-force-ordering-of-db-ops branch from e35f100 to eddc6e3 Compare May 19, 2022 15:44
@odesenfans odesenfans changed the title [DB] Fix for capped collection bulk inserts [DB] Use unordered bulk inserts May 19, 2022
@odesenfans odesenfans marked this pull request as ready for review May 19, 2022 15:44
@odesenfans odesenfans requested a review from hoh May 19, 2022 15:44
@odesenfans odesenfans added this to the May release milestone May 19, 2022
@odesenfans odesenfans force-pushed the od-force-ordering-of-db-ops branch from eddc6e3 to ab46585 Compare May 24, 2022 10:07
We now use unordered bulk inserts when processing the results
of the pending txs and messages jobs. Unordered writes guarantee
that all the writes will be attempted even if errors occur.

This property help fixing a long-standing issue with capped
collections. Given the design of the messages job, it is possible
that the job will handle the same message several times in parallel,
resulting in multiple updates to the same document.
This is problematic for the `CappedMessage` collection as capped
collections do not support updates that increase the size of
a document.

We now make the assumption that we do not care if bulk writes
to capped collections fail, and the unordered write guarantees
that we do not fail to insert a message because an error occurred.

Introduced two new context managers in the toolkit module:
* the new `Timer` class allows to measure the time needed to run
  some operations
* `ignore_exceptions` allows to ignore one or more exceptions
  in a block of code.
@odesenfans odesenfans force-pushed the od-force-ordering-of-db-ops branch from ab46585 to 835c09d Compare May 25, 2022 09:26
@odesenfans odesenfans merged commit 66e1316 into aleph-im:dev May 25, 2022
@odesenfans odesenfans deleted the od-force-ordering-of-db-ops branch May 25, 2022 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants