Skip to content

Commit

Permalink
Fix possible race condition when reading text file
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Jun 21, 2024
1 parent c615a67 commit 1d20045
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pg_tracing_sql_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ pg_tracing_spans(PG_FUNCTION_ARGS)
return (Datum) 0;

LWLockAcquire(pg_tracing_shared_state->lock, lock_mode);
/* There was a new write, reload the text file */
if (pg_tracing_shared_state->extent != qbuffer_size)
{
free(qbuffer);
qbuffer = qtext_load_file(&qbuffer_size);
}
Assert(pg_tracing_shared_state->extent == qbuffer_size);

for (int i = 0; i < shared_spans->end; i++)
{
span = shared_spans->spans + i;
Expand Down

0 comments on commit 1d20045

Please sign in to comment.