Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions docs/configuring.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuring Spock

Add the following `postgresql.conf` settings on each node in your Spock
Add the following `postgresql.conf` settings on each node in your Spock
replication scenario before creating the Spock extension:

```sql
Expand Down Expand Up @@ -53,12 +53,6 @@ functions adhere to the same rule previously described for
added into the `default` replication set; alternatively, they will be added
to the `default_insert_only` replication set.

### `spock.batch_inserts`

`spock.batch_inserts` tells Spock to use batch insert mechanism if
possible. The batch mechanism uses Postgres internal batch insert mode which
is also used by `COPY` command.

### `spock.channel_counters`

`spock.channel_counters` is a boolean value (the default is `true`) that
Expand Down
4 changes: 0 additions & 4 deletions docs/conflicts.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ that are set in the `postgresql.conf` file or via `ALTER SYSTEM SET`:
setting (see [possible
values](https://www.postgresql.org/docs/15/runtime-config-logging.html#RUNTIME-CONFIG-SEVERITY-LEVELS));
this setting is used primarily to suppress logging of conflicts.
- `spock.batch_inserts` tells Spock to use a batch insert mechanism if
possible; the batch mechanism uses PostgreSQL internal batch insert mode
(also used by the `COPY` command); the default is `on`.


### Handling `INSERT-RowExists` or `INSERT/INSERT` Conflicts

Expand Down
13 changes: 0 additions & 13 deletions docs/managing/batch_inserts.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/managing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
The Spock extension is a powerful addition to any PostgreSQL installation; management features of the Spock extension allow you to seamlessly:

* [replicate partitioned tables](partition_mgmt.md).
* use [batch inserts](batch_inserts.md) to improve performance.
* create logical [row-based data filters](filtering.md).
* set a cluster to [READ-ONLY mode](read_only.md); this restricts non-superusers to read-only operations, while superusers can still perform both read and write operations.
* use a [trigger](repset_trigger.md) to manage replication set membership.
Expand Down
1 change: 0 additions & 1 deletion include/spock.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
extern bool spock_synchronous_commit;
extern char *spock_temp_directory;
extern bool spock_use_spi;
extern bool spock_batch_inserts;
extern char *spock_extra_connection_options;
extern bool spock_ch_stats;
extern bool spock_deny_ddl;
Expand Down
4 changes: 0 additions & 4 deletions include/spock_apply_heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@ extern void spock_apply_heap_update(SpockRelation *rel,
extern void spock_apply_heap_delete(SpockRelation *rel,
SpockTupleData *oldtup);

bool spock_apply_heap_can_mi(SpockRelation *rel);
void spock_apply_heap_mi_add_tuple(SpockRelation *rel,
SpockTupleData *tup);
void spock_apply_heap_mi_finish(SpockRelation *rel);

#endif /* SPOCK_APPLY_HEAP_H */
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ nav:
- Spock's Management Features:
- Managing a Spock Installation: managing/index.md
- Replicating Partitioned Tables: managing/partition_mgmt.md
- Using Batch Inserts: managing/batch_inserts.md
- Filtering Data: managing/filtering.md
- Using Spock in Read-Only Mode: managing/read_only.md
- Using a Trigger to Manage Replication Set Membership: managing/repset_trigger.md
Expand Down
10 changes: 0 additions & 10 deletions src/spock.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ static const struct config_enum_entry readonly_options[] = {

bool spock_synchronous_commit = false;
char *spock_temp_directory = "";
bool spock_batch_inserts = true;
static char *spock_temp_directory_config;
bool spock_ch_stats = true;
static char *spock_country_code;
Expand Down Expand Up @@ -1042,15 +1041,6 @@ _PG_init(void)
0,
NULL, NULL, NULL);

DefineCustomBoolVariable("spock.batch_inserts",
"Batch inserts if possible",
NULL,
&spock_batch_inserts,
true,
PGC_POSTMASTER,
0,
NULL, NULL, NULL);

/* May be set only internally */
DefineCustomBoolVariable("spock.replication_repair_mode",
"Switch to the repair mode",
Expand Down
88 changes: 0 additions & 88 deletions src/spock_apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ static bool apply_replay_spilling = false;
static int apply_replay_spill_count = 0;
static int apply_replay_spill_read = 0;

/* Number of tuples inserted after which we switch to multi-insert. */
#define MIN_MULTI_INSERT_TUPLES 5
static SpockRelation *last_insert_rel = NULL;
static int last_insert_rel_cnt = 0;
static bool use_multi_insert = false;

/*
* A message counter for the xact, for debugging. We don't send
* the remote change LSN with messages, so this aids identification
Expand Down Expand Up @@ -232,8 +226,6 @@ static void maybe_start_skipping_changes(XLogRecPtr finish_lsn);
static void stop_skipping_changes(void);
static void clear_subscription_skip_lsn(XLogRecPtr finish_lsn);

static void multi_insert_finish(void);

static void handle_queued_message(HeapTuple msgtup, bool tx_just_started);
static void handle_startup_param(const char *key, const char *value);
static bool parse_bool_param(const char *key, const char *value);
Expand Down Expand Up @@ -831,8 +823,6 @@ handle_commit(StringInfo s)
*/
clear_subscription_skip_lsn(replorigin_session_origin_lsn);

multi_insert_finish();

spock_apply_heap_commit();


Expand Down Expand Up @@ -1191,8 +1181,6 @@ handle_relation(StringInfo s)
/* Let's wait to avoid concurrent updates to spock cache */
wait_for_previous_transaction();

multi_insert_finish();

(void) spock_read_rel(s);
}

Expand Down Expand Up @@ -1302,54 +1290,6 @@ handle_insert(StringInfo s)
return;
}

/*
* Handle multi_insert capabilities. TODO: Don't do multi- or
* batch-inserts when in use_try_block mode
*/
if (use_multi_insert && MyApplyWorker->use_try_block == false)
{
if (rel != last_insert_rel)
{
multi_insert_finish();
/* Fall through to normal insert. */
}
else
{
spock_apply_heap_mi_add_tuple(rel, &newtup);
last_insert_rel_cnt++;

MemoryContextSwitchTo(oldcontext);
MemoryContextReset(ApplyOperationContext);

/*
* Close replication step to satisfy corresponding 'begin' routine.
* TODO: multi-insert code should be revised one day: it is not
* obvious why we push and pop transactional snapshot on each tuple
* as well as how command counter increment really works here in
* absence of actual INSERT - following update may need to refer
* this tuple and what's then?
*/
end_replication_step();
return;
}
}
else if (spock_batch_inserts &&
RelationGetRelid(rel->rel) != QueueRelid &&
spock_apply_heap_can_mi(rel) &&
MyApplyWorker->use_try_block == false)
{
if (rel != last_insert_rel)
{
last_insert_rel = rel;
last_insert_rel_cnt = 0;
}
else if (last_insert_rel_cnt++ >= MIN_MULTI_INSERT_TUPLES)
{
use_multi_insert = true;
last_insert_rel_cnt = 0;
}
}

/* Normal insert. */

/* TODO: Handle multiple inserts */
Expand Down Expand Up @@ -1439,8 +1379,6 @@ handle_insert(StringInfo s)
LockRelId lockid = rel->rel->rd_lockInfo.lockRelId;
Relation qrel;

multi_insert_finish();

ht = heap_form_tuple(RelationGetDescr(rel->rel),
newtup.values, newtup.nulls);

Expand Down Expand Up @@ -1472,28 +1410,6 @@ handle_insert(StringInfo s)
MemoryContextReset(ApplyOperationContext);
}

static void
multi_insert_finish(void)
{
if (use_multi_insert && last_insert_rel_cnt)
{
const char *old_action = errcallback_arg.action_name;
SpockRelation *old_rel = errcallback_arg.rel;

errcallback_arg.action_name = "multi INSERT";
errcallback_arg.rel = last_insert_rel;

spock_apply_heap_mi_finish(last_insert_rel);
spock_relation_close(last_insert_rel, NoLock);
use_multi_insert = false;
last_insert_rel = NULL;
last_insert_rel_cnt = 0;

errcallback_arg.rel = old_rel;
errcallback_arg.action_name = old_action;
}
}

static void
handle_update(StringInfo s)
{
Expand All @@ -1515,8 +1431,6 @@ handle_update(StringInfo s)
errcallback_arg.action_name = "UPDATE";
xact_action_counter++;

multi_insert_finish();

rel = spock_read_update(s, RowExclusiveLock, &hasoldtup, &oldtup, &newtup);
if (unlikely(rel == NULL))
{
Expand Down Expand Up @@ -1645,8 +1559,6 @@ handle_delete(StringInfo s)

begin_replication_step();

multi_insert_finish();

rel = spock_read_delete(s, RowExclusiveLock, &oldtup);
if (unlikely(rel == NULL))
{
Expand Down
Loading
Loading