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
b0299c5d
Commit
b0299c5d
authored
Nov 09, 2000
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto checkpoint creation.
parent
a0951eec
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
142 additions
and
55 deletions
+142
-55
src/backend/access/transam/xlog.c
src/backend/access/transam/xlog.c
+10
-5
src/backend/bootstrap/bootstrap.c
src/backend/bootstrap/bootstrap.c
+27
-26
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+82
-20
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+14
-1
src/bin/initdb/initdb.sh
src/bin/initdb/initdb.sh
+2
-2
src/include/bootstrap/bootstrap.h
src/include/bootstrap/bootstrap.h
+7
-1
No files found.
src/backend/access/transam/xlog.c
View file @
b0299c5d
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.2
4 2000/11/05 22:50:19
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.2
5 2000/11/09 11:25:58
vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -42,13 +42,13 @@ void CreateCheckPoint(bool shutdown);
char
XLogDir
[
MAXPGPATH
];
char
ControlFilePath
[
MAXPGPATH
];
uint32
XLOGbuffers
=
0
;
int
XLOGbuffers
=
0
;
XLogRecPtr
MyLastRecPtr
=
{
0
,
0
};
bool
StopIfError
=
false
;
bool
InRecovery
=
false
;
StartUpID
ThisStartUpID
=
0
;
int
XLOG_DEBUG
=
1
;
int
XLOG_DEBUG
=
0
;
/* To read/update control file and create new log file */
SPINLOCK
ControlFileLockId
;
...
...
@@ -919,7 +919,7 @@ MoveOfflineLogs(char *archdir, uint32 _logId, uint32 _logSeg)
elog
(
LOG
,
"MoveOfflineLogs: %s %s"
,
(
archdir
[
0
])
?
"archive"
:
"remove"
,
xlde
->
d_name
);
sprintf
(
path
,
"%s%c%s"
,
XLogDir
,
SEP_CHAR
,
xlde
->
d_name
);
if
(
archdir
[
0
]
!
=
0
)
if
(
archdir
[
0
]
=
=
0
)
unlink
(
path
);
errno
=
0
;
}
...
...
@@ -1641,9 +1641,14 @@ SetThisStartUpID(void)
void
ShutdownXLOG
()
{
#ifdef XLOG
extern
void
CreateDummyCaches
(
void
);
#endif
elog
(
LOG
,
"Data Base System shutting down at %s"
,
str_time
(
time
(
NULL
)));
#ifdef XLOG
CreateDummyCaches
();
#endif
CreateCheckPoint
(
true
);
elog
(
LOG
,
"Data Base System shut down at %s"
,
str_time
(
time
(
NULL
)));
...
...
src/backend/bootstrap/bootstrap.c
View file @
b0299c5d
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.9
7 2000/11/08 22:09:56 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.9
8 2000/11/09 11:25:58 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -220,7 +220,7 @@ BootstrapMain(int argc, char *argv[])
int
i
;
char
*
dbName
;
int
flag
;
bool
xloginit
=
false
;
int
xlogop
=
BS_XLOG_NOP
;
char
*
potential_DataDir
=
NULL
;
extern
int
optind
;
...
...
@@ -260,7 +260,7 @@ BootstrapMain(int argc, char *argv[])
potential_DataDir
=
getenv
(
"PGDATA"
);
/* Null if no PGDATA variable */
}
while
((
flag
=
getopt
(
argc
,
argv
,
"D:dCQxpB:F"
))
!=
EOF
)
while
((
flag
=
getopt
(
argc
,
argv
,
"D:dCQx
:
pB:F"
))
!=
EOF
)
{
switch
(
flag
)
{
...
...
@@ -281,7 +281,7 @@ BootstrapMain(int argc, char *argv[])
Quiet
=
true
;
break
;
case
'x'
:
xlog
init
=
true
;
xlog
op
=
atoi
(
optarg
)
;
break
;
case
'p'
:
/* indicates fork from postmaster */
...
...
@@ -339,40 +339,41 @@ BootstrapMain(int argc, char *argv[])
}
/*
* Bootstrap under Postmaster means two things: (xloginit) ?
* StartupXLOG : ShutdownXLOG
*
* If !under Postmaster and xloginit then BootStrapXLOG.
* XLOG operations
*/
if
(
IsUnderPostmaster
||
xloginit
)
if
(
xlogop
!=
BS_XLOG_NOP
)
{
snprintf
(
XLogDir
,
MAXPGPATH
,
"%s/pg_xlog"
,
DataDir
);
snprintf
(
ControlFilePath
,
MAXPGPATH
,
"%s/global/pg_control"
,
DataDir
);
if
(
xlogop
==
BS_XLOG_BOOTSTRAP
)
BootStrapXLOG
();
else
{
SetProcessingMode
(
NormalProcessing
);
if
(
xlogop
==
BS_XLOG_STARTUP
)
StartupXLOG
();
else
if
(
xlogop
==
BS_XLOG_CHECKPOINT
)
{
#ifdef XLOG
extern
void
CreateDummyCaches
(
void
);
CreateDummyCaches
();
#endif
CreateCheckPoint
(
false
);
}
else
if
(
xlogop
==
BS_XLOG_SHUTDOWN
)
ShutdownXLOG
();
else
elog
(
STOP
,
"Unsupported XLOG op %d"
,
xlogop
);
proc_exit
(
0
);
}
}
if
(
IsUnderPostmaster
&&
xloginit
)
{
SetProcessingMode
(
NormalProcessing
);
StartupXLOG
();
proc_exit
(
0
);
}
if
(
!
IsUnderPostmaster
&&
xloginit
)
BootStrapXLOG
();
/*
* backend initialization
*/
InitPostgres
(
dbName
,
NULL
);
LockDisable
(
true
);
if
(
IsUnderPostmaster
&&
!
xloginit
)
{
SetProcessingMode
(
NormalProcessing
);
ShutdownXLOG
();
proc_exit
(
0
);
}
for
(
i
=
0
;
i
<
MAXATTR
;
i
++
)
{
attrtypes
[
i
]
=
(
Form_pg_attribute
)
NULL
;
...
...
src/backend/postmaster/postmaster.c
View file @
b0299c5d
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.18
0 2000/11/08 17:57:46 petere
Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.18
1 2000/11/09 11:25:59 vadim
Exp $
*
* NOTES
*
...
...
@@ -78,7 +78,7 @@
#include "utils/exc.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "bootstrap/bootstrap.h"
#define INVALID_SOCK (-1)
#define ARGV_SIZE 64
...
...
@@ -197,8 +197,12 @@ bool NetServer = false; /* listen on TCP/IP */
bool
EnableSSL
=
false
;
bool
SilentMode
=
false
;
/* silent mode (-S) */
static
pid_t
StartupPID
=
0
,
ShutdownPID
=
0
;
int
CheckPointTimeout
=
300
;
static
pid_t
StartupPID
=
0
,
ShutdownPID
=
0
,
CheckPointPID
=
0
;
static
time_t
checkpointed
=
0
;
#define NoShutdown 0
#define SmartShutdown 1
...
...
@@ -250,11 +254,11 @@ static void SignalChildren(SIGNAL_ARGS);
static
int
CountChildren
(
void
);
static
bool
CreateOptsFile
(
int
argc
,
char
*
argv
[]);
extern
int
BootstrapMain
(
int
argc
,
char
*
argv
[]);
static
pid_t
SSDataBase
(
bool
startup
);
static
pid_t
SSDataBase
(
int
xlop
);
#define StartupDataBase() SSDataBase(true)
#define ShutdownDataBase() SSDataBase(false)
#define StartupDataBase() SSDataBase(BS_XLOG_STARTUP)
#define CheckPointDataBase() SSDataBase(BS_XLOG_CHECKPOINT)
#define ShutdownDataBase() SSDataBase(BS_XLOG_SHUTDOWN)
#ifdef USE_SSL
static
void
InitSSL
(
void
);
...
...
@@ -814,13 +818,27 @@ ServerLoop(void)
for
(;;)
{
Port
*
port
;
fd_set
rmask
,
wmask
;
struct
timeval
*
timeout
=
(
struct
timeval
*
)
NULL
;
#ifdef USE_SSL
struct
timeval
timeout_tv
;
Port
*
port
;
fd_set
rmask
,
wmask
;
struct
timeval
*
timeout
=
NULL
;
struct
timeval
timeout_tv
;
if
(
CheckPointPID
==
0
&&
checkpointed
)
{
time_t
now
=
time
(
NULL
);
if
(
CheckPointTimeout
+
checkpointed
>
now
)
{
timeout_tv
.
tv_sec
=
CheckPointTimeout
+
checkpointed
-
now
;
timeout_tv
.
tv_usec
=
0
;
timeout
=
&
timeout_tv
;
}
else
CheckPointPID
=
CheckPointDataBase
();
}
#ifdef USE_SSL
/*
* If we are using SSL, there may be input data already read and
* pending in SSL's input buffers. If so, check for additional
...
...
@@ -850,6 +868,7 @@ ServerLoop(void)
if
(
select
(
nSockets
,
&
rmask
,
&
wmask
,
(
fd_set
*
)
NULL
,
timeout
)
<
0
)
{
PG_SETMASK
(
&
BlockSig
);
if
(
errno
==
EINTR
||
errno
==
EWOULDBLOCK
)
continue
;
fprintf
(
stderr
,
"%s: ServerLoop: select failed: %s
\n
"
,
...
...
@@ -1186,6 +1205,14 @@ processCancelRequest(Port *port, PacketLen len, void *pkt)
backendPID
=
(
int
)
ntohl
(
canc
->
backendPID
);
cancelAuthCode
=
(
long
)
ntohl
(
canc
->
cancelAuthCode
);
if
(
backendPID
==
CheckPointPID
)
{
if
(
DebugLvl
)
fprintf
(
stderr
,
"%s: processCancelRequest: CheckPointPID in cancel request for process %d
\n
"
,
progname
,
backendPID
);
return
STATUS_ERROR
;
}
/* See if we have a matching backend */
for
(
curr
=
DLGetHead
(
BackendList
);
curr
;
curr
=
DLGetSucc
(
curr
))
...
...
@@ -1480,6 +1507,9 @@ reaper(SIGNAL_ARGS)
*/
SetThisStartUpID
();
CheckPointPID
=
0
;
checkpointed
=
time
(
NULL
);
pqsignal
(
SIGCHLD
,
reaper
);
return
;
}
...
...
@@ -1563,7 +1593,13 @@ CleanupProc(int pid,
curr
=
DLGetSucc
(
curr
);
}
ProcRemove
(
pid
);
if
(
pid
==
CheckPointPID
)
{
CheckPointPID
=
0
;
checkpointed
=
time
(
NULL
);
}
else
ProcRemove
(
pid
);
return
;
}
...
...
@@ -1612,7 +1648,13 @@ CleanupProc(int pid,
* only, couldn't we just sigpause?), so probably we'll remove
* this call from here someday. -- vadim 04-10-1999
*/
ProcRemove
(
pid
);
if
(
pid
==
CheckPointPID
)
{
CheckPointPID
=
0
;
checkpointed
=
0
;
}
else
ProcRemove
(
pid
);
DLRemove
(
curr
);
free
(
bp
);
...
...
@@ -2090,6 +2132,8 @@ CountChildren(void)
if
(
bp
->
pid
!=
mypid
)
cnt
++
;
}
if
(
CheckPointPID
!=
0
)
cnt
--
;
return
cnt
;
}
...
...
@@ -2132,10 +2176,11 @@ InitSSL(void)
#endif
static
pid_t
SSDataBase
(
bool
startu
p
)
SSDataBase
(
int
xlo
p
)
{
pid_t
pid
;
int
i
;
Backend
*
bn
;
static
char
ssEntry
[
4
][
2
*
ARGV_SIZE
];
for
(
i
=
0
;
i
<
4
;
++
i
)
...
...
@@ -2159,6 +2204,7 @@ SSDataBase(bool startup)
int
ac
=
0
;
char
nbbuf
[
ARGV_SIZE
];
char
dbbuf
[
ARGV_SIZE
];
char
xlbuf
[
ARGV_SIZE
];
/* Lose the postmaster's on-exit routines and port connections */
on_exit_reset
();
...
...
@@ -2178,8 +2224,8 @@ SSDataBase(bool startup)
sprintf
(
nbbuf
,
"-B%u"
,
NBuffers
);
av
[
ac
++
]
=
nbbuf
;
if
(
startup
)
av
[
ac
++
]
=
"-x"
;
sprintf
(
xlbuf
,
"-x %d"
,
xlop
);
av
[
ac
++
]
=
xlbuf
;
av
[
ac
++
]
=
"-p"
;
...
...
@@ -2206,12 +2252,28 @@ SSDataBase(bool startup)
if
(
pid
<
0
)
{
fprintf
(
stderr
,
"%s Data Base: fork failed: %s
\n
"
,
((
startup
)
?
"Startup"
:
"Shutdown"
),
strerror
(
errno
));
((
xlop
==
BS_XLOG_STARTUP
)
?
"Startup"
:
((
xlop
==
BS_XLOG_CHECKPOINT
)
?
"CheckPoint"
:
"Shutdown"
)),
strerror
(
errno
));
ExitPostmaster
(
1
);
}
NextBackendTag
-=
1
;
if
(
xlop
!=
BS_XLOG_CHECKPOINT
)
return
(
pid
);
if
(
!
(
bn
=
(
Backend
*
)
calloc
(
1
,
sizeof
(
Backend
))))
{
fprintf
(
stderr
,
"%s: CheckPointDataBase: malloc failed
\n
"
,
progname
);
ExitPostmaster
(
1
);
}
bn
->
pid
=
pid
;
bn
->
cancel_key
=
0
;
DLAddHead
(
BackendList
,
DLNewElem
(
bn
));
return
(
pid
);
}
...
...
src/backend/utils/misc/guc.c
View file @
b0299c5d
...
...
@@ -4,7 +4,7 @@
* Support for grand unified configuration scheme, including SET
* command, configuration file, and command line options.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.1
5 2000/11/01 21:14:03 petere
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.1
6 2000/11/09 11:25:59 vadim
Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
...
...
@@ -36,6 +36,10 @@
/* XXX should be in a header file */
extern
bool
Log_connections
;
extern
int
CheckPointTimeout
;
extern
int
XLOGbuffers
;
extern
int
XLOG_DEBUG
;
/*
* Debugging options
*/
...
...
@@ -257,6 +261,15 @@ ConfigureNamesInt[] =
{
"unix_socket_permissions"
,
PGC_POSTMASTER
,
&
Unix_socket_permissions
,
0777
,
0000
,
0777
},
{
"checkpoint_timeout"
,
PGC_POSTMASTER
,
&
CheckPointTimeout
,
300
,
30
,
1800
},
{
"wal_buffers"
,
PGC_POSTMASTER
,
&
XLOGbuffers
,
4
,
4
,
INT_MAX
},
{
"wal_debug"
,
PGC_POSTMASTER
,
&
XLOG_DEBUG
,
0
,
0
,
16
},
{
NULL
,
0
,
NULL
,
0
,
0
,
0
}
};
...
...
src/bin/initdb/initdb.sh
View file @
b0299c5d
...
...
@@ -23,7 +23,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.11
1 2000/11/06 22:18:09 petere
Exp $
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.11
2 2000/11/09 11:26:00 vadim
Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -440,7 +440,7 @@ else
fi
BACKENDARGS
=
"-boot -C -F -D
$PGDATA
$BACKEND_TALK_ARG
"
FIRSTRUN
=
"-boot -x -C -F -D
$PGDATA
$BACKEND_TALK_ARG
"
FIRSTRUN
=
"-boot -x
1
-C -F -D
$PGDATA
$BACKEND_TALK_ARG
"
echo
"Creating template database in
$PGDATA
/base/1"
[
"
$debug
"
=
yes
]
&&
echo
"Running:
$PGPATH
/postgres
$FIRSTRUN
template1"
...
...
src/include/bootstrap/bootstrap.h
View file @
b0299c5d
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: bootstrap.h,v 1.
19 2000/07/14 22:17:54 tgl
Exp $
* $Id: bootstrap.h,v 1.
20 2000/11/09 11:26:00 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -57,4 +57,10 @@ extern void build_indices(void);
extern
int
Int_yylex
(
void
);
extern
void
Int_yyerror
(
const
char
*
str
);
#define BS_XLOG_NOP 0
#define BS_XLOG_BOOTSTRAP 1
#define BS_XLOG_STARTUP 2
#define BS_XLOG_CHECKPOINT 3
#define BS_XLOG_SHUTDOWN 4
#endif
/* BOOTSTRAP_H */
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