Code Monkey home page Code Monkey logo

nut's People

Contributors

banditopazzo avatar reeywhaar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nut's Issues

Transaction rollback will panic if bucket ref not dropped

	let mut db = db_mock().build().unwrap();
	let mut tx = db.begin_rw_tx().unwrap();
	{
		let  bucket = tx.create_bucket(b"widgets").unwrap();
	}
	let bu = tx.bucket(b"widgets").unwrap();
	tx.rollback().unwrap();

panic code

	pub(crate) fn close(&self) -> Result<(), Error> {
		let mut db = self.db()?;
		let tx = db.remove_tx(self)?;

		*tx.0.db.write() = WeakDB::new();
		tx.0.root.try_write().unwrap().clear();
		tx.0.pages.try_write().unwrap().clear();
		Ok(())
	}

Index out of range

Hi, I got this error:

thread 'tokio-runtime-worker' panicked at /home/user1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nut-0.1.1/src/db/db.rs:731:72:
range start index 57344 out of range for slice of length 32768

The error points to this line:

RwLockReadGuard::map(mmap, |mmap| Page::from_buf(&mmap.as_ref()[pos..]))

Architecture dependant page size

Looking a the code of bbolt, it uses int for page size.

using a u32 in nut breaks compatibility for some architectures:

nut/src/meta/mod.rs

Lines 26 to 27 in 0dac83c

/// u32 to be platform independent
pub page_size: u32,

In normal cases it is better to be platform independent but in this case the "official" implementation is platform dependent and I think we should stick with that in order to be compatible

Panic in multiple situations

I have use nut to open three different boltdb config files which generate by Go language, I only read data with transaction, the code like this:

fn main() -> Result<(), Box<dyn std::error::Error>> {
        let db = DBBuilder::new("config.db").read_only(true).build()?;
        let tx = db.begin_tx()?;
        let b = tx.bucket(b"name")?;
        let Some(value) = b.get(b"key") else {return Err(Box::new(Error::new(ErrorKind::Other, "can't get key from bucket"))); };
        println!("{:?}", value);
        Ok(())
}

but there were several panic when I read different database file as follows:

  • first
thread 'main' panicked at 'unknown flag', /home/jicky/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-be2141875385cea5/nut-0.1.1/src/consts/mod.rs:55:18
stack backtrace:
   0:   0x4c1f14 - <unknown>
   1:   0x466c8c - <unknown>
   .....
  • second
thread 'main' panicked at 'range start index 36864 out of range for slice of length 32768', /home/jicky/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-be2141875385cea5/nut-0.1.1/src/db/db.rs:731:59
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted

Of course, I have also succeeded when I read the third database file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.