Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
fc1e058b
Commit
fc1e058b
authored
Mar 17, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
31481bea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
6 deletions
+76
-6
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+35
-1
go/zodb/storage/fs1/format.go
go/zodb/storage/fs1/format.go
+5
-2
go/zodb/storage/fs1/py/gen-testdata
go/zodb/storage/fs1/py/gen-testdata
+36
-3
go/zodb/storage/fs1/testdata/whiteout.fs
go/zodb/storage/fs1/testdata/whiteout.fs
+0
-0
No files found.
go/zodb/storage/fs1/filestorage_test.go
View file @
fc1e058b
// Copyright (C) 2017-202
0
Nexedi SA and Contributors.
// Copyright (C) 2017-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -370,3 +370,37 @@ func TestOpenRecovery(t *testing.T) {
})
}
}
// TestLoadWhiteout verifies access to whiteout data record.
//
// Whiteout is data record with deletion when object was not previously there.
// It has both len(data)=0 and backpointer=0.
//
// TODO merge into regilat tests on testdata/1.fs when
// FileStorage/py.deleteObject allows to create whiteouts instead of raising
// POSKeyError.
func
TestLoadWhiteout
(
t
*
testing
.
T
)
{
fs
,
_
:=
xfsopen
(
t
,
"testdata/whiteout.fs"
)
defer
exc
.
XRun
(
fs
.
Close
)
xid
:=
zodb
.
Xid
{
At
:
zodb
.
Tid
(
0x17
),
Oid
:
zodb
.
Oid
(
1
)}
buf
,
serial
,
err
:=
fs
.
Load
(
context
.
Background
(),
xid
)
errOk
:=
&
zodb
.
OpError
{
URL
:
fs
.
URL
(),
Op
:
"load"
,
Args
:
xid
,
Err
:
&
zodb
.
NoDataError
{
Oid
:
xid
.
Oid
,
DeletedAt
:
xid
.
At
},
}
if
!
reflect
.
DeepEqual
(
err
,
errOk
)
{
t
.
Errorf
(
"load %s: bad err:
\n
have: %v
\n
want: %v"
,
xid
,
err
,
errOk
)
}
if
buf
!=
nil
{
t
.
Errorf
(
"load %s: buf != nil"
,
xid
)
}
if
serial
!=
0
{
t
.
Errorf
(
"load %s: bad serial %s ; want 0"
,
xid
,
serial
)
}
}
go/zodb/storage/fs1/format.go
View file @
fc1e058b
// Copyright (C) 2017-202
0
Nexedi SA and Contributors.
// Copyright (C) 2017-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -575,7 +575,10 @@ func (dh *DataHeader) LoadBackRef(r io.ReaderAt) (backPos int64, err error) {
}
backPos
=
int64
(
binary
.
BigEndian
.
Uint64
(
dh
.
workMem
[
0
:
]))
if
!
(
backPos
==
0
||
backPos
>=
dataValidFrom
)
{
if
backPos
==
0
{
return
0
,
nil
// deletion
}
if
backPos
<
dataValidFrom
{
return
0
,
checkErr
(
r
,
dh
,
"invalid backpointer: %v"
,
backPos
)
}
if
backPos
+
DataHeaderSize
>
dh
.
TxnPos
-
8
{
...
...
go/zodb/storage/fs1/py/gen-testdata
View file @
fc1e058b
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (C) 2017-202
0
Nexedi SA and Contributors.
# Copyright (C) 2017-202
1
Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -21,9 +21,10 @@
"""generate reference fs1 database and index for tests"""
from
ZODB.FileStorage
import
FileStorage
from
ZODB.FileStorage.FileStorage
import
FILESTORAGE_MAGIC
,
TxnHeader
,
DataHeader
,
TRANS_HDR_LEN
from
ZODB
import
DB
from
ZODB.Connection
import
TransactionMetaData
from
zodbtools.test.gen_testdata
import
gen_testdb
,
precommit
,
run_with_zodb
3
py2_compat
from
zodbtools.test.gen_testdata
import
gen_testdb
,
precommit
,
run_with_zodb
4
py2_compat
from
os
import
stat
,
remove
from
shutil
import
copyfile
from
golang.gcompat
import
qq
...
...
@@ -156,7 +157,7 @@ def main():
vstor
.
store
(
vroot
.
_p_oid
,
vroot
.
_p_serial
,
'000 data 000'
,
''
,
txn_stormeta
)
vstor
.
tpc_vote
(
txn_stormeta
)
# NO tpc_finish here so that status remain 'c' (voted) instead of ' ' (committed)
run_with_zodb
3
py2_compat
(
_
)
run_with_zodb
4
py2_compat
(
_
)
st
=
stat
(
outfs
)
l
=
st
.
st_size
...
...
@@ -174,5 +175,37 @@ def main():
remove
(
voted
+
".lock"
)
# prepare file with whiteout (deletion of previously non-existing object)
whiteout
=
"testdata/whiteout.fs"
# as of 20210317 FileStorage.deleteObject verifies that object exists
# -> prepare magic/transaction/data records manually
with
open
(
whiteout
,
"wb"
)
as
f
:
oid
=
p64
(
1
)
tid
=
p64
(
0x17
)
# file header
f
.
write
(
FILESTORAGE_MAGIC
)
tpos
=
f
.
tell
()
# data record (see FileStorage.deleteObject)
dh
=
DataHeader
(
oid
,
tid
,
0
,
tpos
,
0
,
0
)
drec
=
dh
.
asString
()
+
p64
(
0
)
# emit txn header (see FileStorage.tpc_vote)
tlen
=
TRANS_HDR_LEN
+
0
+
0
+
0
+
len
(
drec
)
# empty u,d,e
th
=
TxnHeader
(
tid
,
tlen
,
' '
,
0
,
0
,
0
)
th
.
user
=
b''
th
.
descr
=
b''
th
.
ext
=
b''
f
.
write
(
th
.
asString
())
# emit data record
f
.
write
(
drec
)
# emit txn tail
f
.
write
(
p64
(
tlen
))
if
__name__
==
'__main__'
:
main
()
go/zodb/storage/fs1/testdata/whiteout.fs
0 → 100644
View file @
fc1e058b
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment