Commit a2b8516c authored by Kirill Smelkov's avatar Kirill Smelkov

go/neo/proto: Don't require deletedAt to be present in OID_NOT_FOUND

Providing deletedAt in addition to oid in OID_NOT_FOUND error is NEO/go extension.
NEO/py sends only OidNotFound(oid):

https://lab.nexedi.com/nexedi/neoppod/blob/v1.12-0-g6332112c/neo/storage/handlers/client.py#L70-72

-> decode deletedAt only if it is present.

Since inspecting NEO/py codebase turned out that message always comes
with oid, remove the "abusing" words about this approach to convey oid
via error message for OID_NOT_FOUND and OID_DOES_NOT_EXIST.

Without this patch TestLoad was failing as

    === RUN   TestLoad/py
    I: runneo.py: /tmp/neo124851059/1: started master(s): 127.0.0.1:19681
        xtesting.go:306: load 0285cbac258bf265:0000000000000000: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbac258bf265:0000000000000000: OID_NOT_FOUND: 0000000000000000
            want: neo://1@127.0.0.1:19681: load 0285cbac258bf265:0000000000000000: 0000000000000000: object was not yet created
        xtesting.go:306: load 0285cbac3d0369e5:0000000000000001: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbac3d0369e5:0000000000000001: OID_NOT_FOUND: 0000000000000001
            want: neo://1@127.0.0.1:19681: load 0285cbac3d0369e5:0000000000000001: 0000000000000001: object was not yet created
        xtesting.go:306: load 0285cbac41b4e832:0000000000000002: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbac41b4e832:0000000000000002: OID_NOT_FOUND: 0000000000000002
            want: neo://1@127.0.0.1:19681: load 0285cbac41b4e832:0000000000000002: 0000000000000002: object was not yet created
        xtesting.go:306: load 0285cbac4666667f:0000000000000003: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbac4666667f:0000000000000003: OID_NOT_FOUND: 0000000000000003
            want: neo://1@127.0.0.1:19681: load 0285cbac4666667f:0000000000000003: 0000000000000003: object was not yet created
        xtesting.go:306: load 0285cbac4fc96318:0000000000000004: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbac4fc96318:0000000000000004: OID_NOT_FOUND: 0000000000000004
            want: neo://1@127.0.0.1:19681: load 0285cbac4fc96318:0000000000000004: 0000000000000004: object was not yet created
        xtesting.go:306: load 0285cbac547ae165:0000000000000005: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbac547ae165:0000000000000005: OID_NOT_FOUND: 0000000000000005
            want: neo://1@127.0.0.1:19681: load 0285cbac547ae165:0000000000000005: 0000000000000005: object was not yet created
        xtesting.go:306: load 0285cbac628f5c4b:0000000000000006: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbac628f5c4b:0000000000000006: OID_NOT_FOUND: 0000000000000006
            want: neo://1@127.0.0.1:19681: load 0285cbac628f5c4b:0000000000000006: 0000000000000006: object was not yet created
        xtesting.go:306: load 0285cbaca444447f:0000000000000007: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbaca444447f:0000000000000007: OID_NOT_FOUND: 0000000000000007
            want: neo://1@127.0.0.1:19681: load 0285cbaca444447f:0000000000000007: 0000000000000007: object was not yet created
        xtesting.go:306: load 0285cbacbbbbbbff:0000000000000008: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbacbbbbbbff:0000000000000008: OID_NOT_FOUND: 0000000000000008
            want: neo://1@127.0.0.1:19681: load 0285cbacbbbbbbff:0000000000000008: 0000000000000008: object was not yet created
        xtesting.go:306: load 0285cbad80da7498:0000000000000009: returned err unexpected:
            have: neo://1@127.0.0.1:19681: load 0285cbad80da7498:0000000000000009: OID_NOT_FOUND: 0000000000000009
            want: neo://1@127.0.0.1:19681: load 0285cbad80da7498:0000000000000009: 0000000000000009: object was not yet created
parent dacce3d1
......@@ -43,14 +43,14 @@ func ZODBErrEncode(err error) *Error {
switch err := err.(type) {
case *zodb.NoDataError:
// XXX abusing message for oid, deletedAt
// message: oid(,deletedAt)?
return &Error{
Code: OID_NOT_FOUND,
Message: err.Oid.String() + "," + err.DeletedAt.String(),
}
case *zodb.NoObjectError:
// XXX abusing message for oid
// message: oid
return &Error{Code: OID_DOES_NOT_EXIST, Message: err.Oid.String()}
default:
......@@ -66,20 +66,25 @@ func ZODBErrEncode(err error) *Error {
func ZODBErrDecode(e *Error) error {
switch e.Code {
case OID_NOT_FOUND:
// XXX abusing message for oid, deletedAt
// message: oid(,deletedAt)?
zerr := &zodb.NoDataError{}
argv := strings.Split(e.Message, ",")
if len(argv) != 2 {
var err error
zerr.Oid, err = zodb.ParseOid(argv[0])
if err != nil {
break
}
oid, err0 := zodb.ParseOid(argv[0])
del, err1 := zodb.ParseTid(argv[1])
if !(err0 == nil && err1 == nil) {
break
if len(argv) >= 2 {
zerr.DeletedAt, err = zodb.ParseTid(argv[1])
if err != nil {
break
}
}
return &zodb.NoDataError{Oid: oid, DeletedAt: del}
return zerr
case OID_DOES_NOT_EXIST:
oid, err := zodb.ParseOid(e.Message) // XXX abusing message for oid
// message: oid
oid, err := zodb.ParseOid(e.Message)
if err == nil {
return &zodb.NoObjectError{oid}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment