fix: sending does not work

We were inserting one too many 0xff bytes
This commit is contained in:
Timo Kösters 2022-10-09 21:56:56 +02:00 committed by Nyaaori
parent 229444c932
commit ca82b2940d
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
6 changed files with 18 additions and 47 deletions

View file

@ -161,6 +161,7 @@ impl KvTree for RocksDbEngineTree<'_> {
self.db
.rocks
.iterator_cf(&self.cf(), rocksdb::IteratorMode::Start)
//.map(|r| r.unwrap())
.map(|(k, v)| (Vec::from(k), Vec::from(v))),
)
}
@ -184,6 +185,7 @@ impl KvTree for RocksDbEngineTree<'_> {
},
),
)
//.map(|r| r.unwrap())
.map(|(k, v)| (Vec::from(k), Vec::from(v))),
)
}
@ -224,6 +226,7 @@ impl KvTree for RocksDbEngineTree<'_> {
&self.cf(),
rocksdb::IteratorMode::From(&prefix, rocksdb::Direction::Forward),
)
//.map(|r| r.unwrap())
.map(|(k, v)| (Vec::from(k), Vec::from(v)))
.take_while(move |(k, _)| k.starts_with(&prefix)),
)

View file

@ -66,7 +66,6 @@ impl service::sending::Data for KeyValueDatabase {
let mut keys = Vec::new();
for (outgoing_kind, event) in requests {
let mut key = outgoing_kind.get_prefix();
key.push(0xff);
key.extend_from_slice(if let SendingEventType::Pdu(value) = &event {
&**value
} else {
@ -139,6 +138,7 @@ fn parse_servercurrentevent(
let event = parts
.next()
.ok_or_else(|| Error::bad_database("Invalid bytes in servercurrentpdus."))?;
let server = utils::string_from_bytes(server).map_err(|_| {
Error::bad_database("Invalid server bytes in server_currenttransaction")
})?;
@ -169,6 +169,7 @@ fn parse_servercurrentevent(
let event = parts
.next()
.ok_or_else(|| Error::bad_database("Invalid bytes in servercurrentpdus."))?;
(
OutgoingKind::Push(user_id, pushkey_string),
if value.is_empty() {
@ -185,6 +186,7 @@ fn parse_servercurrentevent(
let event = parts
.next()
.ok_or_else(|| Error::bad_database("Invalid bytes in servercurrentpdus."))?;
let server = utils::string_from_bytes(server).map_err(|_| {
Error::bad_database("Invalid server bytes in server_currenttransaction")
})?;

View file

@ -556,7 +556,7 @@ impl KeyValueDatabase {
services()
.rooms
.state_compressor
.load_shortstatehash_info(dbg!(last_roomsstatehash))
.load_shortstatehash_info(last_roomsstatehash)
},
)?;
@ -579,7 +579,7 @@ impl KeyValueDatabase {
};
services().rooms.state_compressor.save_state_from_diff(
dbg!(current_sstatehash),
current_sstatehash,
statediffnew,
statediffremoved,
2, // every state change is 2 event changes on average

View file

@ -587,7 +587,7 @@ impl Service {
.notification_count(&userid, &pdu.room_id)
.map_err(|e| (kind.clone(), e))?
.try_into()
.expect("notifiation count can't go that high");
.expect("notification count can't go that high");
let permit = services().sending.maximum_requests.acquire().await;
@ -616,6 +616,7 @@ impl Service {
.get_pdu_json_from_id(pdu_id)
.map_err(|e| (OutgoingKind::Normal(server.clone()), e))?
.ok_or_else(|| {
error!("event not found: {server} {pdu_id:?}");
(
OutgoingKind::Normal(server.clone()),
Error::bad_database(