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

Iteration behavior changes depending on the log worker thread work #152

Closed
Tpt opened this issue Oct 21, 2022 · 0 comments · Fixed by #154
Closed

Iteration behavior changes depending on the log worker thread work #152

Tpt opened this issue Oct 21, 2022 · 0 comments · Fixed by #154
Assignees

Comments

@Tpt
Copy link
Contributor

Tpt commented Oct 21, 2022

In the following test, the presence or abscence of the db.process_commits call changes the iteration behavior of the last iter.prev() call.

If db.process_commit is never called, the last iter.prev() returns the key [0] as exepected, if db.process_commit is called before iterating, it returns None.

This test is doing both forward and backward iterations, I don't know if we want to support both on the same iterator...

	#[cfg(feature = "instrumentation")]
	#[test]
	fn test_process_commit_in_the_middle_of_iter() {
		let tmp = tempdir().unwrap();
		let mut options = Options::with_columns(tmp.path(), 1);
		options.columns[0].btree_index = true;
		options.always_flush = true;
		options.with_background_thread = false;

		let db = Db::open_or_create(&options).unwrap();
		db.commit::<_, Vec<u8>>(vec![(0, vec![0], Some(vec![0]))]).unwrap();
		db.process_commits().unwrap();
		let mut iter = db.iter(0).unwrap();
		iter.seek_to_last().unwrap();
		assert_eq!(iter.prev().unwrap(), Some((vec![0], vec![0]))); // State = 0
		assert_eq!(iter.next().unwrap(), None); // State = End
		assert_eq!(iter.prev().unwrap(), Some((vec![0], vec![0]))); // Fails because is None, work properly if process_commit is not called
	}

Changelog: 2022-10-24: Updated the bug description, the bug happens even if process_commits is called before iterating.

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

Successfully merging a pull request may close this issue.

2 participants