Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b6d6488a
Commit
b6d6488a
authored
Jul 31, 2018
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pg_upgrade: fix --check for live source server checks
Fix for commit
244142d3
. Backpatch-through: 9.3
parent
df163230
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
58 deletions
+59
-58
src/bin/pg_upgrade/controldata.c
src/bin/pg_upgrade/controldata.c
+59
-58
No files found.
src/bin/pg_upgrade/controldata.c
View file @
b6d6488a
...
...
@@ -113,6 +113,65 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_putenv
(
"LC_ALL"
,
NULL
);
pg_putenv
(
"LC_MESSAGES"
,
"C"
);
/*
* Check for clean shutdown
*/
if
(
!
live_check
||
cluster
==
&
new_cluster
)
{
/* only pg_controldata outputs the cluster state */
snprintf
(
cmd
,
sizeof
(
cmd
),
"
\"
%s/pg_controldata
\"
\"
%s
\"
"
,
cluster
->
bindir
,
cluster
->
pgdata
);
fflush
(
stdout
);
fflush
(
stderr
);
if
((
output
=
popen
(
cmd
,
"r"
))
==
NULL
)
pg_fatal
(
"could not get control data using %s: %s
\n
"
,
cmd
,
strerror
(
errno
));
/* we have the result of cmd in "output". so parse it line by line now */
while
(
fgets
(
bufin
,
sizeof
(
bufin
),
output
))
{
if
((
p
=
strstr
(
bufin
,
"Database cluster state:"
))
!=
NULL
)
{
p
=
strchr
(
p
,
':'
);
if
(
p
==
NULL
||
strlen
(
p
)
<=
1
)
pg_fatal
(
"%d: database cluster state problem
\n
"
,
__LINE__
);
p
++
;
/* remove ':' char */
/*
* We checked earlier for a postmaster lock file, and if we found
* one, we tried to start/stop the server to replay the WAL. However,
* pg_ctl -m immediate doesn't leave a lock file, but does require
* WAL replay, so we check here that the server was shut down cleanly,
* from the controldata perspective.
*/
/* remove leading spaces */
while
(
*
p
==
' '
)
p
++
;
if
(
strcmp
(
p
,
"shut down
\n
"
)
!=
0
)
{
if
(
cluster
==
&
old_cluster
)
pg_fatal
(
"The source cluster was not shut down cleanly.
\n
"
);
else
pg_fatal
(
"The target cluster was not shut down cleanly.
\n
"
);
}
got_cluster_state
=
true
;
}
}
pclose
(
output
);
if
(
!
got_cluster_state
)
{
if
(
cluster
==
&
old_cluster
)
pg_fatal
(
"The source cluster lacks cluster state information:
\n
"
);
else
pg_fatal
(
"The target cluster lacks cluster state information:
\n
"
);
}
}
/* pg_resetxlog has been renamed to pg_resetwal in version 10 */
if
(
GET_MAJOR_VERSION
(
cluster
->
bin_version
)
<
1000
)
resetwal_bin
=
"pg_resetxlog
\"
-n"
;
...
...
@@ -423,64 +482,6 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pclose
(
output
);
/*
* Check for clean shutdown
*/
/* only pg_controldata outputs the cluster state */
snprintf
(
cmd
,
sizeof
(
cmd
),
"
\"
%s/pg_controldata
\"
\"
%s
\"
"
,
cluster
->
bindir
,
cluster
->
pgdata
);
fflush
(
stdout
);
fflush
(
stderr
);
if
((
output
=
popen
(
cmd
,
"r"
))
==
NULL
)
pg_fatal
(
"could not get control data using %s: %s
\n
"
,
cmd
,
strerror
(
errno
));
/* we have the result of cmd in "output". so parse it line by line now */
while
(
fgets
(
bufin
,
sizeof
(
bufin
),
output
))
{
if
((
!
live_check
||
cluster
==
&
new_cluster
)
&&
(
p
=
strstr
(
bufin
,
"Database cluster state:"
))
!=
NULL
)
{
p
=
strchr
(
p
,
':'
);
if
(
p
==
NULL
||
strlen
(
p
)
<=
1
)
pg_fatal
(
"%d: database cluster state problem
\n
"
,
__LINE__
);
p
++
;
/* remove ':' char */
/*
* We checked earlier for a postmaster lock file, and if we found
* one, we tried to start/stop the server to replay the WAL. However,
* pg_ctl -m immediate doesn't leave a lock file, but does require
* WAL replay, so we check here that the server was shut down cleanly,
* from the controldata perspective.
*/
/* remove leading spaces */
while
(
*
p
==
' '
)
p
++
;
if
(
strcmp
(
p
,
"shut down
\n
"
)
!=
0
)
{
if
(
cluster
==
&
old_cluster
)
pg_fatal
(
"The source cluster was not shut down cleanly.
\n
"
);
else
pg_fatal
(
"The target cluster was not shut down cleanly.
\n
"
);
}
got_cluster_state
=
true
;
}
}
pclose
(
output
);
if
(
!
got_cluster_state
)
{
if
(
cluster
==
&
old_cluster
)
pg_fatal
(
"The source cluster lacks cluster state information:
\n
"
);
else
pg_fatal
(
"The target cluster lacks cluster state information:
\n
"
);
}
/*
* Restore environment variables
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment