Commit 4830d6b9 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Make transaction limit and timeout into cmd line options

parent 5e251abf
......@@ -38,11 +38,13 @@ VUT_OPT_D
VSL_OPT_g
VSL_OPT_i
VSL_OPT_I
VSL_OPT_L
VSM_OPT_n
VSM_OPT_N
VUT_OPT_P
VUT_OPT_q
VSL_OPT_r
VSL_OPT_T
VSL_OPT_u
VSL_OPT_v
VSL_OPT_w
......
......@@ -95,11 +95,29 @@
VSL_iI_PS \
)
#define VSL_OPT_L \
VOPT("L:", "[-L limit]", "Incomplete transaction limit", \
"Sets the upper limit of incomplete transactions kept" \
" before the oldest transaction is force completed. A" \
" warning record is synthesized when this happens. This" \
" setting keeps an upper bound on the memory usage of" \
" running queries. Defaults to 1000 transactions." \
)
#define VSL_OPT_r \
VOPT("r:", "[-r filename]", "Binary file input", \
"Read log in binary file format from this file." \
)
#define VSL_OPT_T \
VOPT("T:", "[-T seconds]", "Transaction end timeout", \
"Sets the transaction timeout in seconds. This defines the" \
" maximum number of seconds elapsed between a Begin tag" \
" and the End tag. If the timeout expires, a warning" \
" record is synthesized and the transaction is force" \
" completed. Defaults to 120 seconds." \
)
#define VSL_OPT_u \
VOPT("u", "[-u]", "Binary file output unbuffered", \
"Unbuffered binary file output mode." \
......
......@@ -91,6 +91,8 @@ VSL_New(void)
if (vsl == NULL)
return (NULL);
vsl->L_opt = 1000;
vsl->T_opt = 120.;
vsl->vbm_select = vbit_init(SLT__MAX);
vsl->vbm_supress = vbit_init(SLT__MAX);
VTAILQ_INIT(&vsl->vslf_select);
......
......@@ -90,6 +90,8 @@ struct VSL_data {
int b_opt;
int c_opt;
int L_opt;
double T_opt;
int v_opt;
};
......
......@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include "miniobj.h"
#include "vas.h"
......@@ -312,6 +313,9 @@ int
VSL_Arg(struct VSL_data *vsl, int opt, const char *arg)
{
int i;
char *p;
double d;
long l;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
/* If first option is 'i', set all bits for supression */
......@@ -324,6 +328,26 @@ VSL_Arg(struct VSL_data *vsl, int opt, const char *arg)
case 'c': vsl->c_opt = 1; return (1);
case 'i': case 'x': return (vsl_ix_arg(vsl, opt, arg));
case 'I': case 'X': return (vsl_IX_arg(vsl, opt, arg));
case 'L':
l = strtol(arg, &p, 0);
while (isspace(*p))
p++;
if (*p != '\0')
return (vsl_diag(vsl, "-L: Syntax error"));
if (l < 0 || l > INT_MAX)
return (vsl_diag(vsl, "-L: Range error"));
vsl->L_opt = (int)l;
return (1);
case 'T':
d = strtod(arg, &p);
while (isspace(*p))
p++;
if (*p != '\0')
return (vsl_diag(vsl, "-P: Syntax error"));
if (d < 0.)
return (vsl_diag(vsl, "-L: Range error"));
vsl->T_opt = d;
return (1);
case 'v': vsl->v_opt = 1; return (1);
default:
return (0);
......
......@@ -1009,9 +1009,7 @@ VSLQ_Dispatch(struct VSLQ *vslq, VSLQ_dispatch_f *func, void *priv)
now = VTIM_mono();
while ((vtx = VTAILQ_FIRST(&vslq->incomplete)) &&
now - vtx->t_start > 120.) {
/* XXX: Make timeout configurable through options and
provide a sane default */
now - vtx->t_start > vslq->vsl->T_opt) {
AZ(vtx->flags & VTX_F_COMPLETE);
vtx = vtx_force(vslq, vtx, "incomplete - timeout");
if (vtx) {
......@@ -1026,9 +1024,7 @@ VSLQ_Dispatch(struct VSLQ *vslq, VSLQ_dispatch_f *func, void *priv)
if (i)
return (i);
while (vslq->n_incomplete > 1000) {
/* XXX: Make limit configurable through options and
provide a sane default */
while (vslq->n_incomplete > vslq->vsl->L_opt) {
vtx = VTAILQ_FIRST(&vslq->incomplete);
AN(vtx);
AZ(vtx->flags & VTX_F_COMPLETE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment