@@ -74,10 +74,10 @@ alloc_history(History *observations, int count)
74
74
static void
75
75
realloc_history (History * observations , int count )
76
76
{
77
- HistoryItem * newitems ;
78
- int copyCount ,
79
- i ,
80
- j ;
77
+ HistoryItem * newitems ;
78
+ int copyCount ,
79
+ i ,
80
+ j ;
81
81
82
82
/* Allocate new array for history */
83
83
newitems = (HistoryItem * ) palloc0 (sizeof (HistoryItem ) * count );
@@ -115,7 +115,8 @@ realloc_history(History *observations, int count)
115
115
static void
116
116
handle_sigterm (SIGNAL_ARGS )
117
117
{
118
- int save_errno = errno ;
118
+ int save_errno = errno ;
119
+
119
120
shutdown_requested = true;
120
121
if (MyProc )
121
122
SetLatch (& MyProc -> procLatch );
@@ -150,7 +151,7 @@ probe_waits(History *observations, HTAB *profile_hash,
150
151
{
151
152
int i ,
152
153
newSize ;
153
- TimestampTz ts = GetCurrentTimestamp ();
154
+ TimestampTz ts = GetCurrentTimestamp ();
154
155
155
156
/* Realloc waits history if needed */
156
157
newSize = pgws_historySize ;
@@ -161,9 +162,9 @@ probe_waits(History *observations, HTAB *profile_hash,
161
162
LWLockAcquire (ProcArrayLock , LW_SHARED );
162
163
for (i = 0 ; i < ProcGlobal -> allProcCount ; i ++ )
163
164
{
164
- HistoryItem item ,
165
- * observation ;
166
- PGPROC * proc = & ProcGlobal -> allProcs [i ];
165
+ HistoryItem item ,
166
+ * observation ;
167
+ PGPROC * proc = & ProcGlobal -> allProcs [i ];
167
168
168
169
if (!pgws_should_sample_proc (proc , & item .pid , & item .wait_event_info ))
169
170
continue ;
@@ -185,8 +186,8 @@ probe_waits(History *observations, HTAB *profile_hash,
185
186
/* Write to the profile if needed */
186
187
if (write_profile )
187
188
{
188
- ProfileItem * profileItem ;
189
- bool found ;
189
+ ProfileItem * profileItem ;
190
+ bool found ;
190
191
191
192
if (!profile_pid )
192
193
item .pid = 0 ;
@@ -207,9 +208,9 @@ probe_waits(History *observations, HTAB *profile_hash,
207
208
static void
208
209
send_history (History * observations , shm_mq_handle * mqh )
209
210
{
210
- Size count ,
211
- i ;
212
- shm_mq_result mq_result ;
211
+ Size count ,
212
+ i ;
213
+ shm_mq_result mq_result ;
213
214
214
215
if (observations -> wraparound )
215
216
count = observations -> count ;
@@ -227,10 +228,10 @@ send_history(History *observations, shm_mq_handle *mqh)
227
228
for (i = 0 ; i < count ; i ++ )
228
229
{
229
230
mq_result = shm_mq_send_compat (mqh ,
230
- sizeof (HistoryItem ),
231
- & observations -> items [i ],
232
- false,
233
- true);
231
+ sizeof (HistoryItem ),
232
+ & observations -> items [i ],
233
+ false,
234
+ true);
234
235
if (mq_result == SHM_MQ_DETACHED )
235
236
{
236
237
ereport (WARNING ,
@@ -247,10 +248,10 @@ send_history(History *observations, shm_mq_handle *mqh)
247
248
static void
248
249
send_profile (HTAB * profile_hash , shm_mq_handle * mqh )
249
250
{
250
- HASH_SEQ_STATUS scan_status ;
251
- ProfileItem * item ;
252
- Size count = hash_get_num_entries (profile_hash );
253
- shm_mq_result mq_result ;
251
+ HASH_SEQ_STATUS scan_status ;
252
+ ProfileItem * item ;
253
+ Size count = hash_get_num_entries (profile_hash );
254
+ shm_mq_result mq_result ;
254
255
255
256
mq_result = shm_mq_send_compat (mqh , sizeof (count ), & count , false, true);
256
257
if (mq_result == SHM_MQ_DETACHED )
@@ -282,7 +283,7 @@ send_profile(HTAB *profile_hash, shm_mq_handle *mqh)
282
283
static HTAB *
283
284
make_profile_hash ()
284
285
{
285
- HASHCTL hash_ctl ;
286
+ HASHCTL hash_ctl ;
286
287
287
288
hash_ctl .hash = tag_hash ;
288
289
hash_ctl .hcxt = TopMemoryContext ;
@@ -303,8 +304,8 @@ make_profile_hash()
303
304
static int64
304
305
millisecs_diff (TimestampTz tz1 , TimestampTz tz2 )
305
306
{
306
- long secs ;
307
- int microsecs ;
307
+ long secs ;
308
+ int microsecs ;
308
309
309
310
TimestampDifference (tz1 , tz2 , & secs , & microsecs );
310
311
@@ -318,13 +319,13 @@ millisecs_diff(TimestampTz tz1, TimestampTz tz2)
318
319
void
319
320
pgws_collector_main (Datum main_arg )
320
321
{
321
- HTAB * profile_hash = NULL ;
322
- History observations ;
323
- MemoryContext old_context ,
324
- collector_context ;
325
- TimestampTz current_ts ,
326
- history_ts ,
327
- profile_ts ;
322
+ HTAB * profile_hash = NULL ;
323
+ History observations ;
324
+ MemoryContext old_context ,
325
+ collector_context ;
326
+ TimestampTz current_ts ,
327
+ history_ts ,
328
+ profile_ts ;
328
329
329
330
/*
330
331
* Establish signal handlers.
@@ -358,7 +359,7 @@ pgws_collector_main(Datum main_arg)
358
359
359
360
CurrentResourceOwner = ResourceOwnerCreate (NULL , "pg_wait_sampling collector" );
360
361
collector_context = AllocSetContextCreate (TopMemoryContext ,
361
- "pg_wait_sampling context" , ALLOCSET_DEFAULT_SIZES );
362
+ "pg_wait_sampling context" , ALLOCSET_DEFAULT_SIZES );
362
363
old_context = MemoryContextSwitchTo (collector_context );
363
364
alloc_history (& observations , pgws_historySize );
364
365
MemoryContextSwitchTo (old_context );
@@ -370,12 +371,12 @@ pgws_collector_main(Datum main_arg)
370
371
371
372
while (1 )
372
373
{
373
- int rc ;
374
- shm_mq_handle * mqh ;
375
- int64 history_diff ,
376
- profile_diff ;
377
- bool write_history ,
378
- write_profile ;
374
+ int rc ;
375
+ shm_mq_handle * mqh ;
376
+ int64 history_diff ,
377
+ profile_diff ;
378
+ bool write_history ,
379
+ write_profile ;
379
380
380
381
/* We need an explicit call for at least ProcSignal notifications. */
381
382
CHECK_FOR_INTERRUPTS ();
@@ -392,8 +393,8 @@ pgws_collector_main(Datum main_arg)
392
393
history_diff = millisecs_diff (history_ts , current_ts );
393
394
profile_diff = millisecs_diff (profile_ts , current_ts );
394
395
395
- write_history = (history_diff >= (int64 )pgws_historyPeriod );
396
- write_profile = (profile_diff >= (int64 )pgws_profilePeriod );
396
+ write_history = (history_diff >= (int64 ) pgws_historyPeriod );
397
+ write_profile = (profile_diff >= (int64 ) pgws_profilePeriod );
397
398
398
399
if (write_history || write_profile )
399
400
{
@@ -422,8 +423,8 @@ pgws_collector_main(Datum main_arg)
422
423
* shared memory.
423
424
*/
424
425
rc = WaitLatch (& MyProc -> procLatch , WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH ,
425
- Min (pgws_historyPeriod - (int )history_diff ,
426
- pgws_historyPeriod - (int )profile_diff ), PG_WAIT_EXTENSION );
426
+ Min (pgws_historyPeriod - (int ) history_diff ,
427
+ pgws_historyPeriod - (int ) profile_diff ), PG_WAIT_EXTENSION );
427
428
428
429
if (rc & WL_POSTMASTER_DEATH )
429
430
proc_exit (1 );
@@ -444,7 +445,7 @@ pgws_collector_main(Datum main_arg)
444
445
445
446
if (request == HISTORY_REQUEST || request == PROFILE_REQUEST )
446
447
{
447
- shm_mq_result mq_result ;
448
+ shm_mq_result mq_result ;
448
449
449
450
/* Send history or profile */
450
451
shm_mq_set_sender (pgws_collector_mq , MyProc );
0 commit comments