dbt-labs/dbt-core · error

read should succeed after write

Error message

read should succeed after write

What it means

Test-only assertion in test_write_and_read_round_trip: after LeaseHandler::write stores the lease data, reading it back from the lease file must succeed. Fires only if lease file write/read serialization regresses.

Solutions

  1. Check LeaseHandler write/read for serialization regressions
  2. Verify the lease file is created at the expected path in the test environment
  3. Treat failure as a lease subsystem bug
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/dbt-common/src/lease.rs:320 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/bb3321da9a59aa1c. Report an issue: GitHub.

Appendix: source

Thrown at crates/dbt-common/src/lease.rs:320

    fn test_lease_data_is_valid_expired() {
        let past_ms = current_time_micros().saturating_sub(1_000); // 1s ago
        let data = LeaseData {
            lease_id: "test".to_string(),
            expiry: past_ms,
        };
        assert!(!data.is_valid());
    }

    #[test]
    fn test_write_and_read_round_trip() {
        let path = test_lease_path();
        let handler = LeaseHandler::new(path.clone(), "test".to_string(), Duration::ZERO);

        let lease_id = "round-trip-id".to_string();
        let expiry: u128 = current_time_micros() + 30_000;

        handler.write(&lease_id, expiry).unwrap();
        let data = handler.read().expect("read should succeed after write");

        assert_eq!(data.lease_id, lease_id);
        assert_eq!(data.expiry, expiry);

        cleanup(&path);
    }

    #[dbt_runtime::test]
    async fn test_acquire_no_existing_lease() {
        let lease_id = "acquire-no-existing-lease".to_string();
        let path = test_lease_path();
        let handler = Arc::new(LeaseHandler::new(
            path.clone(),
            "test".to_string(),
            Duration::from_secs(5),
        ));

        let lease = handler.acquire(lease_id, Duration::from_secs(10));

View on GitHub (pinned to 0267ce9170)