Function called at startup to load RDB or AOF file in memory. */
| 5931 | |
| 5932 | /* Function called at startup to load RDB or AOF file in memory. */ |
| 5933 | void loadDataFromDisk(void) { |
| 5934 | long long start = ustime(); |
| 5935 | if (server.aof_state == AOF_ON) { |
| 5936 | if (loadAppendOnlyFile(server.aof_filename) == C_OK) |
| 5937 | serverLog(LL_NOTICE,"DB loaded from append only file: %.3f seconds",(float)(ustime()-start)/1000000); |
| 5938 | } else { |
| 5939 | rdbSaveInfo rsi = RDB_SAVE_INFO_INIT; |
| 5940 | errno = 0; /* Prevent a stale value from affecting error checking */ |
| 5941 | if (rdbLoad(server.rdb_filename,&rsi,RDBFLAGS_NONE) == C_OK) { |
| 5942 | serverLog(LL_NOTICE,"DB loaded from disk: %.3f seconds", |
| 5943 | (float)(ustime()-start)/1000000); |
| 5944 | |
| 5945 | /* Restore the replication ID / offset from the RDB file. */ |
| 5946 | if ((server.masterhost || |
| 5947 | (server.cluster_enabled && |
| 5948 | nodeIsSlave(server.cluster->myself))) && |
| 5949 | rsi.repl_id_is_set && |
| 5950 | rsi.repl_offset != -1 && |
| 5951 | /* Note that older implementations may save a repl_stream_db |
| 5952 | * of -1 inside the RDB file in a wrong way, see more |
| 5953 | * information in function rdbPopulateSaveInfo. */ |
| 5954 | rsi.repl_stream_db != -1) |
| 5955 | { |
| 5956 | memcpy(server.replid,rsi.repl_id,sizeof(server.replid)); |
| 5957 | server.master_repl_offset = rsi.repl_offset; |
| 5958 | /* If we are a slave, create a cached master from this |
| 5959 | * information, in order to allow partial resynchronizations |
| 5960 | * with masters. */ |
| 5961 | replicationCacheMasterUsingMyself(); |
| 5962 | selectDb(server.cached_master,rsi.repl_stream_db); |
| 5963 | } |
| 5964 | } else if (errno != ENOENT) { |
| 5965 | serverLog(LL_WARNING,"Fatal error loading the DB: %s. Exiting.",strerror(errno)); |
| 5966 | exit(1); |
| 5967 | } |
| 5968 | } |
| 5969 | } |
| 5970 | |
| 5971 | void redisOutOfMemoryHandler(size_t allocation_size) { |
| 5972 | serverLog(LL_WARNING,"Out Of Memory allocating %zu bytes!", |
no test coverage detected