Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Aug 27, 2024
1 parent 4ff93af commit b81cd97
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,9 @@ void *bioProcessBackgroundJobs(void *arg) {
int job_type = job->header.type;

if (job_type == BIO_CLOSE_FILE) {
if (job->fd_args.need_fsync && valkey_fsync(job->fd_args.fd) == -1 && errno != EBADF && errno != EINVAL) {
serverLog(LL_WARNING, "Fail to fsync the AOF file: %s", strerror(errno));
}
if (job->fd_args.need_reclaim_cache) {
if (reclaimFilePageCache(job->fd_args.fd, 0, 0) == -1) {
serverLog(LL_NOTICE, "Unable to reclaim page cache: %s", strerror(errno));
}
}
close(job->fd_args.fd);
fseek(server.fp_wlog2, 0, SEEK_END);
serverLog(LL_WARNING, "1111");

} else if (job_type == BIO_AOF_FSYNC || job_type == BIO_CLOSE_AOF) {
/* The fd may be closed by main thread and reused for another
* socket, pipe, or file. We just ignore these errno because
Expand Down
2 changes: 2 additions & 0 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@ void clusterHandleServerShutdown(void) {
serverLog(LL_NOTICE, "Saving the cluster configuration file before exiting.");
clusterSaveConfig(1);

#if !defined(__sun)
/* Unlock the cluster config file before shutdown, see clusterLockConfig.
*
* This is needed if you shutdown a very large server process, it will take
Expand All @@ -1209,6 +1210,7 @@ void clusterHandleServerShutdown(void) {
if (server.cluster_config_file_lock_fd != -1) {
flock(server.cluster_config_file_lock_fd, LOCK_UN | LOCK_NB);
}
#endif /* __sun */
}

/* Reset a node performing a soft or hard reset:
Expand Down
14 changes: 14 additions & 0 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,16 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* Software watchdog: deliver the SIGALRM that will reach the signal
* handler if we don't return here fast enough. */
if (server.watchdog_period) watchdogScheduleSignal(server.watchdog_period);
serverLog(LL_WARNING, "================");

fseek(server.fp_wlog2, 0, SEEK_END);

bioCreateCloseJob(0, 0, 0);

server.fp_wlog = fopen("1.txt", "wb");
server.fp_wlog2 = server.fp_wlog;
fclose(server.fp_wlog);
server.fp_wlog = NULL;

server.hz = server.config_hz;
/* Adapt the server.hz value to the number of configured clients. If we have
Expand Down Expand Up @@ -2552,6 +2562,10 @@ void initServer(void) {
openlog(server.syslog_ident, LOG_PID | LOG_NDELAY | LOG_NOWAIT, server.syslog_facility);
}

server.fp_wlog = fopen("1.txt", "wb");
server.fp_wlog2 = server.fp_wlog;
fclose(server.fp_wlog);

/* Initialization after setting defaults from the config system. */
server.aof_state = server.aof_enabled ? AOF_ON : AOF_OFF;
server.fsynced_reploff = server.aof_enabled ? 0 : -1;
Expand Down
2 changes: 2 additions & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,8 @@ struct valkeyServer {
/* AOF persistence */
int aof_enabled; /* AOF configuration */
int aof_state; /* AOF_(ON|OFF|WAIT_REWRITE) */
FILE *fp_wlog;
FILE *fp_wlog2;
int aof_fsync; /* Kind of fsync() policy */
char *aof_filename; /* Basename of the AOF file and manifest file */
char *aof_dirname; /* Name of the AOF directory */
Expand Down

0 comments on commit b81cd97

Please sign in to comment.