AppEngine IO I / O error results in API error 10 (file: FILE_NOT_OPENED) "

My GoLang The AppEngine code unpacks the ZIP file and then saves each file as BlobStore content. I saw that it takes more than 30 seconds to save data and then "API error 10 (file: FILE_NOT_OPENED)". The size of the uncompressed file being written is about 1.5 megabytes. Here's the code that copies the new BlogStore item from the Zip reader:

func storeBlob(c appengine.Context, rc io.Reader, mimeType string) (appengine.BlobKey, error) {

c.Infof("Creating new blob of type: [%v]", mimeType)
var key appengine.BlobKey
w, err := blobstore.Create(c, mimeType)
if err != nil {
    return "", err
}

c.Infof("Copying blob data")
_, err = io.Copy(w, rc)
if err != nil {
    return "", err
}

c.Infof("Closing Blob")
err = w.Close()
if err != nil {
    return "", err
}

c.Infof("Getting Blob Key")
key, err = w.Key()
if err != nil {
    return "", err
}
return key, nil

      

}

The production app server blocks for 30 seconds and then reports an error when calling io.Copy. Any thoughts on how to fix this issue?

+3


source to share


1 answer


This error is due to your request being disabled. Create

makes a request for a protocol buffer that looks like this :

oreq := &filepb.OpenRequest{
    Filename:      res.Filename,
    ContentType:   filepb.FileContentType_RAW.Enum(),
    OpenMode:      filepb.OpenRequest_APPEND.Enum(),
    ExclusiveLock: proto.Bool(true),
}

      

Relevant definition :

type OpenRequest struct {
    Filename             *string                      `protobuf:"bytes,1,req,name=filename" json:"filename,omitempty"`
    ContentType          *FileContentType_ContentType `protobuf:"varint,2,req,name=content_type,enum=files.FileContentType_ContentType" json:"content_type,omitempty"`
    OpenMode             *OpenRequest_OpenMode        `protobuf:"varint,3,req,name=open_mode,enum=files.OpenRequest_OpenMode" json:"open_mode,omitempty"`
    ExclusiveLock        *bool                        `protobuf:"varint,4,opt,name=exclusive_lock,def=0" json:"exclusive_lock,omitempty"`
    BufferedOutput       *bool                        `protobuf:"varint,5,opt,name=buffered_output,def=0" json:"buffered_output,omitempty"`
    OpenLeaseTimeSeconds *int32                       `protobuf:"varint,6,opt,name=open_lease_time_seconds,def=30" json:"open_lease_time_seconds,omitempty"`
    XXX_unrecognized     []byte                       `json:"-"`
}

      

OpenLeaseTimeSeconds

No notification set. By default it will be 30 seconds:



const Default_OpenRequest_OpenLeaseTimeSeconds int32 = 30

      

Thus, it is possible to close the connection below you.

You have two options:

  • Write your own method Create

    that sets the lease time to more than 30 seconds. The most you can do is 60 seconds, after which your request will be killed , in which case you will need to use the Task Queue .

  • API is deprecated:

    Warning. The File API feature used here to write files to Blobstore has been deprecated and will be removed in the future in favor of writing files to Google Cloud Storage and using Blobstore to serve them. For more information visit Google Cloud Storage.

    So maybe you should try using google storage instead.

+2


source







All Articles