diff src/backend/access/transam/xact.c index c71a10e..9b85441 *** a/src/backend/access/transam/xact.c --- b/src/backend/access/transam/xact.c *************** RecordTransactionCommit(void) *** 1118,1139 **** if ((wrote_xlog && synchronous_commit > SYNCHRONOUS_COMMIT_OFF) || forceSyncCommit || nrels > 0) { - /* - * Synchronous commit case: - * - * Sleep before flush! So we can flush more than one commit records - * per single fsync. (The idea is some other backend may do the - * XLogFlush while we're sleeping. This needs work still, because on - * most Unixen, the minimum select() delay is 10msec or more, which is - * way too long.) - * - * We do not sleep if enableFsync is not turned on, nor if there are - * fewer than CommitSiblings other backends with active transactions. - */ - if (CommitDelay > 0 && enableFsync && - MinimumActiveBackends(CommitSiblings)) - pg_usleep(CommitDelay); - XLogFlush(XactLastRecEnd); /* --- 1118,1123 ---- diff src/backend/access/transam/xlog.c index d3650bd..6715618 *** a/src/backend/access/transam/xlog.c --- b/src/backend/access/transam/xlog.c *************** int wal_level = WAL_LEVEL_MINIMAL; *** 85,90 **** --- 85,94 ---- bool XLOG_DEBUG = false; #endif + /* This should appear in a header */ + extern int CommitDelay; + extern int CommitSiblings; + /* * XLOGfileslop is the maximum number of preallocated future XLOG segments. * When we are done with an old XLOG segment file, we will recycle it as a *************** XLogFlush(XLogRecPtr record) *** 2111,2116 **** --- 2115,2137 ---- */ continue; } + + /* + * Synchronous commit case: + * + * Sleep before flush! So we can flush more than one commit records + * per single fsync. (The idea is some other backend may do the + * XLogFlush while we're sleeping. This needs work still, because on + * most Unixen, the minimum select() delay is 10msec or more, which is + * way too long.) + * + * We do not sleep if enableFsync is not turned on, nor if there are + * fewer than CommitSiblings other backends with active transactions. + */ + if (CommitDelay > 0 && enableFsync && + MinimumActiveBackends(CommitSiblings)) + pg_usleep(CommitDelay); + /* Got the lock */ LogwrtResult = XLogCtl->LogwrtResult; if (!XLByteLE(record, LogwrtResult.Flush))