forked from Deuxfleurs/garage
Compare commits
10 commits
feat/lmdb-
...
main
Author | SHA1 | Date | |
---|---|---|---|
906c8708fd | |||
747889a096 | |||
feb09a4bc6 | |||
aa8bc6aa88 | |||
aba7902995 | |||
78de7b5bde | |||
9bd9e392ba | |||
116ad479a8 | |||
|
b6a58c5c16 | ||
2b0bfa9b18 |
8 changed files with 40 additions and 62 deletions
|
@ -23,7 +23,7 @@ client = minio.Minio(
|
||||||
"GKyourapikey",
|
"GKyourapikey",
|
||||||
"abcd[...]1234",
|
"abcd[...]1234",
|
||||||
# Force the region, this is specific to garage
|
# Force the region, this is specific to garage
|
||||||
region="region",
|
region="garage",
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -335,6 +335,7 @@ From the [official Mastodon documentation](https://docs.joinmastodon.org/admin/t
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ RAILS_ENV=production bin/tootctl media remove --days 3
|
$ RAILS_ENV=production bin/tootctl media remove --days 3
|
||||||
|
$ RAILS_ENV=production bin/tootctl media remove --days 15 --prune-profiles
|
||||||
$ RAILS_ENV=production bin/tootctl media remove-orphans
|
$ RAILS_ENV=production bin/tootctl media remove-orphans
|
||||||
$ RAILS_ENV=production bin/tootctl preview_cards remove --days 15
|
$ RAILS_ENV=production bin/tootctl preview_cards remove --days 15
|
||||||
```
|
```
|
||||||
|
@ -353,8 +354,6 @@ Imports: 1.7 KB
|
||||||
Settings: 0 Bytes
|
Settings: 0 Bytes
|
||||||
```
|
```
|
||||||
|
|
||||||
Unfortunately, [old avatars and headers cannot currently be cleaned up](https://github.com/mastodon/mastodon/issues/9567).
|
|
||||||
|
|
||||||
### Migrating your data
|
### Migrating your data
|
||||||
|
|
||||||
Data migration should be done with an efficient S3 client.
|
Data migration should be done with an efficient S3 client.
|
||||||
|
|
|
@ -50,3 +50,20 @@ locations. They use Garage themselves for the following tasks:
|
||||||
|
|
||||||
The Deuxfleurs Garage cluster is a multi-site cluster currently composed of
|
The Deuxfleurs Garage cluster is a multi-site cluster currently composed of
|
||||||
9 nodes in 3 physical locations.
|
9 nodes in 3 physical locations.
|
||||||
|
|
||||||
|
### Triplebit
|
||||||
|
|
||||||
|
[Triplebit](https://www.triplebit.org) is a non-profit hosting provider and
|
||||||
|
ISP focused on improving access to privacy-related services. They use
|
||||||
|
Garage themselves for the following tasks:
|
||||||
|
|
||||||
|
- Hosting of their homepage, [privacyguides.org](https://www.privacyguides.org/), and various other static sites
|
||||||
|
|
||||||
|
- As a Mastodon object storage backend for [mstdn.party](https://mstdn.party/) and [mstdn.plus](https://mstdn.plus/)
|
||||||
|
|
||||||
|
- As a PeerTube storage backend for [neat.tube](https://neat.tube/)
|
||||||
|
|
||||||
|
- As a [Matrix media backend](https://github.com/matrix-org/synapse-s3-storage-provider)
|
||||||
|
|
||||||
|
Triplebit's Garage cluster is a multi-site cluster currently composed of
|
||||||
|
10 nodes in 3 physical locations.
|
||||||
|
|
|
@ -76,6 +76,9 @@ spec:
|
||||||
- name: etc
|
- name: etc
|
||||||
mountPath: /etc/garage.toml
|
mountPath: /etc/garage.toml
|
||||||
subPath: garage.toml
|
subPath: garage.toml
|
||||||
|
{{- with .Values.extraVolumeMounts }}
|
||||||
|
{{- toYaml . | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
# TODO
|
# TODO
|
||||||
# livenessProbe:
|
# livenessProbe:
|
||||||
# httpGet:
|
# httpGet:
|
||||||
|
@ -110,6 +113,9 @@ spec:
|
||||||
- name: data
|
- name: data
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- with .Values.extraVolumes }}
|
||||||
|
{{- toYaml . | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
{{- with .Values.nodeSelector }}
|
{{- with .Values.nodeSelector }}
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
{{- toYaml . | nindent 8 }}
|
{{- toYaml . | nindent 8 }}
|
||||||
|
|
|
@ -218,6 +218,10 @@ affinity: {}
|
||||||
|
|
||||||
environment: {}
|
environment: {}
|
||||||
|
|
||||||
|
extraVolumes: {}
|
||||||
|
|
||||||
|
extraVolumeMounts: {}
|
||||||
|
|
||||||
monitoring:
|
monitoring:
|
||||||
metrics:
|
metrics:
|
||||||
# If true, a service for monitoring is created with a prometheus.io/scrape annotation
|
# If true, a service for monitoring is created with a prometheus.io/scrape annotation
|
||||||
|
|
|
@ -15,9 +15,6 @@ path = "lib.rs"
|
||||||
err-derive.workspace = true
|
err-derive.workspace = true
|
||||||
hexdump.workspace = true
|
hexdump.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
opentelemetry.workspace = true
|
|
||||||
opentelemetry.workspace = true
|
|
||||||
xxhash-rust.workspace = true
|
|
||||||
|
|
||||||
heed = { workspace = true, optional = true }
|
heed = { workspace = true, optional = true }
|
||||||
rusqlite = { workspace = true, optional = true, features = ["backup"] }
|
rusqlite = { workspace = true, optional = true, features = ["backup"] }
|
||||||
|
|
|
@ -10,8 +10,6 @@ use std::sync::{Arc, RwLock};
|
||||||
use heed::types::ByteSlice;
|
use heed::types::ByteSlice;
|
||||||
use heed::{BytesDecode, Env, RoTxn, RwTxn, UntypedDatabase as Database};
|
use heed::{BytesDecode, Env, RoTxn, RwTxn, UntypedDatabase as Database};
|
||||||
|
|
||||||
use xxhash_rust::xxh3::xxh3_128;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult,
|
Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult,
|
||||||
TxResult, TxValueIter, Value, ValueIter,
|
TxResult, TxValueIter, Value, ValueIter,
|
||||||
|
@ -60,40 +58,6 @@ impl LmdbDb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn key_hash(key: &[u8]) -> [u8; 16] {
|
|
||||||
xxh3_128(key).to_ne_bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn kv_to_value(key: &[u8], value: &[u8]) -> Vec<u8> {
|
|
||||||
[&key.len().to_ne_bytes(), key, value].concat()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn value_to_kv(value: &[u8]) -> (Vec<u8>, Vec<u8>) {
|
|
||||||
const USIZE_LEN: usize = std::mem::size_of::<usize>();
|
|
||||||
let klen = usize::from_ne_bytes(value[0..USIZE_LEN].try_into().unwrap());
|
|
||||||
(
|
|
||||||
value[USIZE_LEN..klen+USIZE_LEN].to_vec(),
|
|
||||||
value[USIZE_LEN+klen..].to_vec()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn key_hash(key: &[u8]) -> [u8; 16] {
|
|
||||||
xxh3_128(key).to_ne_bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn kv_to_value(key: &[u8], value: &[u8]) -> Vec<u8> {
|
|
||||||
[&key.len().to_ne_bytes(), key, value].concat()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn value_to_kv(value: &[u8]) -> (Vec<u8>, Vec<u8>) {
|
|
||||||
const USIZE_LEN: usize = std::mem::size_of::<usize>();
|
|
||||||
let klen = usize::from_ne_bytes(value[0..USIZE_LEN].try_into().unwrap());
|
|
||||||
(
|
|
||||||
value[USIZE_LEN..klen+USIZE_LEN].to_vec(),
|
|
||||||
value[USIZE_LEN+klen..].to_vec()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IDb for LmdbDb {
|
impl IDb for LmdbDb {
|
||||||
fn engine(&self) -> String {
|
fn engine(&self) -> String {
|
||||||
"LMDB (using Heed crate)".into()
|
"LMDB (using Heed crate)".into()
|
||||||
|
@ -155,11 +119,10 @@ impl IDb for LmdbDb {
|
||||||
let tree = self.get_tree(tree)?;
|
let tree = self.get_tree(tree)?;
|
||||||
|
|
||||||
let tx = self.db.read_txn()?;
|
let tx = self.db.read_txn()?;
|
||||||
let kh = key_hash(key);
|
let val = tree.get(&tx, key)?;
|
||||||
let val = tree.get(&tx, &kh)?;
|
|
||||||
match val {
|
match val {
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
Some(v) => Ok(Some(value_to_kv(v).1))
|
Some(v) => Ok(Some(v.to_vec())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,9 +135,7 @@ impl IDb for LmdbDb {
|
||||||
fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> {
|
fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> {
|
||||||
let tree = self.get_tree(tree)?;
|
let tree = self.get_tree(tree)?;
|
||||||
let mut tx = self.db.write_txn()?;
|
let mut tx = self.db.write_txn()?;
|
||||||
let kh = key_hash(key);
|
tree.put(&mut tx, key, value)?;
|
||||||
let value = kv_to_value(key, value);
|
|
||||||
tree.put(&mut tx, &kh, &value)?;
|
|
||||||
tx.commit()?;
|
tx.commit()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -182,8 +143,7 @@ impl IDb for LmdbDb {
|
||||||
fn remove(&self, tree: usize, key: &[u8]) -> Result<()> {
|
fn remove(&self, tree: usize, key: &[u8]) -> Result<()> {
|
||||||
let tree = self.get_tree(tree)?;
|
let tree = self.get_tree(tree)?;
|
||||||
let mut tx = self.db.write_txn()?;
|
let mut tx = self.db.write_txn()?;
|
||||||
let kh = key_hash(key);
|
tree.delete(&mut tx, key)?;
|
||||||
tree.delete(&mut tx, &kh)?;
|
|
||||||
tx.commit()?;
|
tx.commit()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -282,9 +242,8 @@ impl<'a> LmdbTx<'a> {
|
||||||
impl<'a> ITx for LmdbTx<'a> {
|
impl<'a> ITx for LmdbTx<'a> {
|
||||||
fn get(&self, tree: usize, key: &[u8]) -> TxOpResult<Option<Value>> {
|
fn get(&self, tree: usize, key: &[u8]) -> TxOpResult<Option<Value>> {
|
||||||
let tree = self.get_tree(tree)?;
|
let tree = self.get_tree(tree)?;
|
||||||
let kh = key_hash(key);
|
match tree.get(&self.tx, key)? {
|
||||||
match tree.get(&self.tx, &kh)? {
|
Some(v) => Ok(Some(v.to_vec())),
|
||||||
Some(v) => Ok(Some(value_to_kv(v).1)),
|
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,18 +254,14 @@ impl<'a> ITx for LmdbTx<'a> {
|
||||||
|
|
||||||
fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult<()> {
|
fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult<()> {
|
||||||
let tree = *self.get_tree(tree)?;
|
let tree = *self.get_tree(tree)?;
|
||||||
let kh = key_hash(key);
|
tree.put(&mut self.tx, key, value)?;
|
||||||
let value = kv_to_value(key, value);
|
|
||||||
tree.put(&mut self.tx, &kh, &value)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult<()> {
|
fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult<()> {
|
||||||
let tree = *self.get_tree(tree)?;
|
let tree = *self.get_tree(tree)?;
|
||||||
let kh = key_hash(key);
|
tree.delete(&mut self.tx, key)?;
|
||||||
tree.delete(&mut self.tx, &kh)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear(&mut self, tree: usize) -> TxOpResult<()> {
|
fn clear(&mut self, tree: usize) -> TxOpResult<()> {
|
||||||
let tree = *self.get_tree(tree)?;
|
let tree = *self.get_tree(tree)?;
|
||||||
tree.clear(&mut self.tx)?;
|
tree.clear(&mut self.tx)?;
|
||||||
|
@ -415,7 +370,7 @@ where
|
||||||
match next {
|
match next {
|
||||||
None => None,
|
None => None,
|
||||||
Some(Err(e)) => Some(Err(e.into())),
|
Some(Err(e)) => Some(Err(e.into())),
|
||||||
Some(Ok((_k, v))) => Some(Ok(value_to_kv(v))),
|
Some(Ok((k, v))) => Some(Ok((k.to_vec(), v.to_vec()))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -425,7 +380,7 @@ where
|
||||||
fn tx_iter_item<'a>(
|
fn tx_iter_item<'a>(
|
||||||
item: std::result::Result<(&'a [u8], &'a [u8]), heed::Error>,
|
item: std::result::Result<(&'a [u8], &'a [u8]), heed::Error>,
|
||||||
) -> TxOpResult<(Vec<u8>, Vec<u8>)> {
|
) -> TxOpResult<(Vec<u8>, Vec<u8>)> {
|
||||||
item.map(|(_k, v)| value_to_kv(v))
|
item.map(|(k, v)| (k.to_vec(), v.to_vec()))
|
||||||
.map_err(|e| TxOpError(Error::from(e)))
|
.map_err(|e| TxOpError(Error::from(e)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl Garage {
|
||||||
)?)
|
)?)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|x| NetworkKey::from_slice(&x))
|
.and_then(|x| NetworkKey::from_slice(&x))
|
||||||
.ok_or_message("Invalid RPC secret key: expected 32 bits of entropy, please check the documentation for requirements")?;
|
.ok_or_message("Invalid RPC secret key: expected 32 bytes of random hex, please check the documentation for requirements")?;
|
||||||
|
|
||||||
let (replication_factor, consistency_mode) = parse_replication_mode(&config)?;
|
let (replication_factor, consistency_mode) = parse_replication_mode(&config)?;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue