mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 20:43:04 +01:00
Non forced writes mode, move logic to cch, add dbb mutex, and rollback changes in ail.cpp, pio.h, pio_proto.h, unix.cpp and winnt.cpp
This commit is contained in:
parent
082b9d6989
commit
95934e47bd
@ -158,9 +158,9 @@ void AIL_checkpoint_finish(
|
||||
|
||||
tdbb = GET_THREAD_DATA;
|
||||
|
||||
PIO_flush(dbb->dbb_file, TRUE);
|
||||
PIO_flush(dbb->dbb_file);
|
||||
if (dbb->dbb_shadow)
|
||||
PIO_flush(dbb->dbb_shadow->sdw_file, TRUE);
|
||||
PIO_flush(dbb->dbb_shadow->sdw_file);
|
||||
|
||||
AIL_upd_cntrl_pt(walname, (USHORT) strlen(walname), seq, off, p_off);
|
||||
|
||||
@ -173,9 +173,9 @@ void AIL_checkpoint_finish(
|
||||
status_vector);
|
||||
|
||||
CCH_write_all_shadows(tdbb, 0, window.win_bdb, status_vector, 1, FALSE);
|
||||
PIO_flush(dbb->dbb_file, TRUE);
|
||||
PIO_flush(dbb->dbb_file);
|
||||
if (dbb->dbb_shadow)
|
||||
PIO_flush(dbb->dbb_shadow->sdw_file, TRUE);
|
||||
PIO_flush(dbb->dbb_shadow->sdw_file);
|
||||
|
||||
CCH_RELEASE(tdbb, &window);
|
||||
|
||||
|
@ -69,7 +69,8 @@
|
||||
#include "../jrd/tra_proto.h"
|
||||
#include "../jrd/ail.h"
|
||||
#include "../wal/wal_proto.h"
|
||||
|
||||
#include "../common/config/config.h"
|
||||
#include "../jrd/jrd_time.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
@ -1191,10 +1192,41 @@ void CCH_flush(TDBB tdbb, USHORT flush_flag, SLONG tra_number)
|
||||
}
|
||||
}
|
||||
|
||||
PIO_flush (dbb->dbb_file, FALSE);
|
||||
if (dbb->dbb_shadow)
|
||||
PIO_flush (dbb->dbb_shadow->sdw_file, FALSE);
|
||||
//
|
||||
// Check if flush needed
|
||||
//
|
||||
time_t now;
|
||||
int max_unflushed_writes = Config::getMaxUnflushedWrites();
|
||||
time_t max_unflushed_write_time = Config::getMaxUnflushedWriteTime();
|
||||
now = time(0);
|
||||
BOOLEAN doFlush = FALSE;
|
||||
if (!(dbb->dbb_file->fil_flags & FIL_force_write)
|
||||
&& (max_unflushed_writes > 0 || max_unflushed_write_time>0))
|
||||
{
|
||||
THD_MUTEX_LOCK(dbb->dbb_mutexes + DBB_MUTX_flush_count);
|
||||
if (((max_unflushed_writes >= 0) && (dbb->unflushed_writes == max_unflushed_writes))
|
||||
|| ((max_unflushed_write_time>=0) && (dbb->oldest_unflushed_write)
|
||||
&& (now - dbb->oldest_unflushed_write > max_unflushed_write_time))){
|
||||
doFlush = TRUE;
|
||||
dbb->unflushed_writes = 0;
|
||||
dbb->oldest_unflushed_write = NULL;
|
||||
}
|
||||
else {
|
||||
dbb->unflushed_writes++;
|
||||
if (!dbb->oldest_unflushed_write)
|
||||
{
|
||||
dbb->oldest_unflushed_write = now;
|
||||
}
|
||||
}
|
||||
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_flush_count);
|
||||
}
|
||||
|
||||
if (doFlush)
|
||||
{
|
||||
PIO_flush (dbb->dbb_file);
|
||||
if (dbb->dbb_shadow)
|
||||
PIO_flush (dbb->dbb_shadow->sdw_file);
|
||||
}
|
||||
/* take the opportunity when we know there are no pages
|
||||
in cache to check that the shadow(s) have not been
|
||||
scheduled for shutdown or deletion */
|
||||
|
@ -214,6 +214,9 @@ public:
|
||||
SLONG dbb_sweep_interval; /* Transactions between sweep */
|
||||
SLONG dbb_lock_owner_handle; /* Handle for the lock manager */
|
||||
|
||||
USHORT unflushed_writes; /* unflushed writes */
|
||||
time_t oldest_unflushed_write; /* oldest unflushed time */
|
||||
|
||||
#ifdef ISC_DATABASE_ENCRYPTION
|
||||
int (*dbb_encrypt) (); /* External encryption routine */
|
||||
int (*dbb_decrypt) (); /* External decryption routine */
|
||||
@ -328,7 +331,8 @@ typedef dbb* DBB;
|
||||
#define DBB_MUTX_cache 4 // Process-private cache management
|
||||
#define DBB_MUTX_clone 5 // Request cloning
|
||||
#define DBB_MUTX_cmp_clone 6 // Compiled request cloning
|
||||
#define DBB_MUTX_max 7
|
||||
#define DBB_MUTX_flush_count 7 // flush count/time
|
||||
#define DBB_MUTX_max 8
|
||||
#define DBB_WLCK_pools 0 // Pool manipulation
|
||||
#define DBB_WLCK_files 1 // DB and shadow file manipulation
|
||||
#define DBB_WLCK_max 2
|
||||
|
@ -48,8 +48,6 @@ class fil : public pool_alloc_rpt<SCHAR, type_fil>
|
||||
MUTX_T fil_mutex[1];
|
||||
USHORT fil_length; /* Length of expanded file name */
|
||||
SCHAR fil_string[1]; /* Expanded file name */
|
||||
USHORT unflushed_writes;
|
||||
time_t oldest_unflushed_write;
|
||||
};
|
||||
typedef fil *FIL;
|
||||
|
||||
@ -74,8 +72,6 @@ class fil : public pool_alloc_rpt<SCHAR, type_fil>
|
||||
USHORT fil_fid[3]; /* File id */
|
||||
USHORT fil_did[3]; /* Directory id */
|
||||
SCHAR fil_string[1]; /* Expanded file name */
|
||||
USHORT unflushed_writes;
|
||||
time_t oldest_unflushed_write;
|
||||
};
|
||||
tyepdef fil *FIL;
|
||||
|
||||
@ -105,8 +101,6 @@ class fil : public pool_alloc_rpt<SCHAR, type_fil>
|
||||
USHORT fil_flags;
|
||||
USHORT fil_length; /* Length of expanded file name */
|
||||
SCHAR fil_string[1]; /* Expanded file name */
|
||||
USHORT unflushed_writes;
|
||||
time_t oldest_unflushed_write;
|
||||
};
|
||||
typedef fil *FIL;
|
||||
|
||||
|
@ -33,7 +33,7 @@ extern void PIO_close(struct fil *);
|
||||
extern struct fil *PIO_create(struct dbb *, TEXT *, SSHORT, BOOLEAN);
|
||||
extern int PIO_connection(TEXT *, USHORT *);
|
||||
extern int PIO_expand(TEXT *, USHORT, TEXT *);
|
||||
extern void PIO_flush(struct fil *, BOOLEAN);
|
||||
extern void PIO_flush(struct fil *);
|
||||
extern void PIO_force_write(struct fil *, USHORT);
|
||||
extern void PIO_header(struct dbb *, SCHAR *, int);
|
||||
extern SLONG PIO_max_alloc(struct dbb *);
|
||||
|
@ -366,7 +366,7 @@ int PIO_expand(TEXT * file_name, USHORT file_length, TEXT * expanded_name)
|
||||
}
|
||||
|
||||
|
||||
void PIO_flush(FIL main_file, BOOLEAN forced)
|
||||
void PIO_flush(FIL main_file)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -378,39 +378,17 @@ void PIO_flush(FIL main_file, BOOLEAN forced)
|
||||
* Flush the operating system cache back to good, solid oxide.
|
||||
*
|
||||
**************************************/
|
||||
FIL file;
|
||||
|
||||
/* Since all SUPERSERVER_V2 database and shadow I/O is synchronous, this
|
||||
is a no-op. */
|
||||
|
||||
#ifndef SUPERSERVER_V2
|
||||
FIL file;
|
||||
time_t now;
|
||||
int max_unflushed_writes = Config::getMaxUnflushedWrites();
|
||||
time_t max_unflushed_write_time = Config::getMaxUnflushedWriteTime();
|
||||
now = time(0);
|
||||
for (file = main_file; file; file = file->fil_next) {
|
||||
if (!(file->fil_flags & FIL_force_write) )
|
||||
{
|
||||
if (file->fil_desc != -1) { /* This really should be an error */
|
||||
if (forced ||
|
||||
((max_unflushed_writes >= 0) && (file->unflushed_writes == max_unflushed_writes))
|
||||
|| ((max_unflushed_write_time>=0) && (file->oldest_unflushed_write)
|
||||
&& (now - file->oldest_unflushed_write > max_unflushed_write_time)))
|
||||
{
|
||||
THD_MUTEX_LOCK(file->fil_mutex);
|
||||
FlushFileBuffers((HANDLE) file->fil_desc);
|
||||
file->unflushed_writes = 0;
|
||||
file->oldest_unflushed_write = NULL;
|
||||
fsync(file->fil_desc);
|
||||
THD_MUTEX_UNLOCK(file->fil_mutex);
|
||||
} else if ((max_unflushed_writes >= 0) || (max_unflushed_write_time>=0)) {
|
||||
THD_MUTEX_LOCK(file->fil_mutex);
|
||||
file->unflushed_writes++;
|
||||
if (!file->oldest_unflushed_write)
|
||||
{
|
||||
file->oldest_unflushed_write = now;
|
||||
}
|
||||
THD_MUTEX_UNLOCK(file->fil_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -429,30 +407,38 @@ void PIO_force_write(FIL file, USHORT flag)
|
||||
* Set (or clear) force write, if possible, for the database.
|
||||
*
|
||||
**************************************/
|
||||
#ifdef hpux
|
||||
union fcntlun control;
|
||||
#else
|
||||
int control;
|
||||
#endif
|
||||
|
||||
/* Since all SUPERSERVER_V2 database and shadow I/O is synchronous, this
|
||||
is a no-op. */
|
||||
|
||||
#ifndef SUPERSERVER_V2
|
||||
#ifdef hpux
|
||||
union fcntlun control;
|
||||
#ifdef hpux
|
||||
control.val = (flag) ? SYNC : NULL;
|
||||
#else
|
||||
int control;
|
||||
#else
|
||||
control = (flag) ? SYNC : 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (fcntl(file->fil_desc, F_SETFL, control) == -1)
|
||||
{
|
||||
ERR_post(isc_io_error,
|
||||
gds_arg_string, "fcntl SYNC",
|
||||
gds_arg_cstring, file->fil_length,
|
||||
ERR_string(file->fil_string, file->fil_length), isc_arg_gds,
|
||||
isc_io_access_err, gds_arg_unix, errno, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag) {
|
||||
file->fil_flags |= (FIL_force_write | FIL_force_write_init);
|
||||
} else {
|
||||
file->fil_flags &= ~FIL_force_write;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,6 @@
|
||||
#include "../jrd/mov_proto.h"
|
||||
#include "../jrd/pio_proto.h"
|
||||
#include "../jrd/thd_proto.h"
|
||||
#include "../common/config/config.h"
|
||||
#include "../jrd/jrd_time.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
@ -273,7 +271,7 @@ int PIO_expand(TEXT* file_name, USHORT file_length, TEXT* expanded_name)
|
||||
}
|
||||
|
||||
|
||||
void PIO_flush(FIL main_file, BOOLEAN forced)
|
||||
void PIO_flush(FIL main_file)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -285,41 +283,20 @@ void PIO_flush(FIL main_file, BOOLEAN forced)
|
||||
* Flush the operating system cache back to good, solid oxide.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
/* Since all SUPERSERVER_V2 database and shadow I/O is synchronous, this
|
||||
is a no-op. */
|
||||
#ifndef SUPERSERVER_V2
|
||||
FIL file;
|
||||
time_t now;
|
||||
int max_unflushed_writes = Config::getMaxUnflushedWrites();
|
||||
time_t max_unflushed_write_time = Config::getMaxUnflushedWriteTime();
|
||||
now = time(0);
|
||||
|
||||
for (file = main_file; file; file = file->fil_next)
|
||||
{
|
||||
if (!(file->fil_flags & FIL_force_write))
|
||||
{
|
||||
if (forced ||
|
||||
((max_unflushed_writes >= 0) && (file->unflushed_writes == max_unflushed_writes))
|
||||
|| ((max_unflushed_write_time>=0) && (file->oldest_unflushed_write)
|
||||
&& (now - file->oldest_unflushed_write > max_unflushed_write_time)))
|
||||
if (ostype == OS_CHICAGO)
|
||||
{
|
||||
THD_MUTEX_LOCK(file->fil_mutex);
|
||||
}
|
||||
FlushFileBuffers((HANDLE) file->fil_desc);
|
||||
file->unflushed_writes = 0;
|
||||
file->oldest_unflushed_write = NULL;
|
||||
THD_MUTEX_UNLOCK(file->fil_mutex);
|
||||
} else if ((max_unflushed_writes >= 0) || (max_unflushed_write_time>=0)) {
|
||||
THD_MUTEX_LOCK(file->fil_mutex);
|
||||
file->unflushed_writes++;
|
||||
if (!file->oldest_unflushed_write)
|
||||
if (ostype == OS_CHICAGO)
|
||||
{
|
||||
file->oldest_unflushed_write = now;
|
||||
}
|
||||
THD_MUTEX_UNLOCK(file->fil_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -336,10 +313,6 @@ void PIO_force_write(FIL file, USHORT flag)
|
||||
*
|
||||
**************************************/
|
||||
|
||||
/* Since all SUPERSERVER_V2 database and shadow I/O is synchronous, this
|
||||
is a no-op. */
|
||||
|
||||
#ifndef SUPERSERVER_V2
|
||||
const bool bOldForce = (file->fil_flags & FIL_force_write_init) != 0;
|
||||
|
||||
if ((flag && !bOldForce) || (!flag && bOldForce)) {
|
||||
@ -369,13 +342,13 @@ void PIO_force_write(FIL file, USHORT flag)
|
||||
GetLastError(),
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
file->fil_flags |= (FIL_force_write | FIL_force_write_init);
|
||||
} else {
|
||||
file->fil_flags &= ~FIL_force_write;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user