Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate context state during cleanup #547

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

arajkumar
Copy link
Contributor

Currently, when switching between modes, the follow process cleans up context files, which include details like WAL segment size and timeline. However, we haven't been resetting the in-memory state that decides whether the context should be read from these files. This can lead to the usage of outdated timeline information while retriving the context[1][2][3].

This commit addresses this issue by resetting the in-memory state during context cleanup. This ensures that the system will re-read the context from the files after any cleanup, leading to more accurate and reliable timeline information.

[1]

/* we need timeline and wal_segment_size to compute WAL filenames */
if (specs->system.timeline == 0)
{
if (!stream_read_context(&(specs->paths),
&(specs->system),
&(specs->WalSegSz)))
{
log_error("Failed to read the streaming context information "
"from the source database, see above for details");
return false;
}
}

[2]
if (streamSpecs->system.timeline == 0)
{
if (!stream_read_context(&(streamSpecs->paths),
&(streamSpecs->system),
&(streamSpecs->WalSegSz)))
{
log_error("Failed to read the streaming context information "
"from the source database, see above for details");
return false;
}
}

[3]
if (specs->system.timeline == 0)
{
if (!stream_read_context(&(specs->paths),
&(specs->system),
&(specs->WalSegSz)))
{
log_error("Failed to read the streaming context information "
"from the source database, see above for details");
return false;
}
}

Currently, when switching between modes, the follow process cleans up context files, which include details like WAL segment size and timeline. However, we haven't been resetting the in-memory state that decides whether the context should be read from these files. This can lead to the usage of outdated timeline information while retriving the context[1][2][3].

This commit addresses this issue by resetting the in-memory state during context cleanup. This ensures that the system will re-read the context from the files after any cleanup, leading to more accurate and reliable timeline information.

[1] https://github.com/dimitri/pgcopydb/blob/8d305a51f82a83bacac6a3fcce716c9450505e57/src/bin/pgcopydb/ld_transform.c#L201-L212
[2] https://github.com/dimitri/pgcopydb/blob/8d305a51f82a83bacac6a3fcce716c9450505e57/src/bin/pgcopydb/follow.c#L428-L438
[3] https://github.com/dimitri/pgcopydb/blob/8d305a51f82a83bacac6a3fcce716c9450505e57/src/bin/pgcopydb/ld_apply.c#L206-L216

Signed-off-by: Arunprasad Rajkumar <ar.arunprasad@gmail.com>
@dimitri dimitri merged commit 559e446 into dimitri:main Nov 21, 2023
15 checks passed
@dimitri dimitri added this to the v0.15 milestone Nov 21, 2023
@dimitri dimitri added the bug Something isn't working label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants