当我尝试在无服务器框架的/tmp目录中打开和下载.realm文件时,我得到以下错误。{"errorType":"Runtime.UnhandledPromiseRejection",“errorMessage”:“错误: posix_fallocate()失败:不允许操作”}
Below is the code:
let realm = new Realm({path: '/tmp/custom.realm', schema: [schema1, schema2]});
realm.write(() => {
console.log('completed==');
});发布于 2021-10-14 13:22:17
编辑:这可能很快就会在Realm-Core:see issue 4957中得到修复。
如果你在其他地方遇到这个问题,这里有一个解决方法。
这是由于AWS Lambda不支持fallocate和fallocate64系统调用造成的。亚马逊没有在这种情况下返回正确的错误代码,而是阻止了系统调用,以便返回EPERM。
解决方案是将一个小型共享库作为层添加到lambda中:在Linux机器上或在lambda-ci Docker镜像中编译以下C文件:
#include <errno.h>
#include <fcntl.h>
int posix_fallocate(int __fd, off_t __offset, off_t __len) {
return EINVAL;
}
int posix_fallocate64(int __fd, off_t __offset, off_t __len) {
return EINVAL;
}gcc -shared fix.c -o fix.so
然后,
zip layer.zip fix.so
创建一个新的lambda层
中
LD_PRELOAD的值/opt/fix.so配置到Lambda来加载共享对象。https://stackoverflow.com/questions/57825072
复制相似问题