Browse Source

ckdb - add some table level locking to speed up large loads

master
kanoi 9 years ago
parent
commit
09a40a4607
  1. 2
      src/ckdb.h
  2. 30
      src/ckdb_dbio.c

2
src/ckdb.h

@ -51,7 +51,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.4" #define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.930" #define CKDB_VERSION DB_VERSION"-1.940"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__

30
src/ckdb_dbio.c

@ -2943,6 +2943,14 @@ bool workinfo_fill(PGconn *conn)
return false; return false;
} }
res = PQexec(conn, "Lock table workinfo in access exclusive mode", CKPQ_READ);
rescode = PQresultStatus(res);
PQclear(res);
if (!PGOK(rescode)) {
PGLOGERR("Lock", rescode, conn);
goto flail;
}
res = PQexecParams(conn, sel, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_READ); res = PQexecParams(conn, sel, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_READ);
rescode = PQresultStatus(res); rescode = PQresultStatus(res);
PQclear(res); PQclear(res);
@ -5468,6 +5476,14 @@ bool miningpayouts_fill(PGconn *conn)
return false; return false;
} }
res = PQexec(conn, "Lock table miningpayouts in access exclusive mode", CKPQ_READ);
rescode = PQresultStatus(res);
PQclear(res);
if (!PGOK(rescode)) {
PGLOGERR("Lock", rescode, conn);
goto flail;
}
res = PQexec(conn, sel, CKPQ_READ); res = PQexec(conn, sel, CKPQ_READ);
rescode = PQresultStatus(res); rescode = PQresultStatus(res);
PQclear(res); PQclear(res);
@ -6967,9 +6983,6 @@ bool markersummary_fill(PGconn *conn)
LOGDEBUG("%s(): select", __func__); LOGDEBUG("%s(): select", __func__);
printf(TICK_PREFIX"ms 0\r");
fflush(stdout);
// TODO: limit how far back // TODO: limit how far back
sel = "declare ws cursor for select " sel = "declare ws cursor for select "
"markerid,userid,workername,diffacc,diffsta,diffdup,diffhi," "markerid,userid,workername,diffacc,diffsta,diffdup,diffhi,"
@ -6987,6 +7000,9 @@ bool markersummary_fill(PGconn *conn)
LOGWARNING("%s(): loading from markerid>=%s", __func__, params[0]); LOGWARNING("%s(): loading from markerid>=%s", __func__, params[0]);
printf(TICK_PREFIX"ms 0\r");
fflush(stdout);
res = PQexec(conn, "Begin", CKPQ_READ); res = PQexec(conn, "Begin", CKPQ_READ);
rescode = PQresultStatus(res); rescode = PQresultStatus(res);
PQclear(res); PQclear(res);
@ -6995,6 +7011,14 @@ bool markersummary_fill(PGconn *conn)
return false; return false;
} }
res = PQexec(conn, "Lock table markersummary in access exclusive mode", CKPQ_READ);
rescode = PQresultStatus(res);
PQclear(res);
if (!PGOK(rescode)) {
PGLOGERR("Lock", rescode, conn);
goto flail;
}
res = PQexecParams(conn, sel, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_READ); res = PQexecParams(conn, sel, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_READ);
rescode = PQresultStatus(res); rescode = PQresultStatus(res);
PQclear(res); PQclear(res);

Loading…
Cancel
Save