pigeonhole-db 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +16 -16
- data/Cargo.toml +5 -5
- data/lib/pigeonhole/version.rb +1 -1
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/IO_Event.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/gem_make.out +6 -6
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/mkmf.log +26 -26
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/gem_make.out +6 -6
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/json/ext/generator.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/json/ext/parser.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/mkmf.log +19 -19
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/gem_make.out +9 -9
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/mkmf.log +6 -6
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/prism/prism.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/gem_make.out +6 -6
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/mkmf.log +7 -7
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/rbs_extension.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/Makefile +3 -3
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/IO_Event.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/generator/Makefile +3 -3
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/parser/Makefile +3 -3
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext/generator.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext/parser.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/prism-1.9.0/ext/prism/Makefile +3 -3
- data/vendor/bundle/ruby/3.4.0/gems/prism-1.9.0/lib/prism/prism.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/rbs-4.2.0/ext/rbs_extension/Makefile +3 -3
- data/vendor/bundle/ruby/3.4.0/gems/rbs-4.2.0/lib/rbs_extension.so +0 -0
- data/vendor/cache/Cargo.toml +2 -2
- data/vendor/cache/src/lib.rs +37 -0
- data/vendor/cache/src/loom_tests.rs +32 -0
- data/vendor/cache/src/s3fifo.rs +239 -11
- data/vendor/cache/src/sync.rs +4 -4
- data/vendor/compaction/Cargo.toml +6 -6
- data/vendor/compaction/src/cursor.rs +86 -4
- data/vendor/compaction/src/job.rs +24 -2
- data/vendor/engine/Cargo.toml +11 -11
- data/vendor/engine/src/admission.rs +3 -1
- data/vendor/engine/src/catalog.rs +39 -4
- data/vendor/engine/src/check.rs +59 -20
- data/vendor/engine/src/compact.rs +2 -2
- data/vendor/engine/src/engine/hooks.rs +144 -2
- data/vendor/engine/src/engine/info.rs +6 -0
- data/vendor/engine/src/engine.rs +1492 -50
- data/vendor/engine/src/external_registry.rs +447 -0
- data/vendor/engine/src/feed.rs +313 -84
- data/vendor/engine/src/feed_reader/catalog.rs +490 -0
- data/vendor/engine/src/feed_reader/history.rs +236 -0
- data/vendor/engine/src/feed_reader/read_ahead.rs +241 -0
- data/vendor/engine/src/feed_reader/token.rs +232 -0
- data/vendor/engine/src/feed_reader.rs +970 -852
- data/vendor/engine/src/feed_stop_loom.rs +73 -0
- data/vendor/engine/src/flush.rs +29 -4
- data/vendor/engine/src/io_count.rs +190 -0
- data/vendor/engine/src/large.rs +4 -1
- data/vendor/engine/src/lib.rs +16 -2
- data/vendor/engine/src/maintenance.rs +2 -2
- data/vendor/engine/src/manifest.rs +38 -6
- data/vendor/engine/src/nonblocking.rs +3 -3
- data/vendor/engine/src/options.rs +26 -0
- data/vendor/engine/src/punch.rs +282 -0
- data/vendor/engine/src/range_copy.rs +365 -0
- data/vendor/engine/src/read/keys.rs +37 -5
- data/vendor/engine/src/read/reduce.rs +1 -0
- data/vendor/engine/src/read.rs +7 -0
- data/vendor/engine/src/row_cache.rs +24 -0
- data/vendor/engine/src/shard/tablets.rs +127 -31
- data/vendor/engine/src/shard.rs +1006 -33
- data/vendor/engine/src/source.rs +105 -12
- data/vendor/engine/src/write.rs +310 -4
- data/vendor/format/Cargo.toml +1 -1
- data/vendor/format/src/shm.rs +10 -0
- data/vendor/format/src/superblock.rs +9 -2
- data/vendor/format/src/wal.rs +818 -16
- data/vendor/io/Cargo.toml +3 -3
- data/vendor/io/src/count.rs +76 -0
- data/vendor/io/src/file.rs +70 -0
- data/vendor/io/src/lib.rs +2 -0
- data/vendor/io/src/os/unix.rs +124 -0
- data/vendor/io/src/os/windows.rs +51 -0
- data/vendor/io/src/pread.rs +26 -0
- data/vendor/io/src/sim.rs +81 -9
- data/vendor/io/src/sys.rs +53 -0
- data/vendor/io/src/uring.rs +28 -0
- data/vendor/io/src/vfs.rs +4 -0
- data/vendor/memory/Cargo.toml +4 -4
- data/vendor/memory/src/hooks.rs +6 -0
- data/vendor/memory/src/ivf.rs +67 -1
- data/vendor/memory/src/lib.rs +4 -1
- data/vendor/memory/src/recall/pool.rs +872 -0
- data/vendor/memory/src/recall.rs +351 -273
- data/vendor/memory/src/store.rs +15 -0
- data/vendor/memtable/Cargo.toml +3 -3
- data/vendor/pager/Cargo.toml +3 -3
- data/vendor/pager/src/alloc.rs +430 -0
- data/vendor/pager/src/lib.rs +114 -0
- data/vendor/pigeonhole/Cargo.toml +6 -5
- data/vendor/pigeonhole/src/db.rs +91 -2
- data/vendor/pigeonhole/src/error.rs +2 -1
- data/vendor/pigeonhole/src/feed.rs +210 -6
- data/vendor/pigeonhole/src/lib.rs +3 -0
- data/vendor/pigeonhole/src/metrics.rs +37 -0
- data/vendor/pigeonhole/src/nonblocking.rs +94 -111
- data/vendor/pigeonhole/src/options.rs +69 -0
- data/vendor/pigeonhole/src/replication.rs +601 -11
- data/vendor/pigeonhole/src/write.rs +81 -0
- data/vendor/runtime/Cargo.toml +2 -2
- data/vendor/shm/Cargo.toml +3 -3
- data/vendor/shm/src/region.rs +20 -2
- data/vendor/sst/Cargo.toml +4 -4
- data/vendor/sst/src/blob.rs +85 -7
- data/vendor/sst/src/iter.rs +98 -2
- data/vendor/sst/src/lib.rs +11 -2
- data/vendor/sst/src/writer.rs +12 -2
- data/vendor/text/Cargo.toml +2 -2
- data/vendor/text/src/block.rs +638 -0
- data/vendor/text/src/error.rs +8 -3
- data/vendor/text/src/fuzzy.rs +1 -1
- data/vendor/text/src/index.rs +1055 -80
- data/vendor/text/src/layout.rs +63 -2
- data/vendor/text/src/lib.rs +5 -1
- data/vendor/text/src/maxscore.rs +481 -94
- data/vendor/text/src/merged.rs +470 -0
- data/vendor/text/src/search.rs +1278 -341
- data/vendor/text/src/stats.rs +431 -0
- data/vendor/vector/Cargo.toml +2 -2
- data/vendor/vector/src/hooks.rs +33 -4
- data/vendor/vector/src/index.rs +498 -69
- data/vendor/wal/Cargo.toml +3 -3
- data/vendor/wal/src/feed.rs +313 -19
- data/vendor/wal/src/recovery.rs +31 -1
- data/vendor/wal/src/stream.rs +28 -0
- metadata +15 -1
data/vendor/engine/Cargo.toml
CHANGED
|
@@ -4,34 +4,34 @@
|
|
|
4
4
|
version = "1"
|
|
5
5
|
[dependencies.pigeonhole-cache]
|
|
6
6
|
path = "../cache"
|
|
7
|
-
version = "=3.0
|
|
7
|
+
version = "=3.1.0"
|
|
8
8
|
[dependencies.pigeonhole-compaction]
|
|
9
9
|
path = "../compaction"
|
|
10
|
-
version = "=3.0
|
|
10
|
+
version = "=3.1.0"
|
|
11
11
|
[dependencies.pigeonhole-format]
|
|
12
12
|
path = "../format"
|
|
13
|
-
version = "=3.0
|
|
13
|
+
version = "=3.1.0"
|
|
14
14
|
[dependencies.pigeonhole-io]
|
|
15
15
|
path = "../io"
|
|
16
|
-
version = "=3.0
|
|
16
|
+
version = "=3.1.0"
|
|
17
17
|
[dependencies.pigeonhole-memtable]
|
|
18
18
|
path = "../memtable"
|
|
19
|
-
version = "=3.0
|
|
19
|
+
version = "=3.1.0"
|
|
20
20
|
[dependencies.pigeonhole-pager]
|
|
21
21
|
path = "../pager"
|
|
22
|
-
version = "=3.0
|
|
22
|
+
version = "=3.1.0"
|
|
23
23
|
[dependencies.pigeonhole-runtime]
|
|
24
24
|
path = "../runtime"
|
|
25
|
-
version = "=3.0
|
|
25
|
+
version = "=3.1.0"
|
|
26
26
|
[dependencies.pigeonhole-shm]
|
|
27
27
|
path = "../shm"
|
|
28
|
-
version = "=3.0
|
|
28
|
+
version = "=3.1.0"
|
|
29
29
|
[dependencies.pigeonhole-sst]
|
|
30
30
|
path = "../sst"
|
|
31
|
-
version = "=3.0
|
|
31
|
+
version = "=3.1.0"
|
|
32
32
|
[dependencies.pigeonhole-wal]
|
|
33
33
|
path = "../wal"
|
|
34
|
-
version = "=3.0
|
|
34
|
+
version = "=3.1.0"
|
|
35
35
|
[dependencies.smallvec]
|
|
36
36
|
version = "1"
|
|
37
37
|
[features]
|
|
@@ -50,7 +50,7 @@ name = "pigeonhole-engine"
|
|
|
50
50
|
readme = "README.md"
|
|
51
51
|
repository = "https://github.com/CodingAnarchy/pigeonhole"
|
|
52
52
|
rust-version = "1.96"
|
|
53
|
-
version = "3.0
|
|
53
|
+
version = "3.1.0"
|
|
54
54
|
[target."cfg(engine_loom)".dependencies.loom]
|
|
55
55
|
version = "0.7"
|
|
56
56
|
[target."cfg(unix)"]
|
|
@@ -102,7 +102,9 @@ impl Admission {
|
|
|
102
102
|
/// It doesn't look at `closed`: its caller checked the engine is open just before, and
|
|
103
103
|
/// a commit charged as a close begins is answered `Closed` by its shard, which returns
|
|
104
104
|
/// the charge like any other resolution.
|
|
105
|
-
|
|
105
|
+
// Always inlined: an async commit's fast path, which the compiler stopped inlining once
|
|
106
|
+
// routing grew (#2076's commit-async).
|
|
107
|
+
#[inline(always)]
|
|
106
108
|
pub(crate) fn try_fast(&self, shard: usize, bytes: u64) -> Option<Charge> {
|
|
107
109
|
let s = &self.shards[shard];
|
|
108
110
|
if s.waiting.load(Ordering::Acquire) != 0 {
|
|
@@ -264,6 +264,12 @@ pub struct Catalog {
|
|
|
264
264
|
pub(crate) has_unknown_merge: bool,
|
|
265
265
|
/// The operators this process knows (`EngineOptions::merge_operators`).
|
|
266
266
|
registry: Arc<MergeRegistry>,
|
|
267
|
+
/// Tablets a range drop (D331) retired in this process: a flush that took one of their
|
|
268
|
+
/// memtables before the drop skips its edits, as for a dropped table's tablet, where a
|
|
269
|
+
/// split's or merge's retired tablet refuses the flush. Never persisted: after a reopen
|
|
270
|
+
/// no memtable holds a tablet the manifest no longer has (`Engine::drop_range`'s replay
|
|
271
|
+
/// note), and a drop run again after a crash fills it again.
|
|
272
|
+
range_dropped: Arc<std::collections::BTreeSet<TabletId>>,
|
|
267
273
|
}
|
|
268
274
|
|
|
269
275
|
impl Catalog {
|
|
@@ -280,6 +286,16 @@ impl Catalog {
|
|
|
280
286
|
&self.registry
|
|
281
287
|
}
|
|
282
288
|
|
|
289
|
+
/// Notes `tablets` as retired by a range drop (D331), in the drop's own catalog change.
|
|
290
|
+
pub(crate) fn note_range_dropped(&mut self, tablets: &[TabletId]) {
|
|
291
|
+
Arc::make_mut(&mut self.range_dropped).extend(tablets.iter().copied());
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/// Whether a range drop in this process retired `tablet`.
|
|
295
|
+
pub(crate) fn range_dropped(&self, tablet: TabletId) -> bool {
|
|
296
|
+
self.range_dropped.contains(&tablet)
|
|
297
|
+
}
|
|
298
|
+
|
|
283
299
|
/// Applies one edit. A tablet a `PutTablet` creates goes to shard `tablet % shards`
|
|
284
300
|
/// (a split or merge then places it with `set_shard`).
|
|
285
301
|
pub(crate) fn apply(&mut self, edit: &Edit, shards: usize) -> Result<()> {
|
|
@@ -774,9 +790,16 @@ impl Catalog {
|
|
|
774
790
|
/// Places every tablet for `shards` shards keeping each shard within `max_slots`
|
|
775
791
|
/// `(tablet, family)` slots where it can (with tablet changes on; owners are not
|
|
776
792
|
/// persisted, D130). In tablet id order, a tablet goes to shard `tablet % shards` when
|
|
777
|
-
/// that fits, else to the shard holding the fewest slots.
|
|
778
|
-
///
|
|
779
|
-
|
|
793
|
+
/// that fits, else to the shard holding the fewest slots. A tablet in `pins` (an
|
|
794
|
+
/// in-doubt external share's, D329) goes to its pinned shard first, whatever its slots.
|
|
795
|
+
/// Returns the most slots any shard ends up holding, above `max_slots` only when the
|
|
796
|
+
/// tablets fit no other way.
|
|
797
|
+
pub(crate) fn place(
|
|
798
|
+
&mut self,
|
|
799
|
+
shards: usize,
|
|
800
|
+
max_slots: usize,
|
|
801
|
+
pins: &HashMap<TabletId, ShardId>,
|
|
802
|
+
) -> usize {
|
|
780
803
|
let shards = shards.max(1);
|
|
781
804
|
let mut slots = vec![0usize; shards];
|
|
782
805
|
let widths: HashMap<TableId, usize> = self
|
|
@@ -784,7 +807,19 @@ impl Catalog {
|
|
|
784
807
|
.values()
|
|
785
808
|
.map(|t| (t.id, t.families.len()))
|
|
786
809
|
.collect();
|
|
787
|
-
|
|
810
|
+
let tablets = Arc::make_mut(&mut self.tablets);
|
|
811
|
+
for t in tablets.values_mut() {
|
|
812
|
+
if let Some(&pin) = pins.get(&t.id)
|
|
813
|
+
&& usize::from(pin.0) < shards
|
|
814
|
+
{
|
|
815
|
+
slots[usize::from(pin.0)] += widths.get(&t.table).copied().unwrap_or(0);
|
|
816
|
+
t.shard = pin;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
for t in tablets.values_mut() {
|
|
820
|
+
if pins.contains_key(&t.id) && usize::from(t.shard.0) < shards {
|
|
821
|
+
continue;
|
|
822
|
+
}
|
|
788
823
|
let width = widths.get(&t.table).copied().unwrap_or(0);
|
|
789
824
|
let preferred = usize::from(shard_for(t.id, shards).0);
|
|
790
825
|
let shard = if slots[preferred] + width <= max_slots {
|
data/vendor/engine/src/check.rs
CHANGED
|
@@ -36,7 +36,8 @@ use pigeonhole_format::superblock::{
|
|
|
36
36
|
ExtentRef, FIRST_DATA_PAGE, SUPERBLOCK_PAGE_A, SUPERBLOCK_PAGE_B, Superblock,
|
|
37
37
|
};
|
|
38
38
|
use pigeonhole_format::wal::{
|
|
39
|
-
Decoded, FRAGMENT_HEADER_LEN, FRAME_SIZE, FrameDecoder, FrameEncoder,
|
|
39
|
+
Decoded, FRAGMENT_HEADER_LEN, FRAME_SIZE, FrameDecoder, FrameEncoder, PAD_FRAGMENT,
|
|
40
|
+
SegmentHeader, WalRecord,
|
|
40
41
|
};
|
|
41
42
|
use pigeonhole_format::{BlobFileId, Cursor, Lsn, PAGE_SIZE, StreamId};
|
|
42
43
|
use pigeonhole_io::{FileRef, OpenOptions, VfsRef};
|
|
@@ -912,8 +913,12 @@ impl Checker {
|
|
|
912
913
|
|
|
913
914
|
/// Every WAL sidecar: its segment headers, then the log from the stream's checkpoint.
|
|
914
915
|
fn wal(&mut self, vfs: &VfsRef, path: &Path, catalog: Option<&Catalog>) -> Result<()> {
|
|
915
|
-
let db_id = match Pager::open(vfs, path, false) {
|
|
916
|
-
Ok(o) =>
|
|
916
|
+
let (db_id, silent_ok, xid_ok) = match Pager::open(vfs, path, false) {
|
|
917
|
+
Ok(o) => (
|
|
918
|
+
o.db_id(),
|
|
919
|
+
o.features().incompat & pigeonhole_format::wal::INCOMPAT_FEED_SILENT != 0,
|
|
920
|
+
o.features().incompat & pigeonhole_format::wal::INCOMPAT_EXTERNAL_PREPARE != 0,
|
|
921
|
+
),
|
|
917
922
|
Err(_) => return Ok(()),
|
|
918
923
|
};
|
|
919
924
|
let mut streams = pigeonhole_wal::discover_streams(vfs, path)?;
|
|
@@ -941,6 +946,8 @@ impl Checker {
|
|
|
941
946
|
file,
|
|
942
947
|
stream,
|
|
943
948
|
db_id,
|
|
949
|
+
silent_ok,
|
|
950
|
+
xid_ok,
|
|
944
951
|
findings: Vec::new(),
|
|
945
952
|
};
|
|
946
953
|
scan.run(checkpoint, &mut w)?;
|
|
@@ -957,6 +964,10 @@ struct WalScan {
|
|
|
957
964
|
file: FileRef,
|
|
958
965
|
stream: StreamId,
|
|
959
966
|
db_id: [u8; 16],
|
|
967
|
+
/// The superblock has `incompat` bit 3 (D331): a feed-silent batch's mark is taken.
|
|
968
|
+
silent_ok: bool,
|
|
969
|
+
/// The superblock has `incompat` bit 2 (D329 2b): a batch's xid trailer is taken.
|
|
970
|
+
xid_ok: bool,
|
|
960
971
|
findings: Vec<Finding>,
|
|
961
972
|
}
|
|
962
973
|
|
|
@@ -1067,7 +1078,9 @@ impl WalScan {
|
|
|
1067
1078
|
let len = dec.record().len();
|
|
1068
1079
|
last_end =
|
|
1069
1080
|
offset + FrameEncoder::new(epoch, offset).encoded_len(len) as u64;
|
|
1070
|
-
if let Err(e) =
|
|
1081
|
+
if let Err(e) =
|
|
1082
|
+
WalRecord::decode_flags(dec.record(), self.silent_ok, self.xid_ok)
|
|
1083
|
+
{
|
|
1071
1084
|
self.find(
|
|
1072
1085
|
Severity::Corruption,
|
|
1073
1086
|
Some(base + offset),
|
|
@@ -1300,22 +1313,29 @@ impl WalScan {
|
|
|
1300
1313
|
}
|
|
1301
1314
|
}
|
|
1302
1315
|
|
|
1303
|
-
/// Whether `frame` starts with a fragment of `epoch` whose checksum holds
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1316
|
+
/// Whether `frame` starts with a record's fragment of `epoch` whose checksum holds, after any
|
|
1317
|
+
/// intact pads (D327: a pad is not data, but the record it was written before is).
|
|
1318
|
+
fn fragment_ok(mut frame: &[u8], epoch: u32) -> bool {
|
|
1319
|
+
loop {
|
|
1320
|
+
if frame.len() < FRAGMENT_HEADER_LEN {
|
|
1321
|
+
return false;
|
|
1322
|
+
}
|
|
1323
|
+
let h = &frame[..FRAGMENT_HEADER_LEN];
|
|
1324
|
+
let len = usize::from(u16::from_le_bytes([h[8], h[9]]));
|
|
1325
|
+
let end = FRAGMENT_HEADER_LEN + len;
|
|
1326
|
+
let ty = h[10];
|
|
1327
|
+
let intact = u32::from_le_bytes(h[4..8].try_into().expect("4 bytes")) == epoch
|
|
1328
|
+
&& end <= frame.len()
|
|
1329
|
+
&& pigeonhole_format::checksum::crc32c_append(
|
|
1330
|
+
pigeonhole_format::checksum::crc32c(&h[4..]),
|
|
1331
|
+
&frame[FRAGMENT_HEADER_LEN..end],
|
|
1332
|
+
) == u32::from_le_bytes(h[..4].try_into().expect("4 bytes"));
|
|
1333
|
+
if intact && ty == PAD_FRAGMENT {
|
|
1334
|
+
frame = &frame[end..];
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
return intact && (1..=4).contains(&ty);
|
|
1307
1338
|
}
|
|
1308
|
-
let h = &frame[..FRAGMENT_HEADER_LEN];
|
|
1309
|
-
let len = usize::from(u16::from_le_bytes([h[8], h[9]]));
|
|
1310
|
-
let end = FRAGMENT_HEADER_LEN + len;
|
|
1311
|
-
let ty = h[10];
|
|
1312
|
-
(1..=4).contains(&ty)
|
|
1313
|
-
&& u32::from_le_bytes(h[4..8].try_into().expect("4 bytes")) == epoch
|
|
1314
|
-
&& end <= frame.len()
|
|
1315
|
-
&& pigeonhole_format::checksum::crc32c_append(
|
|
1316
|
-
pigeonhole_format::checksum::crc32c(&h[4..]),
|
|
1317
|
-
&frame[FRAGMENT_HEADER_LEN..end],
|
|
1318
|
-
) == u32::from_le_bytes(h[..4].try_into().expect("4 bytes"))
|
|
1319
1339
|
}
|
|
1320
1340
|
|
|
1321
1341
|
/// The pager's extent rules: past the reserved first pages, a power of two from 64 KiB to
|
|
@@ -1362,7 +1382,26 @@ fn names(
|
|
|
1362
1382
|
|
|
1363
1383
|
#[cfg(test)]
|
|
1364
1384
|
mod tests {
|
|
1365
|
-
use super::valid_extent;
|
|
1385
|
+
use super::{fragment_ok, valid_extent};
|
|
1386
|
+
use pigeonhole_format::wal::{FRAME_SIZE, FrameEncoder};
|
|
1387
|
+
|
|
1388
|
+
/// D327: the scan for records after a stop steps over intact pads, and finds the record
|
|
1389
|
+
/// after one; a pad with nothing valid after it is not a record.
|
|
1390
|
+
#[test]
|
|
1391
|
+
fn a_record_after_a_pad_is_found_and_a_pad_alone_is_not() {
|
|
1392
|
+
let start = FRAME_SIZE as u64 + 100;
|
|
1393
|
+
let mut enc = FrameEncoder::new(7, start);
|
|
1394
|
+
let mut out = Vec::new();
|
|
1395
|
+
assert!(enc.pad(4096, &mut out) > 0);
|
|
1396
|
+
let pad = out.len();
|
|
1397
|
+
enc.encode(b"a record", &mut out);
|
|
1398
|
+
assert!(fragment_ok(&out, 7), "a pad, then a record");
|
|
1399
|
+
assert!(!fragment_ok(&out, 8), "another epoch's");
|
|
1400
|
+
let mut torn = out.clone();
|
|
1401
|
+
torn[pad..].fill(0);
|
|
1402
|
+
assert!(!fragment_ok(&torn, 7), "a pad with zeros after it");
|
|
1403
|
+
assert!(fragment_ok(&out[pad..], 7), "the record alone");
|
|
1404
|
+
}
|
|
1366
1405
|
|
|
1367
1406
|
/// The pager's extent rules. Unreachable from a file (the manifest and superblock
|
|
1368
1407
|
/// decoders refuse such an extent first), so tested here.
|
|
@@ -563,7 +563,7 @@ pub(crate) struct CompactionWork {
|
|
|
563
563
|
/// holds. A base it can't read is not folded: the run stays apart and the read that needs it
|
|
564
564
|
/// reports the error.
|
|
565
565
|
#[derive(Debug)]
|
|
566
|
-
struct BaseBlobs(Arc<SstSet>);
|
|
566
|
+
pub(crate) struct BaseBlobs(pub(crate) Arc<SstSet>);
|
|
567
567
|
|
|
568
568
|
impl pigeonhole_compaction::BlobFetch for BaseBlobs {
|
|
569
569
|
fn fetch(&self, ptr: &pigeonhole_format::value::BlobPointer) -> Option<pigeonhole_cache::Cell> {
|
|
@@ -585,7 +585,7 @@ impl CompactionWork {
|
|
|
585
585
|
gc: GcPolicy,
|
|
586
586
|
record: Option<CompactionRecord>,
|
|
587
587
|
) -> Result<Self> {
|
|
588
|
-
let started = shared.
|
|
588
|
+
let started = shared.clock_vfs.monotonic_nanos();
|
|
589
589
|
let job = if matches!(task.kind, TaskKind::Rewrite | TaskKind::BlobGc { .. }) {
|
|
590
590
|
let priority = SstSet::priority(meta.options.cache_priority);
|
|
591
591
|
let mut inputs: Vec<Arc<SstReader>> = Vec::new();
|
|
@@ -209,6 +209,25 @@ impl Faults {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
/// One-shot callbacks for the next `Engine::open_reader` on a VFS, keyed by its address
|
|
213
|
+
/// (`Engine::on_next_reader_open`). Process-wide, since a reader being opened has no `Shared`
|
|
214
|
+
/// yet; keyed by VFS so tests running alongside never take another's.
|
|
215
|
+
static READER_OPENS: Mutex<Vec<(usize, Callback)>> = Mutex::new(Vec::new());
|
|
216
|
+
|
|
217
|
+
/// Runs the callback set for the next reader open on `vfs`, if any: between the open's
|
|
218
|
+
/// root read (`Pager::open`) and its manifest load (#2085).
|
|
219
|
+
pub(crate) fn run_reader_open(vfs: &Arc<dyn pigeonhole_io::Vfs>) {
|
|
220
|
+
let key = Arc::as_ptr(vfs).cast::<u8>() as usize;
|
|
221
|
+
let f = {
|
|
222
|
+
let mut v = READER_OPENS.lock().unwrap_or_else(PoisonError::into_inner);
|
|
223
|
+
let i = v.iter().position(|(k, _)| *k == key);
|
|
224
|
+
i.map(|i| v.swap_remove(i).1)
|
|
225
|
+
};
|
|
226
|
+
if let Some(f) = f {
|
|
227
|
+
f();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
212
231
|
/// The engine-wide hook state (`Shared::hooks`).
|
|
213
232
|
#[derive(Default)]
|
|
214
233
|
pub(crate) struct Hooks {
|
|
@@ -256,6 +275,11 @@ pub(crate) struct Hooks {
|
|
|
256
275
|
/// `Engine::park_finished_flushes`), and their wakers.
|
|
257
276
|
pub flush_done_park: AtomicBool,
|
|
258
277
|
pub flush_done_parked: Mutex<Vec<TaskWaker>>,
|
|
278
|
+
/// Holds each flush task after its SSTs and barrier, before it submits its manifest
|
|
279
|
+
/// commit (`flush::FlushTask`'s `run_stages`, `Engine::hold_flush_commits`), and the held
|
|
280
|
+
/// tasks' wakers.
|
|
281
|
+
pub flush_commit_hold: AtomicBool,
|
|
282
|
+
pub flush_commit_held: Mutex<Vec<TaskWaker>>,
|
|
259
283
|
/// Holds each compaction job before its first slice (`Engine::hold_compactions`), and
|
|
260
284
|
/// the held jobs' ids and wakers, oldest first (`Engine::release_held_compaction` takes
|
|
261
285
|
/// one to let it run; clearing the hold takes them all).
|
|
@@ -358,6 +382,10 @@ pub(crate) struct ShardCounters {
|
|
|
358
382
|
/// Entries read validation visited in the shard's memtables (`Engine::validate_entries`,
|
|
359
383
|
/// D273's tests: a hot row validates in a few entries, not one per version).
|
|
360
384
|
pub validate_entries: AtomicU64,
|
|
385
|
+
/// Cross-shard shares the shard admitted and holds until their decision
|
|
386
|
+
/// (`Engine::shares_tracked`): a test waits for a share to be admitted on a condition,
|
|
387
|
+
/// not a clock (perf2's S1 on #2058).
|
|
388
|
+
pub shares_tracked: AtomicU64,
|
|
361
389
|
/// The active shard count (`k`, D217) the shard's balancer used at its last pass, plus
|
|
362
390
|
/// one (0 before its first pass), `Engine::pack_ks`.
|
|
363
391
|
pub pack_k: AtomicU64,
|
|
@@ -446,6 +474,11 @@ pub enum AppendedKind {
|
|
|
446
474
|
Batch,
|
|
447
475
|
Prepare,
|
|
448
476
|
Commit,
|
|
477
|
+
/// An external transaction's abort (D329, WAL type 6): its `seqno` is the commit's id,
|
|
478
|
+
/// `apply_seqno` the abort's own seqno, which applies nothing.
|
|
479
|
+
Abort,
|
|
480
|
+
/// A range drop (D331, WAL type 7): its `seqno` is the drop's, which applies nothing.
|
|
481
|
+
RangeDrop,
|
|
449
482
|
}
|
|
450
483
|
|
|
451
484
|
/// One raw entry of a table (a test hook).
|
|
@@ -493,6 +526,17 @@ impl Engine {
|
|
|
493
526
|
self.inner.shared.hooks.sites.set(site, f);
|
|
494
527
|
}
|
|
495
528
|
|
|
529
|
+
/// Sets a one-shot callback for the next `open_reader` on `vfs` (test hook): it runs on
|
|
530
|
+
/// the opening thread after the open has read the root and before it loads that root's
|
|
531
|
+
/// manifest (#2085), replacing one that has not run.
|
|
532
|
+
#[doc(hidden)]
|
|
533
|
+
pub fn on_next_reader_open<V: ?Sized>(vfs: &Arc<V>, f: Box<dyn FnOnce() + Send>) {
|
|
534
|
+
let key = Arc::as_ptr(vfs).cast::<u8>() as usize;
|
|
535
|
+
let mut v = READER_OPENS.lock().unwrap_or_else(PoisonError::into_inner);
|
|
536
|
+
v.retain(|(k, _)| *k != key);
|
|
537
|
+
v.push((key, f));
|
|
538
|
+
}
|
|
539
|
+
|
|
496
540
|
/// Switches fault `fault` on or off (test hook): see [`Fault`] for each. A one-shot fault
|
|
497
541
|
/// (`Next…`) switches itself off where it fires.
|
|
498
542
|
#[doc(hidden)]
|
|
@@ -528,6 +572,41 @@ impl Engine {
|
|
|
528
572
|
n
|
|
529
573
|
}
|
|
530
574
|
|
|
575
|
+
/// How many PREPAREs `Fault::HoldPrepares` holds now (test hook).
|
|
576
|
+
#[doc(hidden)]
|
|
577
|
+
pub fn held_prepares(&self) -> usize {
|
|
578
|
+
self.inner
|
|
579
|
+
.shared
|
|
580
|
+
.hooks
|
|
581
|
+
.held_prepares
|
|
582
|
+
.lock()
|
|
583
|
+
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
|
584
|
+
.len()
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/// How many cross-shard shares shard `shard` has admitted and tracked so far, each until
|
|
588
|
+
/// its decision (test hook): a share counted here holds its rows and reads there.
|
|
589
|
+
#[doc(hidden)]
|
|
590
|
+
pub fn shares_tracked(&self, shard: usize) -> u64 {
|
|
591
|
+
self.inner.shared.metrics[shard]
|
|
592
|
+
.hooks
|
|
593
|
+
.shares_tracked
|
|
594
|
+
.load(Ordering::Relaxed)
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/// How many commit `Decide`s `Fault::HoldDecides` holds now (test hook): one held means
|
|
598
|
+
/// its coordinator decided, so every participant had prepared its share.
|
|
599
|
+
#[doc(hidden)]
|
|
600
|
+
pub fn held_decides(&self) -> usize {
|
|
601
|
+
self.inner
|
|
602
|
+
.shared
|
|
603
|
+
.hooks
|
|
604
|
+
.held_decides
|
|
605
|
+
.lock()
|
|
606
|
+
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
|
607
|
+
.len()
|
|
608
|
+
}
|
|
609
|
+
|
|
531
610
|
/// Sends the oldest `max` of the `Decide`s `Fault::HoldDecides` held, in the order they
|
|
532
611
|
/// were held; returns how many (test hook). The rest stay held, so a test can let one
|
|
533
612
|
/// decision land before another; switch `HoldDecides` off before the last release.
|
|
@@ -978,7 +1057,7 @@ impl Engine {
|
|
|
978
1057
|
/// moves leave a claimed shard alone.
|
|
979
1058
|
#[doc(hidden)]
|
|
980
1059
|
pub fn claim_shard(&self, shard: usize, passes: u64) -> bool {
|
|
981
|
-
let now = self.inner.shared.
|
|
1060
|
+
let now = self.inner.shared.clock_vfs.monotonic_nanos();
|
|
982
1061
|
self.inner.shared.loads[shard].claim(passes, u64::MAX, now)
|
|
983
1062
|
}
|
|
984
1063
|
|
|
@@ -986,7 +1065,7 @@ impl Engine {
|
|
|
986
1065
|
/// change that waits on a compaction claims nothing.
|
|
987
1066
|
#[doc(hidden)]
|
|
988
1067
|
pub fn shard_claimed(&self, shard: usize) -> bool {
|
|
989
|
-
let now = self.inner.shared.
|
|
1068
|
+
let now = self.inner.shared.clock_vfs.monotonic_nanos();
|
|
990
1069
|
!self.inner.shared.loads[shard].claimable(now)
|
|
991
1070
|
}
|
|
992
1071
|
|
|
@@ -1431,6 +1510,36 @@ impl Engine {
|
|
|
1431
1510
|
}
|
|
1432
1511
|
}
|
|
1433
1512
|
|
|
1513
|
+
/// Makes the change feed's next sidecar sync complete as failed, once, though the VFS's
|
|
1514
|
+
/// succeeded: the session's appends stop there, as on a real sync failure (#1869). A
|
|
1515
|
+
/// fault seam: a root commit's Root entry is written first, so a test can fail the sync
|
|
1516
|
+
/// alone. No effect without a change feed (test hook).
|
|
1517
|
+
#[doc(hidden)]
|
|
1518
|
+
pub fn fail_next_sidecar_sync(&self) {
|
|
1519
|
+
if let Some(f) = &self.inner.shared.feed {
|
|
1520
|
+
f.fail_next_sidecar_sync.store(true, Ordering::Release);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/// Runs `f` once, in the next root commit's observer, after that root's feed intent
|
|
1525
|
+
/// landed and before its Root entry is written (#1869): a test arms a fault there to
|
|
1526
|
+
/// fail the Root write alone, whatever the timing. A fault seam: the observer then goes
|
|
1527
|
+
/// on as always. No effect without a change feed (test hook).
|
|
1528
|
+
#[doc(hidden)]
|
|
1529
|
+
pub fn before_next_root_write(&self, f: impl FnOnce() + Send + 'static) {
|
|
1530
|
+
if let Some(feed) = &self.inner.shared.feed {
|
|
1531
|
+
feed.before_root_write.arm(Box::new(f));
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/// Whether the writer's shared-memory region says its change-feed sidecar appends
|
|
1536
|
+
/// stopped (the header's `FEED_FLAGS` bit, D315 amendment, #1869; an inspection helper
|
|
1537
|
+
/// for tests).
|
|
1538
|
+
#[doc(hidden)]
|
|
1539
|
+
pub fn shm_feed_appends_stopped(&self) -> bool {
|
|
1540
|
+
self.inner.shared.shm.feed_appends_stopped()
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1434
1543
|
/// Takes the manifest writer's exclusion on this thread, as a commit in progress holds
|
|
1435
1544
|
/// it: shards' manifest requests queue up (their pumps find it held and leave) until
|
|
1436
1545
|
/// [`release_manifest`](Self::release_manifest). Returns whether it was free (test hook).
|
|
@@ -1528,6 +1637,39 @@ impl Engine {
|
|
|
1528
1637
|
.len()
|
|
1529
1638
|
}
|
|
1530
1639
|
|
|
1640
|
+
/// While `hold` is set, a flush task that wrote its SSTs and passed its barrier waits
|
|
1641
|
+
/// before it submits its manifest commit; clearing it lets them all commit (test hook,
|
|
1642
|
+
/// D331: a range drop between a flush's memtable and its commit).
|
|
1643
|
+
#[doc(hidden)]
|
|
1644
|
+
pub fn hold_flush_commits(&self, hold: bool) {
|
|
1645
|
+
let hooks = &self.inner.shared.hooks;
|
|
1646
|
+
hooks.flush_commit_hold.store(hold, Ordering::Release);
|
|
1647
|
+
if !hold {
|
|
1648
|
+
let held = std::mem::take(
|
|
1649
|
+
&mut *hooks
|
|
1650
|
+
.flush_commit_held
|
|
1651
|
+
.lock()
|
|
1652
|
+
.unwrap_or_else(PoisonError::into_inner),
|
|
1653
|
+
);
|
|
1654
|
+
for w in held {
|
|
1655
|
+
w.wake();
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
/// How many flush tasks [`hold_flush_commits`](Self::hold_flush_commits) holds (test
|
|
1661
|
+
/// hook).
|
|
1662
|
+
#[doc(hidden)]
|
|
1663
|
+
pub fn held_flush_commits(&self) -> usize {
|
|
1664
|
+
self.inner
|
|
1665
|
+
.shared
|
|
1666
|
+
.hooks
|
|
1667
|
+
.flush_commit_held
|
|
1668
|
+
.lock()
|
|
1669
|
+
.unwrap_or_else(PoisonError::into_inner)
|
|
1670
|
+
.len()
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1531
1673
|
/// The oldest `(seqno, view version)` any reader slot of the current region generation
|
|
1532
1674
|
/// pins, and the view version the writer published last (test hook).
|
|
1533
1675
|
#[doc(hidden)]
|
|
@@ -52,6 +52,11 @@ pub struct FeedStorage {
|
|
|
52
52
|
/// Blob bytes kept only for the history's horizon: files no SST points into any more
|
|
53
53
|
/// (dead data) that a retained WAL record may still name.
|
|
54
54
|
pub held_blob_bytes: u64,
|
|
55
|
+
/// The retention the feed's last session requested before this open, if there was one
|
|
56
|
+
/// (#1786). It's the request, not what was in effect then (`retention_bytes` rounds up),
|
|
57
|
+
/// so comparing it with `retention_bytes` can miss a small drop, never report one that
|
|
58
|
+
/// didn't happen (feed1248's N1).
|
|
59
|
+
pub previous_retention_bytes: Option<u64>,
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
/// One table of [`DbInfo`].
|
|
@@ -225,6 +230,7 @@ impl Engine {
|
|
|
225
230
|
retention_bytes: f.retention_in_effect(),
|
|
226
231
|
retained_wal_bytes: f.retained_bytes(),
|
|
227
232
|
held_blob_bytes: f.held_bytes(),
|
|
233
|
+
previous_retention_bytes: f.previous_retention_bytes,
|
|
228
234
|
}),
|
|
229
235
|
tables,
|
|
230
236
|
})
|