Skip to content

Commit

Permalink
Fixed computation of the utmost completion time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonin Houska committed Jun 13, 2024
1 parent 8bc7be4 commit 3f6c271
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pg_squeeze.c
Original file line number Diff line number Diff line change
Expand Up @@ -3100,10 +3100,20 @@ perform_final_merge(Oid relid_src, Oid *indexes_src, int nindexes,
struct timeval t_start;

gettimeofday(&t_start, NULL);
/* Add the whole seconds. */
t_end.tv_sec = t_start.tv_sec + squeeze_max_xlock_time / 1000;
/* Add the rest, expressed in microseconds. */
usec = t_start.tv_usec + 1000 * (squeeze_max_xlock_time % 1000);
t_end.tv_sec = t_start.tv_sec + usec / USECS_PER_SEC;
/* The number of microseconds could have overflown. */
t_end.tv_sec += usec / USECS_PER_SEC;
t_end.tv_usec = usec % USECS_PER_SEC;
t_end_ptr = &t_end;

elog(DEBUG1,
"pg_squeeze: completion required by %lu.%lu, current time is %lu.%lu.",
t_end_ptr->tv_sec, t_end_ptr->tv_usec, t_start.tv_sec,
t_start.tv_usec);

}

/*
Expand Down Expand Up @@ -3153,6 +3163,16 @@ perform_final_merge(Oid relid_src, Oid *indexes_src, int nindexes,
cat_state, rel_dst, ident_key,
ident_key_nentries, iistate,
AccessExclusiveLock, t_end_ptr);
if (t_end_ptr)
{
struct timeval t_now;

gettimeofday(&t_now, NULL);
elog(DEBUG1,
"pg_squeeze: concurrent changes processed at %lu.%lu, result: %u",
t_now.tv_sec, t_now.tv_usec, success);
}

if (!success)
{
/* Unlock the relations and indexes. */
Expand Down

0 comments on commit 3f6c271

Please sign in to comment.