Changeset 59 for trunk/pbs_drmaa


Ignore:
Timestamp:
01/08/12 22:02:20 (12 years ago)
Author:
mmamonski
Message:

Detect PBS server restart and log corruption

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pbs_drmaa/log_reader.c

    r49 r59  
    231231                                                 { 
    232232                                                        event_timestamp = field_token; 
     233#ifdef PBS_PBS_PROFESSIONAL 
     234                                                        /*additional check */ 
     235                                                        TRY 
     236                                                        { 
     237                                                         (void)pbsdrmaa_parse_log_timestamp(event_timestamp, timestamp_unix, sizeof(timestamp_unix)); 
     238                                                        } 
     239                                                        EXCEPT_DEFAULT 
     240                                                        { 
     241                                                                fsd_log_error(("Failed to parse timestamp: %s. Log corrupted?", event_timestamp)); 
     242                                                        } 
     243                                                        END_TRY 
     244#endif 
    233245                                                 } 
    234246                                                else if ( field_id == PBSDRMAA_FLD_ID_EVENT) 
     
    510522                int num_tries = 0; 
    511523                struct tm tm;  
     524                char *old_log_path = NULL; 
    512525                 
    513526                fsd_log_enter(("")); 
     
    522535                #define DRMAA_WAIT_THREAD_MAX_TRIES (12) 
    523536                /* generate new date, close file and open new */ 
    524                 if (self->log_path) 
    525                         fsd_free(self->log_path); 
     537                old_log_path = self->log_path; 
    526538 
    527539                self->log_path = fsd_asprintf("%s/server_logs/%04d%02d%02d", pbssession->pbs_home, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 
     
    562574                        self->first_open = false; 
    563575                 } 
     576                else if (old_log_path && strcmp(old_log_path, self->log_path)) 
     577                 { 
     578                        fsd_log_info(("PBS restarted. Seeking log file %u", (unsgined int)self->current_offset)); 
     579                        if(fseek(self->fhandle, self->current_offset, SEEK_SET) == (off_t) -1) 
     580                         { 
     581                                fsd_exc_raise_fmt(FSD_ERRNO_INTERNAL_ERROR,"fseek error"); 
     582                         } 
     583                 } 
    564584 
    565585                self->date_changed = false; 
    566586                 
     587                fsd_free(old_log_path); 
     588 
    567589                fsd_log_return(("")); 
    568590        }        
Note: See TracChangeset for help on using the changeset viewer.