libmdbx_remote/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(
3    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
4    html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
5    issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
6)]
7#![cfg_attr(not(test), warn(unused_crate_dependencies))]
8#![allow(missing_docs, clippy::needless_pass_by_ref_mut)]
9#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
10
11pub extern crate mdbx_remote_sys as ffi;
12
13#[cfg(feature = "read-tx-timeouts")]
14pub use crate::environment::read_transactions::MaxReadTransactionDuration;
15pub use crate::{
16    any::{CursorAny, DatabaseAny, EnvironmentAny, TransactionAny},
17    codec::*,
18    cursor::{Cursor, Iter, IterDup},
19    database::Database,
20    environment::{
21        Environment, EnvironmentBuilder, EnvironmentKind, Geometry, HandleSlowReadersCallback,
22        HandleSlowReadersReturnCode, Info, PageSize, Stat,
23    },
24    error::{Error, Result},
25    flags::*,
26    remote::{
27        BufferConfiguration, ClientError, RemoteCursor, RemoteDatabase, RemoteEnvironment,
28        RemoteTransaction,
29    },
30    service::{MDBXServerState, RemoteMDBX, RemoteMDBXClient, RemoteMDBXServer, ServerError},
31    transaction::{CommitLatency, Transaction, TransactionKind, RO, RW},
32};
33
34mod any;
35mod codec;
36mod cursor;
37mod database;
38mod environment;
39mod error;
40mod flags;
41mod remote;
42mod service;
43mod transaction;
44mod txn_manager;
45
46#[cfg(test)]
47mod test_utils {
48    use super::*;
49    use byteorder::{ByteOrder, LittleEndian};
50    use tempfile::tempdir;
51
52    /// Regression test for <https://github.com/danburkert/lmdb-rs/issues/21>.
53    /// This test reliably segfaults when run against lmbdb compiled with opt level -O3 and newer
54    /// GCC compilers.
55    #[test]
56    fn issue_21_regression() {
57        const HEIGHT_KEY: [u8; 1] = [0];
58
59        let dir = tempdir().unwrap();
60
61        let env = {
62            let mut builder = Environment::builder();
63            builder.set_max_dbs(2);
64            builder.set_geometry(Geometry {
65                size: Some(1_000_000..1_000_000),
66                ..Default::default()
67            });
68            builder.open(dir.path()).expect("open mdbx env")
69        };
70
71        for height in 0..1000 {
72            let mut value = [0u8; 8];
73            LittleEndian::write_u64(&mut value, height);
74            let tx = env.begin_rw_txn().expect("begin_rw_txn");
75            let index = tx
76                .create_db(None, DatabaseFlags::DUP_SORT)
77                .expect("open index db");
78            tx.put(index.dbi(), HEIGHT_KEY, value, WriteFlags::empty())
79                .expect("tx.put");
80            tx.commit().expect("tx.commit");
81        }
82    }
83}