Skip to content

AsyncMigrationHarness fails in single thread tokio runtime #266

@dnaka91

Description

@dnaka91

Setup

Versions

  • Rust: 1.90
  • Diesel: 2.3.2
  • Diesel_async: 0.7.3
  • Database: PostgreSQL
  • Operating System: Linux

Feature Flags

  • diesel: uuid
  • diesel_async: async-connection-wrapper, deadpool, migrations, postgres

Problem Description

When using the new AsyncMigrationHarness in an automated test with tokio::test, it panics due to being run in a single-thread runtime by default.

The docs clearly say that the harness using block_in_place and the regular setup uses the multi-threaded runtime anyway. This is more of a nice to have than a bug, because this only happens in test cases and it would be nice to not have to slap the flavor = "multi_thread" on every integration test in the code base.

What are you trying to accomplish?

Trying out the new migration harness helper, as an alternative of running the migrations on tokio's blocking thread pool with spawn_blocking.

What is the expected output?

The helper works regardless of single- or multi-thread runtime.

What is the actual output?

The application panics due to the use of block_in_place, which only works in a multi-thread runtime.

Are you seeing any additional errors?

Steps to reproduce

Checklist

  • I have already looked over the issue tracker for similar possible closed issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions