Skip to content

Make collator tasks cancel-safe #908

@drmick

Description

@drmick

Description:
We need to ensure that the current collator task can be safely dropped. The following collator methods, which are invoked in the async dispatcher, must be made cancel-safe:

  • init_collator_wrapper
  • wait_state_and_try_collate_wrapper
  • wait_state_and_do_collate_wrapper

Context:
During collation, the following state is modified:

  • Anchor cache
  • Reader state (buffers, etc.)
  • Queue state and statistics

If the collator task is simply stopped and restarted, it will execute incorrectly because of inconsistent state.

Current state:
We already have a cancellation mechanism using a cancellation token, but it is fully handled manually.

Task:
Investigate and design a cancel-safety mechanism so that collator tasks can be spawned in Tokio and used directly in select without requiring manual cancellation handling.


  • Create transactional types.
  • Make collator state unsplittable
  • Remove state ownership from collation task
  • Implement transaction types to collator state
  • Refactor do_collate. Work with transactions outside.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions