Skip to content

Commit

Permalink
lower timestamp granularity ~3ms
Browse files Browse the repository at this point in the history
  • Loading branch information
tezc committed May 16, 2021
1 parent 33c3b3b commit 6cf6af9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
2 changes: 1 addition & 1 deletion jresql/src/test/java/resql/TimestampTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testTimestampIncrementFor10ms() throws InterruptedException {
rs = client.execute(false);
assert (rs.linesChanged() == 1);
assert (rs.lastRowId() == i + 1);
Thread.sleep(10);
Thread.sleep(20);
}

client.put("SELECT DISTINCT(ts_ms) FROM ts_ms_table;");
Expand Down
4 changes: 3 additions & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ static int server_create_entry(struct server *s, bool force, uint64_t seq,
bool ss_sending;
bool ss_running;
int rc;
uint64_t diff;
uint32_t size = sc_buf_size(buf);
void *data = sc_buf_rbuf(buf);

Expand Down Expand Up @@ -557,7 +558,8 @@ static int server_create_entry(struct server *s, bool force, uint64_t seq,
return force ? RS_FULL : RS_REJECT;
}

if (s->timestamp - s->last_ts > 2) {
diff = s->timestamp - s->last_ts;
if ((!force && diff > 2) || (force && diff > 10000)) {
s->last_ts = s->timestamp;

sc_buf_clear(&s->tmp);
Expand Down
31 changes: 6 additions & 25 deletions test/test_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,28 +422,19 @@ resql *test_client_create()

int rc, try = 0;
bool found;
const char *url = urls[0];
resql *c;

retry:
for (int i = 0; i < 9; i++) {
if (cluster[i] != NULL) {
url = urls[i];
break;
}
}

struct resql_config conf = {
.urls = url,
.urls = node8,
.timeout_millis = 60000,
};

retry:
rc = resql_create(&c, &conf);
if (rc != RESQL_OK) {
try++;
if (try >= 10) {
printf("Failed rs : %d \n", rc);
abort();
rs_abort("%s \n", resql_errstr(c));
}

resql_shutdown(c);
Expand Down Expand Up @@ -471,28 +462,18 @@ resql *test_client_create_timeout(uint32_t timeout)

int rc, try = 0;
bool found;
const char *url = urls[0];
resql *c;

retry:
for (int i = 0; i < 9; i++) {
if (cluster[i] != NULL) {
url = urls[i];
break;
}
}

struct resql_config conf = {
.urls = url,
.urls = node8,
.timeout_millis = timeout,
};

retry:
rc = resql_create(&c, &conf);
if (rc != RESQL_OK) {
try++;
if (try >= 10) {
printf("Failed rs : %d \n", rc);
abort();
rs_abort("%s \n", resql_errstr(c));
}

resql_shutdown(c);
Expand Down

0 comments on commit 6cf6af9

Please sign in to comment.