Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/utils/postgres.h: define commit interval in metadata #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ postgres_producer_produce(Producer p, Message msg)
}

m->count = m->count + 1;
if (m->count == 2000)
if (m->count >= m->commit_interval)
{
commit(&m);
}
Expand Down Expand Up @@ -383,7 +383,7 @@ postgres_validate(config_setting_t *config)

Array master = NULL,replica = NULL;

int m, r, threads;
int m, r, threads, commit_interval;
bool ret = true;

// We need the parent list, because the postgres
Expand All @@ -394,6 +394,9 @@ postgres_validate(config_setting_t *config)
ret = false;
if(!CONF_L_IS_INT(config, "threads", &threads, "require a threads integer"))
ret = false;
if(!CONF_L_IS_INT(config, "commit_interval", &commit_interval,
"require a commit interval integer"))
commit_interval = 2000;
if(!ret) goto error;

master = parse_hostinfo_master((char*) hosts);
Expand Down Expand Up @@ -450,6 +453,9 @@ postgres_validate(config_setting_t *config)
setting = config_setting_add(instance, "threads", CONFIG_TYPE_INT);
config_setting_set_int(setting, threads);

setting = config_setting_add(instance, "commit_interval", CONFIG_TYPE_INT);
config_setting_set_int(setting, commit_interval);

if(r && (array_get(replica,i) != NULL)) {
setting = config_setting_add(instance, "replica", CONFIG_TYPE_STRING);
config_setting_set_string(setting, array_get(replica, i));
Expand Down
1 change: 1 addition & 0 deletions src/utils/postgres.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ typedef struct Meta {
int cpyfmt;
int count;
int copy;
int commit_interval;
int commit_iter;
pthread_mutex_t commit_mutex;
pthread_t commit_worker;
Expand Down