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

Function retry_query_list

cdb2api/cdb2api.c:3883–4045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3881}
3882
3883static int retry_query_list(cdb2_hndl_tp *hndl, int num_retry, int run_last)
3884{
3885 debugprint("retry_all %d, intran %d\n", hndl->retry_all, hndl->in_trans);
3886
3887 if (!hndl->retry_all || !hndl->in_trans)
3888 return 0;
3889
3890 int rc = 0;
3891 if (!(hndl->snapshot_file || hndl->query_no <= 1)) {
3892 debugprint("in_trans=%d snapshot_file=%d query_no=%d\n", hndl->in_trans,
3893 hndl->snapshot_file, hndl->query_no);
3894 sprintf(hndl->errstr, "Database disconnected while in transaction.");
3895 return CDB2ERR_TRAN_IO_ERROR; /* Fail if disconnect happens in
3896 transaction which doesn't have snapshot
3897 info.*/
3898 }
3899
3900 /* Replay all the queries. */
3901 char *host = "NOT-CONNECTED";
3902 if (hndl->connected_host >= 0)
3903 host = hndl->hosts[hndl->connected_host];
3904
3905 /*Send Begin. */
3906 hndl->is_retry = num_retry;
3907
3908 clear_responses(hndl);
3909 hndl->read_intrans_results = 1;
3910
3911 hndl->in_trans = 0;
3912 debugprint("sending 'begin' to %s\n", host);
3913 rc = cdb2_send_query(hndl, hndl, hndl->sb, hndl->dbname, "begin",
3914 hndl->num_set_commands, hndl->num_set_commands_sent,
3915 hndl->commands, 0, NULL, 0, NULL, 1, 0, num_retry, 0,
3916 __LINE__);
3917 hndl->in_trans = 1;
3918 debugprint("cdb2_send_query rc = %d, setting in_trans to 1\n", rc);
3919
3920 if (rc != 0) {
3921 sbuf2close(hndl->sb);
3922 hndl->sb = NULL;
3923 debugprint("send_query host=%s rc=%d; returning 1\n", host, rc);
3924 return 1;
3925 }
3926 int len = 0;
3927 int type = 0;
3928 rc = cdb2_read_record(hndl, &hndl->first_buf, &len, &type);
3929 if (rc) {
3930 sbuf2close(hndl->sb);
3931 hndl->sb = NULL;
3932 debugprint("cdb2_read_record from %s rc=%d, returning 1\n", host, rc);
3933 return 1;
3934 }
3935
3936 if (type == RESPONSE_HEADER__DBINFO_RESPONSE) {
3937 if (hndl->flags & CDB2_DIRECT_CPU) {
3938 debugprint("directcpu will ignore dbinfo\n");
3939 return 1;
3940 }

Callers 2

retry_queries_and_skipFunction · 0.85

Calls 6

clear_responsesFunction · 0.85
cdb2_send_queryFunction · 0.85
cdb2_read_recordFunction · 0.85
parse_dbresponseFunction · 0.85
cdb2_next_record_intFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected