`
cocos
  • 浏览: 401273 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

Error moving temp DB file on the final destination: Invalid cross-device link

 
阅读更多

Error moving temp DB file on the final destination: Invalid cross-device link

 

dbfilename /data1/redisdata/dump.rdb 路径需要同文件系统,否则无法写入dump.rdb文件

/** Save the DB on disk. Return REDIS_ERR on error, REDIS_OK on success */
0405	int rdbSave(char *filename) {
0406	    dictIterator *di = NULL;
0407	    dictEntry *de;
0408	    FILE *fp;
0409	    char tmpfile[256];
0410	    int j;
0411	    time_t now = time(NULL);
0412	 
0413	    /** Wait for I/O therads to terminate, just in case this is a
0414	     * foreground-saving, to avoid seeking the swap file descriptor at the
0415	     * same time. */
0416	    if (server.vm_enabled)
0417	        waitEmptyIOJobsQueue();
0418	 
0419	    snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid());
0420	    fp = fopen(tmpfile,"w");
0421	    if (!fp) {
0422	        redisLog(REDIS_WARNING, "Failed saving the DB: %s", strerror(errno));
0423	        return REDIS_ERR;
0424	    }
0425	    if (fwrite("REDIS0001",9,1,fp) == 0) goto werr;
0426	    for (j = 0; j < server.dbnum; j++) {
0427	        redisDb *db = server.db+j;
0428	        dict *d = db->dict;
0429	        if (dictSize(d) == 0) continue;
0430	        di = dictGetIterator(d);
0431	        if (!di) {
0432	            fclose(fp);
0433	            return REDIS_ERR;
0434	        }
0435	 
0436	        /** Write the SELECT DB opcode */
0437	        if (rdbSaveType(fp,REDIS_SELECTDB) == -1) goto werr;
0438	        if (rdbSaveLen(fp,j) == -1) goto werr;
0439	 
0440	        /** Iterate this DB writing every entry */
0441	        while((de = dictNext(di)) != NULL) {
0442	            sds keystr = dictGetEntryKey(de);
0443	            robj key, *o = dictGetEntryVal(de);
0444	            time_t expiretime;
0445	             
0446	            initStaticStringObject(key,keystr);
0447	            expiretime = getExpire(db,&key);
0448	 
0449	            /** Save the expire time */
0450	            if (expiretime != -1) {
0451	                /** If this key is already expired skip it */
0452	                if (expiretime < now) continue;
0453	                if (rdbSaveType(fp,REDIS_EXPIRETIME) == -1) goto werr;
0454	                if (rdbSaveTime(fp,expiretime) == -1) goto werr;
0455	            }
0456	            /** Save the key and associated value. This requires special
0457	             * handling if the value is swapped out. */
0458	            if (!server.vm_enabled || o->storage == REDIS_VM_MEMORY ||
0459	                                      o->storage == REDIS_VM_SWAPPING) {
0460	                /** Save type, key, value */
0461	                if (rdbSaveType(fp,o->type) == -1) goto werr;
0462	                if (rdbSaveStringObject(fp,&key) == -1) goto werr;
0463	                if (rdbSaveObject(fp,o) == -1) goto werr;
0464	            } else {
0465	                /** REDIS_VM_SWAPPED or REDIS_VM_LOADING */
0466	                robj *po;
0467	                /** Get a preview of the object in memory */
0468	                po = vmPreviewObject(o);
0469	                /** Save type, key, value */
0470	                if (rdbSaveType(fp,po->type) == -1) goto werr;
0471	                if (rdbSaveStringObject(fp,&key) == -1) goto werr;
0472	                if (rdbSaveObject(fp,po) == -1) goto werr;
0473	                /** Remove the loaded object from memory */
0474	                decrRefCount(po);
0475	            }
0476	        }
0477	        dictReleaseIterator(di);
0478	    }
0479	    /** EOF opcode */
0480	    if (rdbSaveType(fp,REDIS_EOF) == -1) goto werr;
0481	 
0482	    /** Make sure data will not remain on the OS's output buffers */
0483	    fflush(fp);
0484	    fsync(fileno(fp));
0485	    fclose(fp);
0486	 
0487	   

 /** Use RENAME to make sure the DB file is changed atomically only
0488	     * if the generate DB file is ok. */
0489	    if (rename(tmpfile,filename) == -1) {
0490	        redisLog(REDIS_WARNING,"Error moving temp DB file on the final destination: %s", strerror(errno));
0491	        unlink(tmpfile);
0492	        return REDIS_ERR;
0493	    }


0494	    redisLog(REDIS_NOTICE,"DB saved on disk");
0495	    server.dirty = 0;
0496	    server.lastsave = time(NULL);
0497	    return REDIS_OK;
0498	 
0499	werr:
0500	    fclose(fp);
0501	    unlink(tmpfile);
0502	    redisLog(REDIS_WARNING,"Write error saving DB on disk: %s", strerror(errno));
0503	    if (di) dictReleaseIterator(di);
0504	    return REDIS_ERR;
0505	}
分享到:
评论

相关推荐

    Networkers2009:BRKSEC-3003 - Advanced IPv6 Security: Securing Link-Operations at First Hop

    - Destination-guard:验证目的地址的有效性。 - **其他特性**:报告还介绍了在第一跳处实施的安全检查(inspection)、监控(monitoring)和防护(guard)功能。 #### 五、部署挑战及案例分析 - **SeND部署挑战**...

    DB2数据库常用命令手册

    - `db2 restore db &lt;database_name&gt; from &lt;device&gt; to &lt;destination_path&gt;`:从磁带设备恢复数据库。 **注意事项:** - `&lt;source_path&gt;`应替换为备份文件所在的路径。 - `&lt;destination_path&gt;`应替换为目标恢复路径...

    新标准大学英语综合翻译PPT学习教案.pptx

    - "Cross-cultural communication":跨文化交流 - "Performance is satisfactory":表现满意 这些内容对于提高学生的英语翻译能力和词汇量非常有帮助,同时也涵盖了日常生活、体育、教育、安全和动物行为等多个...

    2019_2020学年高中英语Unit5Travellingabroad3SectionⅢLearningaboutLangua

    - destination:目的地 - cultural atmosphere:文化氛围 - academic status:学术地位 - fixed routine:日常事务 - agent:经纪人 - optional:选修的 - govern:管理 - make an apology:道歉 - ...

    外出旅行常用英语.doc

    - Please show me the menu. (请把菜单给我。) - Cheers! (干杯!),Bottoms up! (干杯!) - I'm lost. Could you do me a favor to find my hotel? (我迷路了,您能告诉我怎么回饭店吗?) - Could you ...

    专题资料(2021-2022年)《出境旅游常用英语》实用手册要点.doc

    - 前往国:destination country - 登机城市:city where you boarded - 签证签发地:city where visa was issued - 签发日期:date of issue - 出生日期:date of birth,birth date - 年:year - 月:month ...

    Network Tomography:Estimating source-destination traffic intensities from link data

    Y.Vardi的经典论文,涉及到流量矩阵和网络层析技术的可以参考此论文。

    TeeChart8.01 FullSource

    The source code can be modified or expanded for your own compiled applications. You can not resell or redistribute in any way this source code as it is or modified. See the License.txt document for ...

    socket错误代码对应表

    - **Socket error #10039 - Destination address required**:需要目的地址。 - **Socket error #10040 - Message too long**:消息过长。 - **Socket error #10041 - Protocol wrong type for socket**:协议类型与...

    linux常用的60个命令

    - `mount [options] DEVICE MOUNT_POINT` **选项说明:** - `-a`: 挂载 /etc/fstab 文件中的所有条目 - `-t`: 指定文件系统的类型 - `-n`: 不更新 /etc/mtab 文件 - `-f`: 强制挂载 **使用示例与场景:** - 在 ...

    k7 SRIO参考例程

    16-bit device IDs appears as a corrupted packet on the IResp interface. - Version fixed : v5.1 - CR#473400, CR#473693 - Fixed LogIO RX to properly handle all user-defined types. - PHY core does...

    DOS命令大全

    - `ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [-j computer-list | -k computer-list] [-w timeout] destination-list` **功能简介:** - `ping` 命令用于测试网络连接...

    WinCC flexible 2008 VBScript

    - **示例**: `FileCopy "C:\temp\source.txt", "C:\temp\destination.txt"` ##### 3.7 FileLen **功能**: 获取文件长度。 - **语法**: `FileLen(path)` - **参数**: - path: 文件路径。 - **返回值**: 文件大小...

    Solaris 系统管理命令及相关技术中英文对照

    - **示例**: `add_to_install_server -source cdrom_path -destination server_path` **addbadsec** - **功能**: 映射出错误磁盘块。 - **用途**: 用于标记磁盘上的坏扇区,防止其再次被使用。 - **示例**: `...

    curl(url语法在windows系统的命令行)

    - PUT请求:`curl -T file.txt http://example.com/destination` 3. **认证和安全**: - 使用用户名和密码:`curl --user user:password http://example.com` - HTTPS(SSL/TLS)连接:`curl ...

    w_lina01.pdf

    - 从远程主机复制文件到本地:`scp username@host:/remote/path/to/file /local/path/to/destination` - 使用FTP传输文件:`ftp` 14. 磁盘使用 - 显示文件系统的磁盘空间使用情况:`df -h` - 显示目录的大小:`...

    curl命令详解.docx

    - `-F`用于multipart/form-data POST请求,上传二进制文件:`curl -F "file=@/path/to/localfile" [URL]` ### 常用选项示例 - `-A` 指定客户端的用户代理标头 - `-b` 向服务器发送Cookie - `-c` 保存Cookie - `-d` ...

    谷歌地图 delphi 封装库 2013 0.1.9 全面支持google maps api

    Can be a file into your PC or an image on the web. - Improvement: TGMMarker =&gt; added OnIconChange event. - Improvement: General =&gt; all Set methods are changed to avoid duplicate code. May 05, ...

    cmd命令大全(txt)

    - `if exist file.txt (echo File exists) else (echo File does not exist)` —— 检查file.txt是否存在。 #### 三十九、LABEL **功能:** 显示或更改卷标。 **使用示例:** - `label C: NewLabel` —— 将C盘的...

Global site tag (gtag.js) - Google Analytics