MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / check

Function check

tests/tools/insert.c:364–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364void check(void)
365{
366 cdb2_hndl_tp *db;
367 int rc, reopen_count = 0;
368
369reopen:
370 rc = cdb2_open(&db, dbname, cltype, 0);
371 if (rc) {
372 tdprintf(stderr, db, __func__, __LINE__, "check: open rc %d %s\n", rc,
373 cdb2_errstr(db));
374 cdb2_close(db);
375 myexit(__func__, __LINE__, 1);
376 }
377 cdb2_hndl_set_max_retries(db, max_retries);
378 if (debug_trace) {
379 cdb2_set_debug_trace(db);
380 }
381
382 rc = cdb2_run_statement(db, "set hasql on");
383 if (rc) {
384 tdprintf(stderr, db, __func__, __LINE__,
385 "set serializable: run rc %d %s\n", rc, cdb2_errstr(db));
386 cdb2_close(db);
387 myexit(__func__, __LINE__, 1);
388 }
389
390 rc = cdb2_run_statement(db, "set transaction serializable");
391 if (rc) {
392 tdprintf(stderr, db, __func__, __LINE__,
393 "set serializable: run rc %d %s\n", rc, cdb2_errstr(db));
394 cdb2_close(db);
395 myexit(__func__, __LINE__, 1);
396 }
397
398 char *host = read_node(db);
399 ;
400 tdprintf(stderr, db, __func__, __LINE__, "check results run on %s\n", host);
401
402 rc = cdb2_run_statement(db, "select value from jepsen order by value");
403 if (rc) {
404 tdprintf(stderr, db, __func__, __LINE__, "check: run rc %d %s\n", rc,
405 cdb2_errstr(db));
406 cdb2_close(db);
407 if (rc == 402) {
408 sleep(1);
409 reopen_count++;
410 tdprintf(stderr, db, __func__, __LINE__, "%s reopen count is %d\n",
411 __func__, reopen_count);
412 goto reopen;
413 }
414 myexit(__func__, __LINE__, 1);
415 }
416 rc = cdb2_next_record(db);
417 while (rc == CDB2_OK) {
418 int v = (int)*(long long *)cdb2_column_value(db, 0);
419 if (v < 0 || v > largest) {
420 fprintf(stderr, "unexpected value %d\n", v);
421 goto next;

Callers 1

mainFunction · 0.70

Calls 11

cdb2_openFunction · 0.85
tdprintfFunction · 0.85
cdb2_errstrFunction · 0.85
cdb2_closeFunction · 0.85
myexitFunction · 0.85
cdb2_set_debug_traceFunction · 0.85
cdb2_run_statementFunction · 0.85
read_nodeFunction · 0.85
cdb2_next_recordFunction · 0.85
cdb2_column_valueFunction · 0.85

Tested by

no test coverage detected