scylladb / scylladb/scylla-cdc-java

Always use prepared statements for replication

Open
#13 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

replicator
Dominant language
Java
Stars
32
Forks
23
Avg merge
2d 6h
Merged PRs (30d)
3

Description

https://github.com/scylladb/scylla-cdc-java/blob/24265007f5ab1fdfccefeea4fa6516ffc55d8666/scylla-cdc-replicator/src/main/java/com/scylladb/cdc/replicator/ReplicatorConsumer.java#L71-L83

We can always use prepared statements. Sometimes we may need to use a batch statement, but still.
Example prepared statement that can handle any non-frozen map update:

begin unlogged batch
update ks.t set v = v + :added, v = v - :removed where pk = :pk and ck = :ck;
update ks.t set v = :replaced where pk = :pk and ck = :ck;
apply batch

bind the markers as needed: :added from the CDC v column, :removed from cdc$deleted_elements_v, :replaced from cdc$deleted_v (bind null if it got deleted, leave unset otherwise).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in scylla-cdc-replicator/src/main/java/com/scylladb/cdc/replicator/ReplicatorConsumer.java at lines 71-83, then trace how CDC map updates are currently written. Use the issue's prepared-statement and batch example as the target; done means replication consistently uses prepared statements and binds the added, removed, and replaced values as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.