Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch: counter batches are not working properly #1035

Closed
muzarski opened this issue Jul 9, 2024 · 1 comment · Fixed by #1038
Closed

batch: counter batches are not working properly #1035

muzarski opened this issue Jul 9, 2024 · 1 comment · Fixed by #1038
Assignees
Labels
bug Something isn't working

Comments

@muzarski
Copy link
Contributor

muzarski commented Jul 9, 2024

Here is the test that reproduces the issue:

#[tokio::test]
async fn test_counter_batch() {
    setup_tracing();
    let session = Arc::new(create_new_session_builder().build().await.unwrap());
    let ks = unique_keyspace_name();

    session.query(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap();
    session
        .query(
            format!(
                "CREATE TABLE IF NOT EXISTS {}.t_batch (key int PRIMARY KEY, value counter)",
                ks
            ),
            &[],
        )
        .await
        .unwrap();

    let q = format!("UPDATE {}.t_batch SET value = value + ? WHERE key = ?", ks);

    let mut my_batch = Batch::new(BatchType::Counter);
    assert_eq!(BatchType::Counter, my_batch.get_type());
    my_batch.append_statement(&q[..]);
    my_batch.append_statement(&q[..]);
    my_batch.append_statement(&q[..]);

    session
        .batch(
            &my_batch,
            ((Counter(1), 2), (Counter(1), 2), (Counter(1), 2)),
        )
        .await
        .unwrap();
}

This test fails with a server error:

---- transport::session_test::test_my_batch stdout ----
Unique name: test_rust_1720524333_0
thread 'transport::session_test::test_counter_batch' panicked at scylla/src/transport/session_test.rs:404:10:
called `Result::unwrap()` on an `Err` value: DbError(Invalid, "Cannot include a counter statement in a logged batch")

The driver sends a LOGGED batch, even though the user specified the batch type to be a COUNTER.

The issue was discovered by a faling integration test in cpp-rust-driver's CI after updating rust-driver's version to 0.13: scylladb/cpp-rust-driver#138.

@muzarski muzarski self-assigned this Jul 9, 2024
@wprzytula wprzytula added the bug Something isn't working label Jul 9, 2024
@muzarski
Copy link
Contributor Author

I found the culprit: 98b7542. I'll investigate it further and open a PR fixing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants