Skip to content

Conversation

@mason-sharp
Copy link
Member

  • Refactor apply_worker_get_progress() to return only the timestamp needed. Return value instead of pointer to entire struct.
  • Lock sooner in spock_group_resource_dump() because of getting the number of entries
  • Properly handle progress updates after COPY operations in replication set data sync and avoid potential memory leak
  • Address compiler warnings

- Refactor apply_worker_get_progress() to return only the timestamp needed. Return value instead of pointer to entire struct.
- Lock sooner in spock_group_resource_dump() because of getting the number of entries
- Properly handle progress updates after COPY operations in replication set data sync and avoid potential memory leak
- Address compiler warnings
Copy link
Contributor

@danolivo danolivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks correct. Minor fixes should be addressed before the merge.

* because it is reported more frequently (by keepalive messages).
*/
Assert(!(dest->remote_commit_ts == 0 ^ dest->last_updated_ts == 0));
Assert(!((dest->remote_commit_ts == 0) ^ (dest->last_updated_ts == 0)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why do you add extra braces here? Is the C Standard not clear here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a compiler warning go away

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen warnings with such a code before with gcc/clang. What exactly is the problem? The same priority of operations or something else? Maybe the root issue is compiler settings?

hdr.flags = 0;

/* Acquire lock before reading hash table to ensure consistency */
LWLockAcquire(SpockCtx->apply_group_master_lock, LW_SHARED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postmaster writes the HTAB to disk at the moment when all other processes already terminated or killed. So, no potential races can happen. It would be better to check that this lock is not acquired instead (to be sure developers still follow the concept), but generally, this change is correct.

elog(LOG, "SPOCK: adjust spock.progress %d->%d to "
"remote_commit_ts='%s' "
"remote_commit_lsn=%llX remote_insert_lsn=%llX",
"remote_commit_lsn=%lX remote_insert_lsn=%lX",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both variants are incorrect. Conventional way: use the LSN_FORMAT_ARGS macros instead.

}

adjust_progress_info(origin_conn);
progress_entries_list = adjust_progress_info(origin_conn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! But call:
progress_entries_list = adjust_progress_info(origin_conn);
should be done right before the ensure_replication_slot_snapshot().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants