open db
----
mkdir-all: db 0755
open-dir: .
sync: .
close: .
open-dir: db
close: db
open-dir: db
lock: db/LOCK
open-dir: db
open-dir: db
open-dir: db
open-dir: db
create: db/MANIFEST-000001
sync: db/MANIFEST-000001
create: db/marker.manifest.000001.MANIFEST-000001
close: db/marker.manifest.000001.MANIFEST-000001
sync: db
open-dir: db
create: db/000002.log
sync: db
create: db/marker.format-version.000001.014
close: db/marker.format-version.000001.014
sync: db
create: db/marker.format-version.000002.015
close: db/marker.format-version.000002.015
remove: db/marker.format-version.000001.014
sync: db
create: db/marker.format-version.000003.016
close: db/marker.format-version.000003.016
remove: db/marker.format-version.000002.015
sync: db
create: db/marker.format-version.000004.017
close: db/marker.format-version.000004.017
remove: db/marker.format-version.000003.016
sync: db
create: db/marker.format-version.000005.018
close: db/marker.format-version.000005.018
remove: db/marker.format-version.000004.017
sync: db
create: db/marker.format-version.000006.019
close: db/marker.format-version.000006.019
remove: db/marker.format-version.000005.018
sync: db
create: db/marker.format-version.000007.020
close: db/marker.format-version.000007.020
remove: db/marker.format-version.000006.019
sync: db
create: db/marker.format-version.000008.021
close: db/marker.format-version.000008.021
remove: db/marker.format-version.000007.020
sync: db
create: db/marker.format-version.000009.022
close: db/marker.format-version.000009.022
remove: db/marker.format-version.000008.021
sync: db
create: db/marker.format-version.000010.023
close: db/marker.format-version.000010.023
remove: db/marker.format-version.000009.022
sync: db
create: db/marker.format-version.000011.024
close: db/marker.format-version.000011.024
remove: db/marker.format-version.000010.023
sync: db
create: db/temporary.000003.dbtmp
sync: db/temporary.000003.dbtmp
close: db/temporary.000003.dbtmp
rename: db/temporary.000003.dbtmp -> db/OPTIONS-000003
sync: db

batch db
set a 1
set b 2
set c 3
----
sync-data: db/000002.log

flush db
----
sync-data: db/000002.log
close: db/000002.log
create: db/000004.log
sync: db
create: db/000005.sst
sync-data: db/000005.sst
close: db/000005.sst
sync: db
sync: db/MANIFEST-000001

batch db
set b 5
set d 7
set e 8
----
sync-data: db/000004.log

flush db
----
sync-data: db/000004.log
close: db/000004.log
reuseForWrite: db/000002.log -> db/000006.log
sync: db
create: db/000007.sst
sync-data: db/000007.sst
close: db/000007.sst
sync: db
sync: db/MANIFEST-000001

batch db
set f 9
set g 10
----
sync-data: db/000006.log

checkpoint db checkpoints/checkpoint1
----
mkdir-all: checkpoints/checkpoint1 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: .
sync: .
close: .
open-dir: checkpoints/checkpoint1
open: db/OPTIONS-000003
create: checkpoints/checkpoint1/OPTIONS-000003
sync-data: checkpoints/checkpoint1/OPTIONS-000003
close: checkpoints/checkpoint1/OPTIONS-000003
close: db/OPTIONS-000003
open-dir: checkpoints/checkpoint1
create: checkpoints/checkpoint1/marker.format-version.000001.024
sync-data: checkpoints/checkpoint1/marker.format-version.000001.024
close: checkpoints/checkpoint1/marker.format-version.000001.024
sync: checkpoints/checkpoint1
close: checkpoints/checkpoint1
link: db/000005.sst -> checkpoints/checkpoint1/000005.sst
link: db/000007.sst -> checkpoints/checkpoint1/000007.sst
open: db/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint1/MANIFEST-000001
sync-data: checkpoints/checkpoint1/MANIFEST-000001
close: checkpoints/checkpoint1/MANIFEST-000001
close: db/MANIFEST-000001
open-dir: checkpoints/checkpoint1
create: checkpoints/checkpoint1/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint1/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint1/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint1
close: checkpoints/checkpoint1
open: db/000006.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint1/000006.log
sync-data: checkpoints/checkpoint1/000006.log
close: checkpoints/checkpoint1/000006.log
close: db/000006.log
sync: checkpoints/checkpoint1
close: checkpoints/checkpoint1

checkpoint db checkpoints/checkpoint1
----
checkpoint checkpoints/checkpoint1: file already exists

# Create a checkpoint that omits SSTs that don't overlap with the [d - f) range.
checkpoint db checkpoints/checkpoint2 restrict=(d-f)
----
mkdir-all: checkpoints/checkpoint2 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint2
open: db/OPTIONS-000003
create: checkpoints/checkpoint2/OPTIONS-000003
sync-data: checkpoints/checkpoint2/OPTIONS-000003
close: checkpoints/checkpoint2/OPTIONS-000003
close: db/OPTIONS-000003
open-dir: checkpoints/checkpoint2
create: checkpoints/checkpoint2/marker.format-version.000001.024
sync-data: checkpoints/checkpoint2/marker.format-version.000001.024
close: checkpoints/checkpoint2/marker.format-version.000001.024
sync: checkpoints/checkpoint2
close: checkpoints/checkpoint2
link: db/000007.sst -> checkpoints/checkpoint2/000007.sst
open: db/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint2/MANIFEST-000001
sync-data: checkpoints/checkpoint2/MANIFEST-000001
close: checkpoints/checkpoint2/MANIFEST-000001
close: db/MANIFEST-000001
open-dir: checkpoints/checkpoint2
create: checkpoints/checkpoint2/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint2/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint2/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint2
close: checkpoints/checkpoint2
open: db/000006.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint2/000006.log
sync-data: checkpoints/checkpoint2/000006.log
close: checkpoints/checkpoint2/000006.log
close: db/000006.log
sync: checkpoints/checkpoint2
close: checkpoints/checkpoint2

# Create a checkpoint that omits SSTs that don't overlap with [a - e) and [d - f).
checkpoint db checkpoints/checkpoint3 restrict=(a-e, d-f)
----
mkdir-all: checkpoints/checkpoint3 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint3
open: db/OPTIONS-000003
create: checkpoints/checkpoint3/OPTIONS-000003
sync-data: checkpoints/checkpoint3/OPTIONS-000003
close: checkpoints/checkpoint3/OPTIONS-000003
close: db/OPTIONS-000003
open-dir: checkpoints/checkpoint3
create: checkpoints/checkpoint3/marker.format-version.000001.024
sync-data: checkpoints/checkpoint3/marker.format-version.000001.024
close: checkpoints/checkpoint3/marker.format-version.000001.024
sync: checkpoints/checkpoint3
close: checkpoints/checkpoint3
link: db/000005.sst -> checkpoints/checkpoint3/000005.sst
link: db/000007.sst -> checkpoints/checkpoint3/000007.sst
open: db/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint3/MANIFEST-000001
sync-data: checkpoints/checkpoint3/MANIFEST-000001
close: checkpoints/checkpoint3/MANIFEST-000001
close: db/MANIFEST-000001
open-dir: checkpoints/checkpoint3
create: checkpoints/checkpoint3/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint3/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint3/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint3
close: checkpoints/checkpoint3
open: db/000006.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint3/000006.log
sync-data: checkpoints/checkpoint3/000006.log
close: checkpoints/checkpoint3/000006.log
close: db/000006.log
sync: checkpoints/checkpoint3
close: checkpoints/checkpoint3

compact db
----
sync-data: db/000006.log
close: db/000006.log
reuseForWrite: db/000004.log -> db/000008.log
sync: db
create: db/000009.sst
sync-data: db/000009.sst
close: db/000009.sst
sync: db
sync: db/MANIFEST-000001
open: db/000005.sst (options: *vfs.randomReadsOption)
read-at(714, 61): db/000005.sst
read-at(663, 51): db/000005.sst
read-at(132, 531): db/000005.sst
open: db/000009.sst (options: *vfs.randomReadsOption)
read-at(711, 61): db/000009.sst
read-at(660, 51): db/000009.sst
read-at(136, 524): db/000009.sst
open: db/000007.sst (options: *vfs.randomReadsOption)
read-at(714, 61): db/000007.sst
read-at(663, 51): db/000007.sst
read-at(132, 531): db/000007.sst
read-at(91, 41): db/000005.sst
open: db/000005.sst (options: *vfs.sequentialReadsOption)
read-at(0, 91): db/000005.sst
read-at(91, 41): db/000007.sst
open: db/000007.sst (options: *vfs.sequentialReadsOption)
read-at(0, 91): db/000007.sst
create: db/000010.sst
close: db/000005.sst
read-at(95, 41): db/000009.sst
open: db/000009.sst (options: *vfs.sequentialReadsOption)
read-at(0, 95): db/000009.sst
close: db/000007.sst
close: db/000009.sst
sync-data: db/000010.sst
close: db/000010.sst
sync: db
sync: db/MANIFEST-000001
close: db/000005.sst
close: db/000007.sst
close: db/000009.sst
remove: db/000005.sst
remove: db/000007.sst
remove: db/000009.sst

batch db
set h 11
----
sync-data: db/000008.log

list db
----
000006.log
000008.log
000010.sst
LOCK
MANIFEST-000001
OPTIONS-000003
marker.format-version.000011.024
marker.manifest.000001.MANIFEST-000001

list checkpoints/checkpoint1
----
000005.sst
000006.log
000007.sst
MANIFEST-000001
OPTIONS-000003
marker.format-version.000001.024
marker.manifest.000001.MANIFEST-000001

open checkpoints/checkpoint1 readonly
----
open-dir: checkpoints/checkpoint1
lock: checkpoints/checkpoint1/LOCK
open-dir: checkpoints/checkpoint1
open-dir: checkpoints/checkpoint1
open-dir: checkpoints/checkpoint1
open-dir: checkpoints/checkpoint1
open: checkpoints/checkpoint1/MANIFEST-000001
close: checkpoints/checkpoint1/MANIFEST-000001
open-dir: checkpoints/checkpoint1
open: checkpoints/checkpoint1/OPTIONS-000003
close: checkpoints/checkpoint1/OPTIONS-000003
open: checkpoints/checkpoint1/000006.log
close: checkpoints/checkpoint1/000006.log

scan checkpoints/checkpoint1
----
open: checkpoints/checkpoint1/000007.sst (options: *vfs.randomReadsOption)
read-at(714, 61): checkpoints/checkpoint1/000007.sst
read-at(663, 51): checkpoints/checkpoint1/000007.sst
read-at(132, 531): checkpoints/checkpoint1/000007.sst
read-at(91, 41): checkpoints/checkpoint1/000007.sst
read-at(0, 91): checkpoints/checkpoint1/000007.sst
open: checkpoints/checkpoint1/000005.sst (options: *vfs.randomReadsOption)
read-at(714, 61): checkpoints/checkpoint1/000005.sst
read-at(663, 51): checkpoints/checkpoint1/000005.sst
read-at(132, 531): checkpoints/checkpoint1/000005.sst
read-at(91, 41): checkpoints/checkpoint1/000005.sst
read-at(0, 91): checkpoints/checkpoint1/000005.sst
a 1
b 5
c 3
d 7
e 8
f 9
g 10
.

scan db
----
open: db/000010.sst (options: *vfs.randomReadsOption)
read-at(724, 61): db/000010.sst
read-at(673, 51): db/000010.sst
read-at(141, 532): db/000010.sst
read-at(100, 41): db/000010.sst
read-at(0, 100): db/000010.sst
a 1
b 5
c 3
d 7
e 8
f 9
g 10
h 11
.

# This checkpoint should only contain the second SST.
list checkpoints/checkpoint2
----
000006.log
000007.sst
MANIFEST-000001
OPTIONS-000003
marker.format-version.000001.024
marker.manifest.000001.MANIFEST-000001

open checkpoints/checkpoint2 readonly
----
open-dir: checkpoints/checkpoint2
lock: checkpoints/checkpoint2/LOCK
open-dir: checkpoints/checkpoint2
open-dir: checkpoints/checkpoint2
open-dir: checkpoints/checkpoint2
open-dir: checkpoints/checkpoint2
open: checkpoints/checkpoint2/MANIFEST-000001
close: checkpoints/checkpoint2/MANIFEST-000001
open-dir: checkpoints/checkpoint2
open: checkpoints/checkpoint2/OPTIONS-000003
close: checkpoints/checkpoint2/OPTIONS-000003
open: checkpoints/checkpoint2/000006.log
close: checkpoints/checkpoint2/000006.log

scan checkpoints/checkpoint2
----
open: checkpoints/checkpoint2/000007.sst (options: *vfs.randomReadsOption)
read-at(714, 61): checkpoints/checkpoint2/000007.sst
read-at(663, 51): checkpoints/checkpoint2/000007.sst
read-at(132, 531): checkpoints/checkpoint2/000007.sst
read-at(91, 41): checkpoints/checkpoint2/000007.sst
read-at(0, 91): checkpoints/checkpoint2/000007.sst
b 5
d 7
e 8
f 9
g 10
.

# This checkpoint should contain both SSTs.
list checkpoints/checkpoint3
----
000005.sst
000006.log
000007.sst
MANIFEST-000001
OPTIONS-000003
marker.format-version.000001.024
marker.manifest.000001.MANIFEST-000001

open checkpoints/checkpoint3 readonly
----
open-dir: checkpoints/checkpoint3
lock: checkpoints/checkpoint3/LOCK
open-dir: checkpoints/checkpoint3
open-dir: checkpoints/checkpoint3
open-dir: checkpoints/checkpoint3
open-dir: checkpoints/checkpoint3
open: checkpoints/checkpoint3/MANIFEST-000001
close: checkpoints/checkpoint3/MANIFEST-000001
open-dir: checkpoints/checkpoint3
open: checkpoints/checkpoint3/OPTIONS-000003
close: checkpoints/checkpoint3/OPTIONS-000003
open: checkpoints/checkpoint3/000006.log
close: checkpoints/checkpoint3/000006.log

scan checkpoints/checkpoint3
----
open: checkpoints/checkpoint3/000007.sst (options: *vfs.randomReadsOption)
read-at(714, 61): checkpoints/checkpoint3/000007.sst
read-at(663, 51): checkpoints/checkpoint3/000007.sst
read-at(132, 531): checkpoints/checkpoint3/000007.sst
read-at(91, 41): checkpoints/checkpoint3/000007.sst
read-at(0, 91): checkpoints/checkpoint3/000007.sst
open: checkpoints/checkpoint3/000005.sst (options: *vfs.randomReadsOption)
read-at(714, 61): checkpoints/checkpoint3/000005.sst
read-at(663, 51): checkpoints/checkpoint3/000005.sst
read-at(132, 531): checkpoints/checkpoint3/000005.sst
read-at(91, 41): checkpoints/checkpoint3/000005.sst
read-at(0, 91): checkpoints/checkpoint3/000005.sst
a 1
b 5
c 3
d 7
e 8
f 9
g 10
.

# Test virtual sstable checkpointing. Virtual sstable checkpointing will remove
# the backing files which won't be required by the checkpoint. Need to make sure
# that the virtual sstables which are present in the checkpoint manifest are
# still readable, and that the backing files not required are deleted.

lsm db
----
L6:
  000010:[a#0,SET-g#0,SET]

build db ext1 table-format=Pebble,v2
set i i
set j j
set k k
----

ingest-and-excise db ext1 excise=c-d
----

# 12, 13 are virtual sstables.
lsm db
----
L6:
  000012(000010):[a#0,SET-b#0,SET]
  000013(000010):[d#0,SET-g#0,SET]
  000011:[i#20,SET-k#20,SET]

build db ext2 table-format=Pebble,v2
set z z
----

ingest-and-excise db ext2 excise=j-k
----

# 12, 13, 15, 16 are virtual.
lsm db
----
L6:
  000012(000010):[a#0,SET-b#0,SET]
  000013(000010):[d#0,SET-g#0,SET]
  000015(000011):[i#20,SET-i#20,SET]
  000016(000011):[k#20,SET-k#20,SET]
  000014:[z#22,SET-z#22,SET]

# scan db so that it is known what to expect from the checkpoints.
scan db
----
a 1
b 5
d 7
e 8
f 9
g 10
h 11
i i
k k
open: db/000014.sst (options: *vfs.randomReadsOption)
read-at(501, 61): db/000014.sst
read-at(472, 37): db/000014.sst
read-at(53, 419): db/000014.sst
z z
.

# Create a basic checkpoint to see if virtual sstables can be read.
checkpoint db checkpoints/checkpoint4
----
mkdir-all: checkpoints/checkpoint4 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint4
open: db/OPTIONS-000003
create: checkpoints/checkpoint4/OPTIONS-000003
sync-data: checkpoints/checkpoint4/OPTIONS-000003
close: checkpoints/checkpoint4/OPTIONS-000003
close: db/OPTIONS-000003
open-dir: checkpoints/checkpoint4
create: checkpoints/checkpoint4/marker.format-version.000001.024
sync-data: checkpoints/checkpoint4/marker.format-version.000001.024
close: checkpoints/checkpoint4/marker.format-version.000001.024
sync: checkpoints/checkpoint4
close: checkpoints/checkpoint4
link: db/000010.sst -> checkpoints/checkpoint4/000010.sst
link: db/000011.sst -> checkpoints/checkpoint4/000011.sst
link: db/000014.sst -> checkpoints/checkpoint4/000014.sst
open: db/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint4/MANIFEST-000001
sync-data: checkpoints/checkpoint4/MANIFEST-000001
close: checkpoints/checkpoint4/MANIFEST-000001
close: db/MANIFEST-000001
open-dir: checkpoints/checkpoint4
create: checkpoints/checkpoint4/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint4/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint4/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint4
close: checkpoints/checkpoint4
open: db/000008.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint4/000008.log
sync-data: checkpoints/checkpoint4/000008.log
close: checkpoints/checkpoint4/000008.log
close: db/000008.log
sync: checkpoints/checkpoint4
close: checkpoints/checkpoint4

open checkpoints/checkpoint4 readonly
----
open-dir: checkpoints/checkpoint4
lock: checkpoints/checkpoint4/LOCK
open-dir: checkpoints/checkpoint4
open-dir: checkpoints/checkpoint4
open-dir: checkpoints/checkpoint4
open-dir: checkpoints/checkpoint4
open: checkpoints/checkpoint4/MANIFEST-000001
close: checkpoints/checkpoint4/MANIFEST-000001
open-dir: checkpoints/checkpoint4
open: checkpoints/checkpoint4/OPTIONS-000003
close: checkpoints/checkpoint4/OPTIONS-000003
open: checkpoints/checkpoint4/000008.log
close: checkpoints/checkpoint4/000008.log

scan checkpoints/checkpoint4
----
open: checkpoints/checkpoint4/000010.sst (options: *vfs.randomReadsOption)
read-at(724, 61): checkpoints/checkpoint4/000010.sst
read-at(673, 51): checkpoints/checkpoint4/000010.sst
read-at(141, 532): checkpoints/checkpoint4/000010.sst
read-at(100, 41): checkpoints/checkpoint4/000010.sst
read-at(0, 100): checkpoints/checkpoint4/000010.sst
a 1
b 5
d 7
e 8
f 9
g 10
open: checkpoints/checkpoint4/000011.sst (options: *vfs.randomReadsOption)
read-at(518, 61): checkpoints/checkpoint4/000011.sst
read-at(489, 37): checkpoints/checkpoint4/000011.sst
read-at(70, 419): checkpoints/checkpoint4/000011.sst
read-at(43, 27): checkpoints/checkpoint4/000011.sst
read-at(0, 43): checkpoints/checkpoint4/000011.sst
h 11
i i
k k
open: checkpoints/checkpoint4/000014.sst (options: *vfs.randomReadsOption)
read-at(501, 61): checkpoints/checkpoint4/000014.sst
read-at(472, 37): checkpoints/checkpoint4/000014.sst
read-at(53, 419): checkpoints/checkpoint4/000014.sst
read-at(26, 27): checkpoints/checkpoint4/000014.sst
read-at(0, 26): checkpoints/checkpoint4/000014.sst
z z
.

close checkpoints/checkpoint4
----


# Backing sst 10 is in the list as it is backing sstables 12, 13.
list db
----
000006.log
000008.log
000010.sst
000011.sst
000014.sst
LOCK
MANIFEST-000001
OPTIONS-000003
marker.format-version.000011.024
marker.manifest.000001.MANIFEST-000001


# Exclude virtual sstable 12. The backing sst should still be present on disk
# in the checkpoint. See the "link: db/000010.sst" line.
checkpoint db checkpoints/checkpoint5 restrict=(d-zz)
----
mkdir-all: checkpoints/checkpoint5 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint5
open: db/OPTIONS-000003
create: checkpoints/checkpoint5/OPTIONS-000003
sync-data: checkpoints/checkpoint5/OPTIONS-000003
close: checkpoints/checkpoint5/OPTIONS-000003
close: db/OPTIONS-000003
open-dir: checkpoints/checkpoint5
create: checkpoints/checkpoint5/marker.format-version.000001.024
sync-data: checkpoints/checkpoint5/marker.format-version.000001.024
close: checkpoints/checkpoint5/marker.format-version.000001.024
sync: checkpoints/checkpoint5
close: checkpoints/checkpoint5
link: db/000010.sst -> checkpoints/checkpoint5/000010.sst
link: db/000011.sst -> checkpoints/checkpoint5/000011.sst
link: db/000014.sst -> checkpoints/checkpoint5/000014.sst
open: db/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint5/MANIFEST-000001
sync-data: checkpoints/checkpoint5/MANIFEST-000001
close: checkpoints/checkpoint5/MANIFEST-000001
close: db/MANIFEST-000001
open-dir: checkpoints/checkpoint5
create: checkpoints/checkpoint5/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint5/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint5/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint5
close: checkpoints/checkpoint5
open: db/000008.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint5/000008.log
sync-data: checkpoints/checkpoint5/000008.log
close: checkpoints/checkpoint5/000008.log
close: db/000008.log
sync: checkpoints/checkpoint5
close: checkpoints/checkpoint5

open checkpoints/checkpoint5
----
mkdir-all: checkpoints/checkpoint5 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint5
close: checkpoints/checkpoint5
open-dir: checkpoints/checkpoint5
lock: checkpoints/checkpoint5/LOCK
open-dir: checkpoints/checkpoint5
open-dir: checkpoints/checkpoint5
open-dir: checkpoints/checkpoint5
open-dir: checkpoints/checkpoint5
open: checkpoints/checkpoint5/MANIFEST-000001
close: checkpoints/checkpoint5/MANIFEST-000001
open-dir: checkpoints/checkpoint5
open: checkpoints/checkpoint5/OPTIONS-000003
close: checkpoints/checkpoint5/OPTIONS-000003
open: checkpoints/checkpoint5/000008.log
close: checkpoints/checkpoint5/000008.log
create: checkpoints/checkpoint5/000018.sst
sync-data: checkpoints/checkpoint5/000018.sst
close: checkpoints/checkpoint5/000018.sst
sync: checkpoints/checkpoint5
create: checkpoints/checkpoint5/MANIFEST-000019
sync: checkpoints/checkpoint5/MANIFEST-000019
create: checkpoints/checkpoint5/marker.manifest.000002.MANIFEST-000019
close: checkpoints/checkpoint5/marker.manifest.000002.MANIFEST-000019
remove: checkpoints/checkpoint5/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint5
remove: checkpoints/checkpoint5/000008.log
create: checkpoints/checkpoint5/000020.log
sync: checkpoints/checkpoint5
create: checkpoints/checkpoint5/temporary.000021.dbtmp
sync: checkpoints/checkpoint5/temporary.000021.dbtmp
close: checkpoints/checkpoint5/temporary.000021.dbtmp
rename: checkpoints/checkpoint5/temporary.000021.dbtmp -> checkpoints/checkpoint5/OPTIONS-000021
sync: checkpoints/checkpoint5
remove: checkpoints/checkpoint5/OPTIONS-000003

print-backing checkpoints/checkpoint5
----
000010
000011

# sstable 12 is gone.
lsm checkpoints/checkpoint5
----
L0.0:
  000018:[h#18,SET-h#18,SET]
L6:
  000013(000010):[d#0,SET-g#0,SET]
  000015(000011):[i#20,SET-i#20,SET]
  000016(000011):[k#20,SET-k#20,SET]
  000014:[z#22,SET-z#22,SET]

close checkpoints/checkpoint5
----

# Exclude both sstables 12 and 13. The backing sstable 10 should not be linked.
# There should be a remove backing table entry for backing sstable 10.
checkpoint db checkpoints/checkpoint6 restrict=(i-zz)
----
mkdir-all: checkpoints/checkpoint6 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint6
open: db/OPTIONS-000003
create: checkpoints/checkpoint6/OPTIONS-000003
sync-data: checkpoints/checkpoint6/OPTIONS-000003
close: checkpoints/checkpoint6/OPTIONS-000003
close: db/OPTIONS-000003
open-dir: checkpoints/checkpoint6
create: checkpoints/checkpoint6/marker.format-version.000001.024
sync-data: checkpoints/checkpoint6/marker.format-version.000001.024
close: checkpoints/checkpoint6/marker.format-version.000001.024
sync: checkpoints/checkpoint6
close: checkpoints/checkpoint6
link: db/000011.sst -> checkpoints/checkpoint6/000011.sst
link: db/000014.sst -> checkpoints/checkpoint6/000014.sst
open: db/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint6/MANIFEST-000001
sync-data: checkpoints/checkpoint6/MANIFEST-000001
close: checkpoints/checkpoint6/MANIFEST-000001
close: db/MANIFEST-000001
open-dir: checkpoints/checkpoint6
create: checkpoints/checkpoint6/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint6/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint6/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint6
close: checkpoints/checkpoint6
open: db/000008.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint6/000008.log
sync-data: checkpoints/checkpoint6/000008.log
close: checkpoints/checkpoint6/000008.log
close: db/000008.log
sync: checkpoints/checkpoint6
close: checkpoints/checkpoint6

open checkpoints/checkpoint6
----
mkdir-all: checkpoints/checkpoint6 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint6
close: checkpoints/checkpoint6
open-dir: checkpoints/checkpoint6
lock: checkpoints/checkpoint6/LOCK
open-dir: checkpoints/checkpoint6
open-dir: checkpoints/checkpoint6
open-dir: checkpoints/checkpoint6
open-dir: checkpoints/checkpoint6
open: checkpoints/checkpoint6/MANIFEST-000001
close: checkpoints/checkpoint6/MANIFEST-000001
open-dir: checkpoints/checkpoint6
open: checkpoints/checkpoint6/OPTIONS-000003
close: checkpoints/checkpoint6/OPTIONS-000003
open: checkpoints/checkpoint6/000008.log
close: checkpoints/checkpoint6/000008.log
create: checkpoints/checkpoint6/000018.sst
sync-data: checkpoints/checkpoint6/000018.sst
close: checkpoints/checkpoint6/000018.sst
sync: checkpoints/checkpoint6
create: checkpoints/checkpoint6/MANIFEST-000019
sync: checkpoints/checkpoint6/MANIFEST-000019
create: checkpoints/checkpoint6/marker.manifest.000002.MANIFEST-000019
close: checkpoints/checkpoint6/marker.manifest.000002.MANIFEST-000019
remove: checkpoints/checkpoint6/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint6
remove: checkpoints/checkpoint6/000008.log
create: checkpoints/checkpoint6/000020.log
sync: checkpoints/checkpoint6
create: checkpoints/checkpoint6/temporary.000021.dbtmp
sync: checkpoints/checkpoint6/temporary.000021.dbtmp
close: checkpoints/checkpoint6/temporary.000021.dbtmp
rename: checkpoints/checkpoint6/temporary.000021.dbtmp -> checkpoints/checkpoint6/OPTIONS-000021
sync: checkpoints/checkpoint6
remove: checkpoints/checkpoint6/OPTIONS-000003

print-backing checkpoints/checkpoint6
----
000011

lsm checkpoints/checkpoint6
----
L0.0:
  000018:[h#18,SET-h#18,SET]
L6:
  000015(000011):[i#20,SET-i#20,SET]
  000016(000011):[k#20,SET-k#20,SET]
  000014:[z#22,SET-z#22,SET]

# Close and re-open db, this time with WAL failover configured and the secondary
# pointing to /failover-logs.

open db wal-failover=/failover-logs nondeterministic
----

# Perform a checkpoint.
checkpoint db checkpoints/checkpoint7 nondeterministic
----

# Close the database.

close db
----

# Validate that we can open the checkpoint.

open checkpoints/checkpoint7 readonly nondeterministic
----

lsm checkpoints/checkpoint7
----
L0.0:
  000018:[h#18,SET-h#18,SET]
L6:
  000012(000010):[a#0,SET-b#0,SET]
  000013(000010):[d#0,SET-g#0,SET]
  000015(000011):[i#20,SET-i#20,SET]
  000016(000011):[k#20,SET-k#20,SET]
  000014:[z#22,SET-z#22,SET]

# Create a new database with value separation enabled to test that blob files
# are included in checkpoints.

open valsepdb value-separation=(true,1,5,0s,1.0)
----
mkdir-all: valsepdb 0755
open-dir: .
sync: .
close: .
open-dir: valsepdb
close: valsepdb
open-dir: valsepdb
lock: valsepdb/LOCK
open-dir: valsepdb
open-dir: valsepdb
open-dir: valsepdb
open-dir: valsepdb
create: valsepdb/MANIFEST-000001
sync: valsepdb/MANIFEST-000001
create: valsepdb/marker.manifest.000001.MANIFEST-000001
close: valsepdb/marker.manifest.000001.MANIFEST-000001
sync: valsepdb
open-dir: valsepdb
create: valsepdb/000002.log
sync: valsepdb
create: valsepdb/marker.format-version.000001.014
close: valsepdb/marker.format-version.000001.014
sync: valsepdb
create: valsepdb/marker.format-version.000002.015
close: valsepdb/marker.format-version.000002.015
remove: valsepdb/marker.format-version.000001.014
sync: valsepdb
create: valsepdb/marker.format-version.000003.016
close: valsepdb/marker.format-version.000003.016
remove: valsepdb/marker.format-version.000002.015
sync: valsepdb
create: valsepdb/marker.format-version.000004.017
close: valsepdb/marker.format-version.000004.017
remove: valsepdb/marker.format-version.000003.016
sync: valsepdb
create: valsepdb/marker.format-version.000005.018
close: valsepdb/marker.format-version.000005.018
remove: valsepdb/marker.format-version.000004.017
sync: valsepdb
create: valsepdb/marker.format-version.000006.019
close: valsepdb/marker.format-version.000006.019
remove: valsepdb/marker.format-version.000005.018
sync: valsepdb
create: valsepdb/marker.format-version.000007.020
close: valsepdb/marker.format-version.000007.020
remove: valsepdb/marker.format-version.000006.019
sync: valsepdb
create: valsepdb/marker.format-version.000008.021
close: valsepdb/marker.format-version.000008.021
remove: valsepdb/marker.format-version.000007.020
sync: valsepdb
create: valsepdb/marker.format-version.000009.022
close: valsepdb/marker.format-version.000009.022
remove: valsepdb/marker.format-version.000008.021
sync: valsepdb
create: valsepdb/marker.format-version.000010.023
close: valsepdb/marker.format-version.000010.023
remove: valsepdb/marker.format-version.000009.022
sync: valsepdb
create: valsepdb/marker.format-version.000011.024
close: valsepdb/marker.format-version.000011.024
remove: valsepdb/marker.format-version.000010.023
sync: valsepdb
create: valsepdb/temporary.000003.dbtmp
sync: valsepdb/temporary.000003.dbtmp
close: valsepdb/temporary.000003.dbtmp
rename: valsepdb/temporary.000003.dbtmp -> valsepdb/OPTIONS-000003
sync: valsepdb

batch valsepdb
set a a
set b b
set c c
set d d
set e e
set f f
----
sync-data: valsepdb/000002.log

# The flush creates a blob file.

flush valsepdb
----
sync-data: valsepdb/000002.log
close: valsepdb/000002.log
create: valsepdb/000004.log
sync: valsepdb
create: valsepdb/000005.sst
create: valsepdb/000006.blob
sync-data: valsepdb/000006.blob
close: valsepdb/000006.blob
sync-data: valsepdb/000005.sst
close: valsepdb/000005.sst
sync: valsepdb
sync: valsepdb/MANIFEST-000001

# Perform a checkpoint. It should include the blob file.

checkpoint valsepdb checkpoints/checkpoint8
----
mkdir-all: checkpoints/checkpoint8 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint8
open: valsepdb/OPTIONS-000003
create: checkpoints/checkpoint8/OPTIONS-000003
sync-data: checkpoints/checkpoint8/OPTIONS-000003
close: checkpoints/checkpoint8/OPTIONS-000003
close: valsepdb/OPTIONS-000003
open-dir: checkpoints/checkpoint8
create: checkpoints/checkpoint8/marker.format-version.000001.024
sync-data: checkpoints/checkpoint8/marker.format-version.000001.024
close: checkpoints/checkpoint8/marker.format-version.000001.024
sync: checkpoints/checkpoint8
close: checkpoints/checkpoint8
link: valsepdb/000006.blob -> checkpoints/checkpoint8/000006.blob
link: valsepdb/000005.sst -> checkpoints/checkpoint8/000005.sst
open: valsepdb/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint8/MANIFEST-000001
sync-data: checkpoints/checkpoint8/MANIFEST-000001
close: checkpoints/checkpoint8/MANIFEST-000001
close: valsepdb/MANIFEST-000001
open-dir: checkpoints/checkpoint8
create: checkpoints/checkpoint8/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint8/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint8/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint8
close: checkpoints/checkpoint8
open: valsepdb/000004.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint8/000004.log
sync-data: checkpoints/checkpoint8/000004.log
close: checkpoints/checkpoint8/000004.log
close: valsepdb/000004.log
sync: checkpoints/checkpoint8
close: checkpoints/checkpoint8

# Validate that we can open the checkpoint.

open checkpoints/checkpoint8 readonly
----
open-dir: checkpoints/checkpoint8
lock: checkpoints/checkpoint8/LOCK
open-dir: checkpoints/checkpoint8
open-dir: checkpoints/checkpoint8
open-dir: checkpoints/checkpoint8
open-dir: checkpoints/checkpoint8
open: checkpoints/checkpoint8/MANIFEST-000001
close: checkpoints/checkpoint8/MANIFEST-000001
open-dir: checkpoints/checkpoint8
open: checkpoints/checkpoint8/OPTIONS-000003
close: checkpoints/checkpoint8/OPTIONS-000003
open: checkpoints/checkpoint8/000004.log
close: checkpoints/checkpoint8/000004.log

# Ensure that we can read values contained in the blob file.

scan checkpoints/checkpoint8
----
open: checkpoints/checkpoint8/000005.sst (options: *vfs.randomReadsOption)
read-at(862, 61): checkpoints/checkpoint8/000005.sst
read-at(785, 77): checkpoints/checkpoint8/000005.sst
read-at(197, 588): checkpoints/checkpoint8/000005.sst
read-at(131, 41): checkpoints/checkpoint8/000005.sst
read-at(0, 131): checkpoints/checkpoint8/000005.sst
open: checkpoints/checkpoint8/000006.blob (options: *vfs.randomReadsOption)
read-at(62, 38): checkpoints/checkpoint8/000006.blob
read-at(32, 30): checkpoints/checkpoint8/000006.blob
read-at(0, 32): checkpoints/checkpoint8/000006.blob
a a
b b
c c
d d
e e
f f
.

close checkpoints/checkpoint8
----

# Write and flush new keys.

batch valsepdb
set m m
set n n
set o o
set p p
set q q
set r r
----
sync-data: valsepdb/000004.log

flush valsepdb
----
sync-data: valsepdb/000004.log
close: valsepdb/000004.log
reuseForWrite: valsepdb/000002.log -> valsepdb/000007.log
sync: valsepdb
create: valsepdb/000008.sst
create: valsepdb/000009.blob
sync-data: valsepdb/000009.blob
close: valsepdb/000009.blob
sync-data: valsepdb/000008.sst
close: valsepdb/000008.sst
sync: valsepdb
sync: valsepdb/MANIFEST-000001


# Create a checkpoint that omits SSTs that don't overlap with the [a - c) range.
# Blob file 000009.blob is not included because all the referencing tables are
# exlcuded.

checkpoint valsepdb checkpoints/checkpoint9 restrict=(a-c)
----
mkdir-all: checkpoints/checkpoint9 0755
open-dir: checkpoints
sync: checkpoints
close: checkpoints
open-dir: checkpoints/checkpoint9
open: valsepdb/OPTIONS-000003
create: checkpoints/checkpoint9/OPTIONS-000003
sync-data: checkpoints/checkpoint9/OPTIONS-000003
close: checkpoints/checkpoint9/OPTIONS-000003
close: valsepdb/OPTIONS-000003
open-dir: checkpoints/checkpoint9
create: checkpoints/checkpoint9/marker.format-version.000001.024
sync-data: checkpoints/checkpoint9/marker.format-version.000001.024
close: checkpoints/checkpoint9/marker.format-version.000001.024
sync: checkpoints/checkpoint9
close: checkpoints/checkpoint9
link: valsepdb/000006.blob -> checkpoints/checkpoint9/000006.blob
link: valsepdb/000005.sst -> checkpoints/checkpoint9/000005.sst
open: valsepdb/MANIFEST-000001 (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint9/MANIFEST-000001
sync-data: checkpoints/checkpoint9/MANIFEST-000001
close: checkpoints/checkpoint9/MANIFEST-000001
close: valsepdb/MANIFEST-000001
open-dir: checkpoints/checkpoint9
create: checkpoints/checkpoint9/marker.manifest.000001.MANIFEST-000001
sync-data: checkpoints/checkpoint9/marker.manifest.000001.MANIFEST-000001
close: checkpoints/checkpoint9/marker.manifest.000001.MANIFEST-000001
sync: checkpoints/checkpoint9
close: checkpoints/checkpoint9
open: valsepdb/000007.log (options: *vfs.sequentialReadsOption)
create: checkpoints/checkpoint9/000007.log
sync-data: checkpoints/checkpoint9/000007.log
close: checkpoints/checkpoint9/000007.log
close: valsepdb/000007.log
sync: checkpoints/checkpoint9
close: checkpoints/checkpoint9

open checkpoints/checkpoint9 readonly
----
open-dir: checkpoints/checkpoint9
lock: checkpoints/checkpoint9/LOCK
open-dir: checkpoints/checkpoint9
open-dir: checkpoints/checkpoint9
open-dir: checkpoints/checkpoint9
open-dir: checkpoints/checkpoint9
open: checkpoints/checkpoint9/MANIFEST-000001
close: checkpoints/checkpoint9/MANIFEST-000001
open-dir: checkpoints/checkpoint9
open: checkpoints/checkpoint9/OPTIONS-000003
close: checkpoints/checkpoint9/OPTIONS-000003
open: checkpoints/checkpoint9/000007.log
close: checkpoints/checkpoint9/000007.log

scan checkpoints/checkpoint9
----
open: checkpoints/checkpoint9/000005.sst (options: *vfs.randomReadsOption)
read-at(862, 61): checkpoints/checkpoint9/000005.sst
read-at(785, 77): checkpoints/checkpoint9/000005.sst
read-at(197, 588): checkpoints/checkpoint9/000005.sst
read-at(131, 41): checkpoints/checkpoint9/000005.sst
read-at(0, 131): checkpoints/checkpoint9/000005.sst
open: checkpoints/checkpoint9/000006.blob (options: *vfs.randomReadsOption)
read-at(62, 38): checkpoints/checkpoint9/000006.blob
read-at(32, 30): checkpoints/checkpoint9/000006.blob
read-at(0, 32): checkpoints/checkpoint9/000006.blob
a a
b b
c c
d d
e e
f f
.

close checkpoints/checkpoint9
----
