Changeset abe7edbdd20777ec3d02b2f26963cdffdbff79e3

Show
Ignore:
Timestamp:
11/24/09 20:50:02 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1259095802 +0000
git-parent:

[8f3d0bbff627f08aa8e0f50d47bbc884437df826]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1259095802 +0000
Message:

cleanup error messages and add some useful debugging

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stratcon_datastore.c

    rae8bf79 rabe7edb  
    7474static noit_log_stream_t ds_err = NULL; 
    7575static noit_log_stream_t ds_deb = NULL; 
     76static noit_log_stream_t ds_pool_deb = NULL; 
    7677static noit_log_stream_t ingest_err = NULL; 
    7778 
     
    242243  } 
    243244  pthread_mutex_unlock(&cq->pool->lock); 
    244   noitL(ds_deb, "[%p] release %s [%s]\n", (void *)pthread_self(), 
     245  noitL(ds_pool_deb, "[%p] release %s [%s]\n", (void *)pthread_self(), 
    245246        putback ? "to pool" : "and destroy", cq->pool->queue_name); 
    246247  pthread_cond_signal(&cq->pool->cv); 
     
    290291  } 
    291292  if(old_cnt != new_cnt) 
    292     noitL(ds_deb, "reduced db pool %d -> %d [%s]\n", old_cnt, new_cnt, 
     293    noitL(ds_pool_deb, "reduced db pool %d -> %d [%s]\n", old_cnt, new_cnt, 
    293294          pool->queue_name); 
    294295} 
     
    357358  conn_q *cq; 
    358359  cpool = get_conn_pool_for_remote(remote_str, remote_cn, fqdn); 
    359   noitL(ds_deb, "[%p] requesting [%s]\n", (void *)pthread_self(), 
     360  noitL(ds_pool_deb, "[%p] requesting [%s]\n", (void *)pthread_self(), 
    360361        cpool->queue_name); 
    361362  pthread_mutex_lock(&cpool->lock); 
     
    372373  } 
    373374  if(cpool->in_pool + cpool->outstanding >= cpool->max_allocated) { 
    374     noitL(ds_deb, "[%p] over-subscribed, waiting [%s]\n", 
     375    noitL(ds_pool_deb, "[%p] over-subscribed, waiting [%s]\n", 
    375376          (void *)pthread_self(), cpool->queue_name); 
    376377    pthread_cond_wait(&cpool->cv, &cpool->lock); 
    377     noitL(ds_deb, "[%p] waking up and trying again [%s]\n", 
     378    noitL(ds_pool_deb, "[%p] waking up and trying again [%s]\n", 
    378379          (void *)pthread_self(), cpool->queue_name); 
    379380    goto again; 
     
    450451  if(d->rv != PGRES_COMMAND_OK && \ 
    451452     d->rv != PGRES_TUPLES_OK) { \ 
    452     noitL(ds_err, "[%s] stratcon datasource bad (%d): %s\n'%s'\n", \ 
     453    const char *pgerr = PQresultErrorMessage(d->res); \ 
     454    const char *pgerr_end = strchr(pgerr, '\n'); \ 
     455    if(!pgerr_end) pgerr_end = pgerr + strlen(pgerr); \ 
     456    noitL(ds_err, "[%s] stratcon datasource bad (%d): %.*s\n", \ 
    453457          cq->fqdn ? cq->fqdn : "metanode", d->rv, \ 
    454           PQresultErrorMessage(d->res), cmd); \ 
     458          (pgerr_end - pgerr), pgerr); \ 
    455459    PQclear(d->res); \ 
    456460    goto bad_row; \ 
     
    470474  if(d->rv != PGRES_COMMAND_OK && \ 
    471475     d->rv != PGRES_TUPLES_OK) { \ 
    472     noitL(ds_err, "stratcon datasource bad (%d): %s\n'%s' time: %llu\n", \ 
    473           d->rv, PQresultErrorMessage(d->res), cmdbuf, \ 
     476    const char *pgerr = PQresultErrorMessage(d->res); \ 
     477    const char *pgerr_end = strchr(pgerr, '\n'); \ 
     478    if(!pgerr_end) pgerr_end = pgerr + strlen(pgerr); \ 
     479    noitL(ds_err, "stratcon datasource bad (%d): %.*s time: %llu\n", \ 
     480          d->rv, (pgerr_end - pgerr), pgerr, \ 
    474481          (long long unsigned)whence); \ 
    475482    PQclear(d->res); \ 
     
    10721079stratcon_datastore_asynch_execute(eventer_t e, int mask, void *closure, 
    10731080                                  struct timeval *now) { 
    1074   int i
     1081  int i, total, success, sp_total, sp_success
    10751082  interim_journal_t *ij; 
    10761083  ds_line_detail *head, *current, *last_sp; 
     
    10911098  i = 1; 
    10921099  while(stratcon_database_connect(cq)) { 
    1093     noitL(noit_error, "Error connecting to database\n"); 
     1100    noitL(noit_error, "Error connecting to database: %s\n", 
     1101          ij->fqdn ? ij->fqdn : "(null)"); 
    10941102    sleep(i); 
    10951103    i *= 2; 
     
    10981106 
    10991107  head = build_insert_batch(ij); 
     1108  noitL(ds_deb, "Starting batch from %s/%s to %s\n", 
     1109        ij->remote_str ? ij->remote_str : "(null)", 
     1110        ij->remote_cn ? ij->remote_cn : "(null)", 
     1111        ij->fqdn ? ij->fqdn : "(null)"); 
    11001112  current = head;  
    11011113  last_sp = NULL; 
     1114  total = success = sp_total = sp_success = 0; 
    11021115  if(stratcon_datastore_do(cq, "BEGIN")) BUSTED(cq); 
    11031116  while(current) { 
    11041117    execute_outcome_t rv; 
    11051118    if(current->data) { 
    1106       if(!last_sp) SAVEPOINT("batch"); 
     1119      if(!last_sp) { 
     1120        SAVEPOINT("batch"); 
     1121        sp_success = success; 
     1122        sp_total = total; 
     1123      } 
    11071124  
    11081125      if(current->problematic) { 
    11091126        RELEASE_SAVEPOINT("batch"); 
    11101127        current = current->next; 
     1128        total++; 
    11111129        continue; 
    11121130      }  
     
    11151133      switch(rv) { 
    11161134        case DS_EXEC_SUCCESS: 
     1135          total++; 
     1136          success++; 
    11171137          current = current->next; 
    11181138          break; 
     
    11221142          current->problematic = 1; 
    11231143          current = last_sp; 
     1144          success = sp_success; 
     1145          total = sp_total; 
    11241146          ROLLBACK_TO_SAVEPOINT("batch"); 
    11251147          break; 
     
    11441166    free(tofree); 
    11451167  } 
     1168  noitL(ds_deb, "Finished batch %s/%s to %s [%d/%d]\n", 
     1169        ij->remote_str ? ij->remote_str : "(null)", 
     1170        ij->remote_cn ? ij->remote_cn : "(null)", 
     1171        ij->fqdn ? ij->fqdn : "(null)", success, total); 
    11461172  interim_journal_remove(ij); 
    11471173  release_conn_q(cq); 
     
    13731399                                    &storagenode_id, NULL, &fqdn, &dsn); 
    13741400          ij = interim_journal_get(remote, remote_cn, storagenode_id, fqdn); 
    1375 noitL(noit_error, " %s -> %d/%s { fd: %d, path: %s }\n", uuid_str, storagenode_id, fqdn, 
    1376       ij->fd, ij->filename); 
    13771401        } 
    13781402      } 
     
    17011725  ds_err = noit_log_stream_find("error/datastore"); 
    17021726  ds_deb = noit_log_stream_find("debug/datastore"); 
     1727  ds_pool_deb = noit_log_stream_find("debug/datastore_pool"); 
    17031728  ingest_err = noit_log_stream_find("error/ingest"); 
    17041729  if(!ds_err) ds_err = noit_error; 
  • src/stratcon_iep.c

    ra559c4e rabe7edb  
    379379 
    380380  if((age = stratcon_iep_age_from_line(job->line, *now)) > 60) { 
    381     noitL(noit_debug, "Skipping old event %f second old.\n", age); 
     381    noitL(noit_debug, "Skipping old event from %s, %f seconds old.\n", 
     382          job->remote ? job->remote : "(null)", age); 
    382383    return 0; 
    383384  }