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

Transaction 'on close' callback is not triggered #538

Open
krishnangovindraj opened this issue Dec 12, 2023 · 0 comments
Open

Transaction 'on close' callback is not triggered #538

krishnangovindraj opened this issue Dec 12, 2023 · 0 comments
Assignees

Comments

@krishnangovindraj
Copy link
Member

Description

A transaction 'on close' callback registered is not always called.

Environment

  1. TypeDB distribution: Core, but it's a driver side bug.
  2. TypeDB version: 2.25.7
  3. Environment: Mac/Linux
  4. Other details: Reproduced on C++ and rust drivers.

Reproducible Steps

Here is a modified rust integration test.

 let session = Arc::new(Session::new(databases.get(common::TEST_DATABASE).await?, Data).await?);
        let transaction = session.transaction(Read).await?;
        
        let was_called = Arc::new(AtomicBool::new(false));
        transaction.on_close({
            let session = session.clone();
            let was_called = was_called.clone();
            move |_| {
                was_called.store(true, Ordering::SeqCst);
                session.force_close().ok();
            }
        });
        transaction.force_close();
        
        let mut n = 10;
        while n > 0 {
            if was_called.load(Ordering::SeqCst) {
                break;
            }
            thread::sleep(time::Duration::from_millis(1000));
            n -= 1;
        }
        assert_eq!(true, was_called.load(Ordering::SeqCst));

Expected result

The assert would pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants