diff -cpr pgsql-orig/src/backend/storage/buffer/bufmgr.c pgsql/src/backend/storage/buffer/bufmgr.c
*** pgsql-orig/src/backend/storage/buffer/bufmgr.c	2006-01-13 21:59:11.000000000 +0900
--- pgsql/src/backend/storage/buffer/bufmgr.c	2006-01-13 22:05:19.000000000 +0900
***************
*** 51,56 ****
--- 51,57 ----
  #include "utils/relcache.h"
  #include "utils/resowner.h"
  #include "pgstat.h"
+ #include "postmaster/bgwriter.h"
  
  
  /* Note: these two macros only work on shared buffers, not local ones! */
*************** BufferSync(void)
*** 892,897 ****
--- 893,900 ----
  {
  	int			buf_id;
  	int			num_to_scan;
+ 	int			absorb_counter;
+ 	int			absorb_check_interval = NBuffers / 10;
  
  	/*
  	 * Find out where to start the circular scan.
*************** BufferSync(void)
*** 905,915 ****
--- 908,924 ----
  	 * Loop over all buffers.
  	 */
  	num_to_scan = NBuffers;
+ 	absorb_counter = 0;
  	while (num_to_scan-- > 0)
  	{
  		(void) SyncOneBuffer(buf_id, false);
  		if (++buf_id >= NBuffers)
  			buf_id = 0;
+ 		if (++absorb_counter >= absorb_check_interval)
+ 		{
+ 			AbsorbFsyncRequests();
+ 			absorb_counter = 0;
+ 		}
  	}
  }
  
diff -cpr pgsql-orig/src/backend/storage/smgr/md.c pgsql/src/backend/storage/smgr/md.c
*** pgsql-orig/src/backend/storage/smgr/md.c	2006-01-13 21:59:11.000000000 +0900
--- pgsql/src/backend/storage/smgr/md.c	2006-01-13 22:00:31.000000000 +0900
*************** bool
*** 701,706 ****
--- 701,709 ----
  mdsync(void)
  {
  	HASH_SEQ_STATUS hstat;
+ 	int				i;
+ 	int				count;
+ 	PendingOperationEntry *entries;
  	PendingOperationEntry *entry;
  
  	if (!pendingOpsTable)
*************** mdsync(void)
*** 714,722 ****
--- 717,745 ----
  	 */
  	AbsorbFsyncRequests();
  
+ 	/* extract entries from pendingOpsTable */
+ 	i = 0;
+ 	count = pendingOpsTable->hctl->nentries;
+ 	entries = palloc(count * sizeof(PendingOperationEntry));
  	hash_seq_init(&hstat, pendingOpsTable);
  	while ((entry = (PendingOperationEntry *) hash_seq_search(&hstat)) != NULL)
  	{
+ 		if (i >= count)
+ 			elog(ERROR, "pendingOpsTable corrupted");
+ 
+ 		memcpy(&entries[i++], entry, sizeof(PendingOperationEntry));
+ 
+ 		if (hash_search(pendingOpsTable, entry,
+ 						HASH_REMOVE, NULL) == NULL)
+ 			elog(ERROR, "pendingOpsTable corrupted");
+ 	}
+ 
+ 	if (i != count)
+ 		elog(ERROR, "pendingOpsTable corrupted");
+ 
+ 	for (i = 0; i < count; i++)
+ 	{
+ 		entry = &entries[i];
  		/*
  		 * If fsync is off then we don't have to bother opening the file at
  		 * all.  (We delay checking until this point so that changing fsync on
*************** mdsync(void)
*** 766,782 ****
  									entry->rnode.spcNode,
  									entry->rnode.dbNode,
  									entry->rnode.relNode)));
  					return false;
  				}
  			}
  		}
- 
- 		/* Okay, delete this entry */
- 		if (hash_search(pendingOpsTable, entry,
- 						HASH_REMOVE, NULL) == NULL)
- 			elog(ERROR, "pendingOpsTable corrupted");
  	}
  
  	return true;
  }
  
--- 789,809 ----
  									entry->rnode.spcNode,
  									entry->rnode.dbNode,
  									entry->rnode.relNode)));
+ 					/* revert pendingOpsTable */
+ 					for (; i < count; i++)
+ 					{
+ 						(void) hash_search(pendingOpsTable, &entries[i], HASH_ENTER, NULL);
+ 					}
+ 					pfree(entries);
  					return false;
  				}
+ 
+ 				AbsorbFsyncRequests();
  			}
  		}
  	}
  
+ 	pfree(entries);
  	return true;
  }
  
