112#ifdef USE_INJECTION_POINTS
115 "inj_io_completion_hook",
137#ifdef USE_INJECTION_POINTS
140 elog(
LOG,
"injection point loaded");
184#define MAX_BUFFERS_TO_EXTEND_BY 64
285 for (
int i = 0;
i < 100;
i++)
293 elog(
LOG,
"corrupting checksum of blk %u from %u to %u",
297 if (verify_checksum !=
ph->pd_checksum)
305 elog(
ERROR,
"could not corrupt checksum, what's going on?");
369 elog(
ERROR,
"toy buffer %d was already pinned",
407 for (
int i = 0;
i < nblocks;
i++)
425 for (
int i = 0;
i < nblocks;
i++)
431 for (
int i = 0;
i < nblocks;
i++)
452 (
void *) pages, nblocks);
460 for (
int i = 0;
i < nblocks;
i++)
491 buf =
pr.recent_buffer;
567 for (
int blkno = 0; blkno < nblocks; blkno++)
636 errmsg(
"buffer %d after StartBufferIO: %s",
672 errmsg(
"buffer %d before Terminate[Local]BufferIO: %s",
684 errmsg(
"buffer %d after Terminate[Local]BufferIO: %s",
704 int nblocks_done = 0;
731 while (nblocks_done < nblocks)
744 &buffers[nblocks_done],
745 startblock + nblocks_done,
821 for (
int i = 0;
i < nblocks_done;
i++)
842 void *callback_private_data,
843 void *per_buffer_data)
873 elog(
ERROR,
"expected 1 dimensional int4 array");
896 elog(
ERROR,
"read_stream_next_buffer() call %d is unexpectedly invalid",
i);
908 elog(
ERROR,
"read_stream_next_buffer() call %d is unexpectedly valid",
988#ifdef USE_INJECTION_POINTS
990 const void *private_data,
993 const void *private_data,
1098 errmsg(
"short read injection point called, is enabled: %d",
1107 int32 processed = 0;
1110 errmsg(
"short read inject point, changing result from %d to %d",
1124 for (
int i = 0;
i <
ioh->op_data.read.iov_length;
i++)
1127 processed +=
iov[
i].iov_len;
1133 processed +=
iov[
i].iov_len;
1156 errmsg(
"reopen injection point called, is enabled: %d",
1161 elog(
ERROR,
"injection point triggering failure to reopen ");
1169#ifdef USE_INJECTION_POINTS
1178 elog(
ERROR,
"injection points not supported");
1188#ifdef USE_INJECTION_POINTS
1195 elog(
ERROR,
"injection points not supported");
1205#ifdef USE_INJECTION_POINTS
1215 elog(
ERROR,
"injection points not supported");
1225#ifdef USE_INJECTION_POINTS
1228 elog(
ERROR,
"injection points not supported");
1237#ifdef USE_INJECTION_POINTS
1240 elog(
ERROR,
"injection points not supported");
1250#ifdef USE_INJECTION_POINTS
1253 elog(
ERROR,
"injection points not supported");
PgAioHandle * pgaio_io_acquire(struct ResourceOwnerData *resowner, PgAioReturn *ret)
void pgaio_io_get_wref(PgAioHandle *ioh, PgAioWaitRef *iow)
void pgaio_io_set_flag(PgAioHandle *ioh, PgAioHandleFlags flag)
ProcNumber pgaio_io_get_owner(PgAioHandle *ioh)
void pgaio_enter_batchmode(void)
void pgaio_wref_wait(PgAioWaitRef *iow)
void pgaio_io_release(PgAioHandle *ioh)
void pgaio_exit_batchmode(void)
@ PGAIO_HCB_LOCAL_BUFFER_READV
@ PGAIO_HCB_SHARED_BUFFER_READV
@ PGAIO_HF_REFERENCES_LOCAL
void pgaio_io_set_handle_data_32(PgAioHandle *ioh, uint32 *data, uint8 len)
void pgaio_io_register_callbacks(PgAioHandle *ioh, PgAioHandleCallbackID cb_id, uint8 cb_data)
void pgaio_result_report(PgAioResult result, const PgAioTargetData *target_data, int elevel)
PgAioTargetData * pgaio_io_get_target_data(PgAioHandle *ioh)
#define PG_GETARG_ARRAYTYPE_P(n)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static void pg_atomic_unlocked_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
#define InvalidBlockNumber
static Datum values[MAXATTR]
#define BufferIsLocal(buffer)
static uint64 UnlockBufHdrExt(BufferDesc *desc, uint64 old_buf_state, uint64 set_bits, uint64 unset_bits, int refcount_change)
static void ResourceOwnerForgetBufferIO(ResourceOwner owner, Buffer buffer)
#define BUF_STATE_GET_REFCOUNT(state)
static BufferDesc * GetLocalBufferDescriptor(uint32 id)
static BufferDesc * GetBufferDescriptor(uint32 id)
BlockNumber BufferGetBlockNumber(Buffer buffer)
PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
bool StartReadBuffers(ReadBuffersOperation *operation, Buffer *buffers, BlockNumber blockNum, int *nblocks, int flags)
void EvictRelUnpinnedBuffers(Relation rel, int32 *buffers_evicted, int32 *buffers_flushed, int32 *buffers_skipped)
BlockNumber ExtendBufferedRelBy(BufferManagerRelation bmr, ForkNumber fork, BufferAccessStrategy strategy, uint32 flags, uint32 extend_by, Buffer *buffers, uint32 *extended_by)
char * DebugPrintBufferRefcount(Buffer buffer)
uint64 LockBufHdr(BufferDesc *desc)
StartBufferIOResult StartSharedBufferIO(BufferDesc *buf, bool forInput, bool wait, PgAioWaitRef *io_wref)
void ReleaseBuffer(Buffer buffer)
void UnlockReleaseBuffer(Buffer buffer)
bool WaitReadBuffers(ReadBuffersOperation *operation)
bool EvictUnpinnedBuffer(Buffer buf, bool *buffer_flushed)
bool ReadRecentBuffer(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber blockNum, Buffer recent_buffer)
void TerminateBufferIO(BufferDesc *buf, bool clear_dirty, uint64 set_flag_bits, bool forget_owner, bool release_aio)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
void FlushOneBuffer(Buffer buffer)
#define READ_BUFFERS_ZERO_ON_ERROR
static Page BufferGetPage(Buffer buffer)
static Block BufferGetBlock(Buffer buffer)
#define READ_BUFFERS_IGNORE_CHECKSUM_FAILURES
static Size BufferGetPageSize(Buffer buffer)
static void LockBuffer(Buffer buffer, BufferLockMode mode)
static bool BufferIsValid(Buffer bufnum)
bool ignore_checksum_failure
void PageSetChecksum(Page page, BlockNumber blkno)
void PageInit(Page page, Size pageSize, Size specialSize)
static bool PageIsEmpty(const PageData *page)
PageHeaderData * PageHeader
#define Assert(condition)
uint16 pg_checksum_page(char *page, BlockNumber blkno)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
static DataChecksumsWorkerOperation operation
int errcode(int sqlerrcode)
int int errhidestmt(bool hide_stmt)
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
int errhidecontext(bool hide_ctx)
#define ereport(elevel,...)
#define PG_GETARG_TEXT_PP(n)
#define PG_GETARG_UINT32(n)
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_BOOL(x)
void InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags)
void InjectionPointLoad(const char *name)
void InjectionPointAttach(const char *name, const char *library, const char *function, const void *private_data, int private_data_size)
void FlushLocalBuffer(BufferDesc *bufHdr, SMgrRelation reln)
StartBufferIOResult StartLocalBufferIO(BufferDesc *bufHdr, bool forInput, bool wait, PgAioWaitRef *io_wref)
void InvalidateLocalBuffer(BufferDesc *bufHdr, bool check_unreferenced)
void TerminateLocalBufferIO(BufferDesc *bufHdr, bool clear_dirty, uint64 set_flag_bits, bool release_aio)
#define AccessExclusiveLock
void pfree(void *pointer)
void * palloc0(Size size)
void * palloc_aligned(Size size, Size alignto, int flags)
bool process_shared_preload_libraries_in_progress
static char buf[DEFAULT_XLOG_SEG_SIZE]
void pgstat_prepare_report_checksum_failure(Oid dboid)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum Int32GetDatum(int32 X)
static Datum UInt32GetDatum(uint32 X)
#define GetPGProcByNumber(n)
Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
ReadStream * read_stream_begin_relation(int flags, BufferAccessStrategy strategy, Relation rel, ForkNumber forknum, ReadStreamBlockNumberCB callback, void *callback_private_data, size_t per_buffer_data_size)
void read_stream_end(ReadStream *stream)
static SMgrRelation RelationGetSmgr(Relation rel)
#define RelationUsesLocalBuffers(relation)
ResourceOwner CurrentResourceOwner
void RegisterShmemCallbacks(const ShmemCallbacks *callbacks)
#define ShmemRequestStruct(...)
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
void smgrstartreadv(PgAioHandle *ioh, SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void **buffers, BlockNumber nblocks)
void smgrreleaseall(void)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
static void smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const void *buffer, bool skipFsync)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
BlockNumber completion_wait_blockno
pid_t completion_wait_pid
bool enabled_completion_wait
uint32 completion_wait_event
Oid short_read_relfilenode
Oid completion_wait_relfilenode
bool short_read_result_set
RelFileLocator rd_locator
RelFileLocatorBackend smgr_rlocator
ShmemRequestCallback request_fn
static void invalidate_one_block(Relation rel, ForkNumber forknum, BlockNumber blkno)
Datum batch_end(PG_FUNCTION_ARGS)
static Buffer create_toy_buffer(Relation rel, BlockNumber blkno)
Datum inj_io_completion_wait(PG_FUNCTION_ARGS)
Datum evict_rel(PG_FUNCTION_ARGS)
Datum buffer_create_toy(PG_FUNCTION_ARGS)
Datum inj_io_reopen_detach(PG_FUNCTION_ARGS)
Datum buffer_call_terminate_io(PG_FUNCTION_ARGS)
static PgAioHandle * last_handle
Datum inj_io_completion_continue(PG_FUNCTION_ARGS)
Datum read_rel_block_ll(PG_FUNCTION_ARGS)
Datum invalidate_rel_block(PG_FUNCTION_ARGS)
static const ShmemCallbacks inj_io_shmem_callbacks
static void test_aio_shmem_attach(void *arg)
Datum grow_rel(PG_FUNCTION_ARGS)
static BlockNumber read_stream_for_blocks_cb(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
static void test_aio_shmem_request(void *arg)
Datum handle_get_release(PG_FUNCTION_ARGS)
Datum read_stream_for_blocks(PG_FUNCTION_ARGS)
Datum buffer_call_start_io(PG_FUNCTION_ARGS)
#define MAX_BUFFERS_TO_EXTEND_BY
Datum inj_io_reopen_attach(PG_FUNCTION_ARGS)
Datum inj_io_short_read_detach(PG_FUNCTION_ARGS)
Datum handle_get(PG_FUNCTION_ARGS)
Datum batch_start(PG_FUNCTION_ARGS)
Datum modify_rel_block(PG_FUNCTION_ARGS)
Datum handle_get_and_error(PG_FUNCTION_ARGS)
Datum inj_io_short_read_attach(PG_FUNCTION_ARGS)
static InjIoErrorState * inj_io_error_state
Datum read_buffers(PG_FUNCTION_ARGS)
Datum handle_release_last(PG_FUNCTION_ARGS)
static void test_aio_shmem_init(void *arg)
Datum handle_get_twice(PG_FUNCTION_ARGS)
Datum errno_from_string(PG_FUNCTION_ARGS)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
struct PgAioTargetData::@131 smgr
char * text_to_cstring(const text *t)
uint32 WaitEventInjectionPointNew(const char *wait_event_name)