You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been migrating a project to sled from a different embedded db and I'm getting some strange compilation errors:
error: future cannot be sent between threads safely
--> ratman/src/journal/page.rs:99:85
|
99 | async fn fetch(&self, reference: &BlockReference) -> IoResult<Option<Block<L>>> {
| _____________________________________________________________________________________^
100 | | match self.get(&reference.to_string()) {
101 | | Err(RatmanError::Io(io)) => Err(io),
102 | | Ok(Some(BlockData { data, valid })) if valid => Ok(Some(data.to_block())),
103 | | _ => Ok(None),
104 | | }
105 | | }
| |_____^ future created by async block is not `Send`
|
= help: within `Tree`, the trait `Sync` is not implemented for `RefCell<ebr::Inner<concurrent_map::Deferred<sled::ObjectId, sled::Object<1024>, 64>, 128, 128>>`, which is required by `{async block@ratman/src/journal/page.rs:99:85: 105:6}: std::marker::Send`
= note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead
note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync`
And this is the trait definition that causes problems:
#[async_trait]impl<constL:usize>BlockStorage<L>forCachePage<BlockData>{asyncfnstore(&self,block:&Block<L>) -> IoResult<()>{self.insert(
block.reference().to_string(),&BlockData{// We can unwrap here because the blocks were previously// verified to be validdata:StorageBlock::reconstruct(block.as_slice()).unwrap(),valid:true,},)?;Ok(())}asyncfnfetch(&self,reference:&BlockReference) -> IoResult<Option<Block<L>>>{matchself.get(&reference.to_string()){Err(RatmanError::Io(io)) => Err(io),Ok(Some(BlockData{ data, valid }))if valid => Ok(Some(data.to_block())),
_ => Ok(None),}}}
Is this a bug or am I holding the Tree wrong? Oh and I'm using version 1.0.0-alpha.121
The text was updated successfully, but these errors were encountered:
I am not a Sled developer, but I have encountered a similar problem. The solution was not to share the Tree between threads, but to clone it for each thread.
P.S.
It is also better to wrap Tree in Box, because the size on the stack is 7648 bytes, and there may be a stack overflow error.
I've been migrating a project to sled from a different embedded db and I'm getting some strange compilation errors:
The type this is implemented for is:
And this is the trait definition that causes problems:
Is this a bug or am I holding the
Tree
wrong? Oh and I'm using version1.0.0-alpha.121
The text was updated successfully, but these errors were encountered: