From 999107eb4383f5f7b41e784e8faa719103608a16 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 12:34:26 +1000 Subject: [PATCH 1/4] ckdb - create the reload 'begin' filename if not found --- src/ckdb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ckdb.c b/src/ckdb.c index 1178d564..1f13c677 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -5343,8 +5343,10 @@ static bool reload_from(tv_t *start); static bool reload() { char buf[DATE_BUFSIZ+1]; + char *filename; K_ITEM *ccl; tv_t start; + FILE *fp; bool ok; tv_to_buf(&(dbstatus.oldest_sharesummary_firstshare_n), buf, sizeof(buf)); @@ -5383,6 +5385,21 @@ static bool reload() if (start.tv_sec < DATE_BEGIN) { start.tv_sec = DATE_BEGIN; start.tv_usec = 0L; + filename = rotating_filename(restorefrom, start.tv_sec); + fp = fopen(filename, "r"); + if (fp) + fclose(fp); + else { + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + int fd = open(filename, O_CREAT|O_RDONLY, mode); + if (fd == -1) { + int ern = errno; + quithere(1, "Couldn't create '%s' (%d) %s", + filename, ern, strerror(ern)); + close(fd); + } + } + free(filename); } ok = reload_from(&start); From 0ab12b37ebb881380f6dc48adb9362208a748322 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 12:39:37 +1000 Subject: [PATCH 2/4] ckdb - update reload_from code comment --- src/ckdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ckdb.c b/src/ckdb.c index 1f13c677..831d5ac8 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -7471,7 +7471,7 @@ jilted: // 10Mb for now #define MAX_READ (10 * 1024 * 1024) -/* To handle a new database with no data: +/* If the reload start file is missing and -r was specified correctly: * touch the filename reported in "Failed to open 'filename'" * when ckdb aborts at the beginning of the reload */ static bool reload_from(tv_t *start) From 92d0aa3d42ef65dae27a1d3cb3b48c9b08cbdf13 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 12:47:31 +1000 Subject: [PATCH 3/4] DB v0.6 information --- sql/v0.6.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sql/v0.6.txt diff --git a/sql/v0.6.txt b/sql/v0.6.txt new file mode 100644 index 00000000..e3f6b032 --- /dev/null +++ b/sql/v0.6.txt @@ -0,0 +1,17 @@ +To update to 0.6: +1) stop ckdb and ckpool +2) connect to postgres and delete the contents of all the tables except: + users, idcontrol, version + e.g. in psql to see all the table row counts: \i tables.sql + and to delete the rows from a table: delete from auths; +3) in pgsql: update version set version='0.6'; +4) rename all your ckdb20140*.log files using the src/relog.sh script +5) start ckdb +6) wait for ckdb to say it is ready - i.e. wait for it to reload all the + ckdb20140*.log files +7) start ckpool + +You can speed up step 6) if you don't care about losing the contents of the +DB forever: just go to the log directory and rename all the ckdb20140*.log +files something like: rename ".log" ".ignore" ckdb20140*.log +(or delete them) From 81314387dbe610793ea51a3fad882b48fb09ce9f Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 13:41:36 +1000 Subject: [PATCH 4/4] ckdb - update startup comment --- src/ckdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ckdb.c b/src/ckdb.c index 831d5ac8..5fcd9f80 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -94,6 +94,10 @@ static char *restorefrom; * find an authorise message in the CCLs that was processed in the * message queue and thus is already in the DB. * This error would be very rare and also not an issue + * TODO: However, we could start the ckpool message queue after loading + * the users, auths, idcontrol and workers DB tables, before loading the + * much larger sharesummary, workinfo, userstats and poolstats DB tables + * so that ckdb is effectively ready for messages almost immediately * The first ckpool message also allows us to know where ckpool is up to * in the CCLs and thus where to stop processing the CCLs to stay in * sync with ckpool @@ -7500,7 +7504,7 @@ static bool reload_from(tv_t *start) setnow(&now); tvs_to_buf(&now, run, sizeof(run)); - snprintf(data, sizeof(data), "reload.%s.0", run); + snprintf(data, sizeof(data), "reload.%s.s0", run); LOGFILE(data); total = 0;