Neo4j CDC: Native change data capture with Gluesync
Source data from Neo4j
The Neo4j source agent (agent tag neo4j) reads nodes by label and relationships by type. It makes a snapshot on every edition of Neo4j, and on Enterprise Edition and Aura Business Critical or Virtual Dedicated Cloud it captures changes through the native change data capture of the server. It creates no triggers and no objects of its own in the database.
How it works
-
Snapshot. Core Hub records the position of the log at the start of the snapshot, then the agent reads the nodes of a label, or the relationships of a type, and sends them as inserts. See Snapshot;
-
CDC. The agent asks the server for the changes of the entity that came after its last position with
db.cdc.query, filtered on the label or on the relationship type, and sends them in commit order. The changes of one Neo4j transaction reach the target as one transaction. See Change data capture; -
Position. The position of an entity is a change id of the Neo4j transaction log, kept in Core Hub. After a restart of Core Hub or of the agent the reading resumes from it: changes can be read twice after a crash, never lost, and target writes are idempotent. A change committed while a snapshot runs is read by CDC afterwards, because the snapshot starts from the position that was current when it began.
Prerequisites
To have Gluesync working on your Neo4j instance as a source you will need:
-
Neo4j 5.13 to 5.26 LTS, or a 2025.x or 2026.x calendar release.
-
For CDC, Neo4j Enterprise Edition, or Aura Business Critical or Virtual Dedicated Cloud. Community Edition has no change data capture: a Community source runs snapshot-only entities, and an entity that asks for CDC fails its check with a message that names the edition. A server older than 5.13 has no
db.cdc.*procedures and fails the same check; -
txLogEnrichmentset toFULLon the database, see Log full states; -
A user that may call the
db.cdc.*procedures, read the data and list the constraints, see Create the Gluesync user; -
Enough transaction log retention, see Transaction log retention;
-
A key on every entity, see Key constraints;
-
Network access from Core Hub to the Bolt port of the server (default
7687).
The agent checks the CDC requirements, in this order, during its setup, for the entities that are not snapshot-only. It stops at the first one that fails, and the message names the entities that cannot run and the statement that fixes it:
-
the server is Enterprise Edition (or Aura) and at least 5.13;
-
txLogEnrichmentisFULLon the database; -
the user may call
db.cdc.*: the agent runsCALL db.cdc.current().
Log full states: txLogEnrichment
The change data capture of Neo4j reads what the transaction log records. By default the log carries no before and after states, so the database has to be told to record them. Run this on the system database, as an administrator:
ALTER DATABASE neo4j SET OPTION txLogEnrichment "FULL" WAIT;
Use the name of your database instead of neo4j.
The option has three values: OFF (no change data capture), DIFF and FULL. Gluesync needs FULL. With DIFF the log records only the properties that changed in the before and after states of an update, and an agent that builds a full row from them would send NULL for every property that did not change. The agent refuses a database set to DIFF, and says so in its message, so that no wrong value is ever written. FULL records the complete states and makes the transaction log larger.
Create the Gluesync user
The agent reads nodes and relationships, lists the labels, relationship types, properties and constraints of the database, and calls db.cdc.current(), db.cdc.earliest() and db.cdc.query(). As a target it also writes, and creates constraints. This script, run on the system database as an administrator, creates a role and a user that can do all of it, as a source and as a target:
ALTER DATABASE neo4j SET OPTION txLogEnrichment "FULL" WAIT;
CREATE ROLE gluesync IF NOT EXISTS AS COPY OF architect;
GRANT EXECUTE PROCEDURE db.cdc.* ON DBMS TO gluesync;
GRANT EXECUTE BOOSTED PROCEDURE db.cdc.query ON DBMS TO gluesync;
GRANT SHOW CONSTRAINT ON DATABASE neo4j TO gluesync;
GRANT SHOW INDEX ON DATABASE neo4j TO gluesync;
CREATE USER gluesync IF NOT EXISTS SET PASSWORD 'password' CHANGE NOT REQUIRED;
GRANT ROLE gluesync TO gluesync;
The role is a copy of the built-in architect role, which can read and write the graph and manage indexes and constraints, plus:
-
EXECUTE PROCEDURE db.cdc.*andEXECUTE BOOSTED PROCEDURE db.cdc.query, which the CDC read needs.db.cdc.queryis boosted so that it runs with the privilege to read the log of the database. Without these grants the check fails with the twoGRANTstatements in its message; -
SHOW CONSTRAINTandSHOW INDEX, which discovery and the key detection use.
Change the password, and use the name of your database in place of neo4j. A source that only reads needs no write or schema privilege, but the script above is the one the agent is tested with.
Transaction log retention
Change data capture reads the transaction log, and Neo4j prunes the log according to db.tx_log.rotation.retention_policy. An entity that is stopped, paused, or behind because its pipeline or the target is down keeps its position in the log. If the log is pruned past that position, the changes in between no longer exist.
Set the retention to hold more log than the longest downtime of a pipeline you want to survive, in neo4j.conf:
# Keep seven days of transaction log
db.tx_log.rotation.retention_policy=7 days
The value can also be a size, such as 100G size. In a container the same setting is the environment variable NEO4J_db_txlog_rotation_retentionpolicy.
When the position of an entity falls out of the retention, the entity stops with the error CDC Position Lost: The transaction log no longer holds the change position this entity stopped at, because it was pruned. The entity has to be resynchronized. The agent never skips the missing changes. Snapshot the entity again to resume: the snapshot starts a new position. See The position is lost.
A quiet entity does not fall behind: when a read finds nothing new for it, its position moves to the current position of the log, so it stays inside the retention as long as the pipeline runs.
Key constraints
A node or a relationship is identified by its key, never by the elementId. The key comes from the constraints of the label or of the relationship type:
| Entity | Where the key comes from |
|---|---|
Node entity |
A |
Relationship entity: the endpoint nodes |
The key properties of the label of each end node, in the columns |
Relationship entity: the relationship itself |
Optional. A |
A Neo4j Enterprise database that Gluesync writes as a target already has node keys on its node labels and on the end labels of its relationships, so it can be the source of a relationship CDC entity directly. See Constraints. On Community Edition the target creates uniqueness constraints, and the agent never replaces a constraint that exists.
When the labels at the ends of a CDC relationship entity have no node key, the check fails before any data moves, and names the statement. If the label has a uniqueness constraint on the same properties, one you created yourself or one that the target created on Community or because existing nodes lacked a key property, drop it first:
DROP CONSTRAINT <uniqueness_constraint_name>;
CREATE CONSTRAINT gs_nodekey_Person_id IF NOT EXISTS FOR (n:`Person`) REQUIRE n.`id` IS NODE KEY;
The message of the check gives this pair with your label, properties and constraint name. Alternatively mark the relationship entity as snapshot-only.
Setup via Web UI
-
Hostname / IP Address: DNS record or IP Address of the Neo4j server. It can be left empty when you set the connection URI;
-
Port: Optional, defaults to
7687; -
Database name: The database the agent works on. Defaults to
neo4j; -
Username: Username of the Gluesync user;
-
Password: Password belonging to the given username;
-
Connection URI (replaces host, port and TLS): (optional) The complete URI of the server, such as
neo4j+s://<id>.databases.neo4j.iofor Aura. When it is set, it is used as it is and the host, the port, the TLS settings and the URI scheme are ignored. The scheme has to be one ofneo4j,neo4j+s,neo4j+ssc,bolt,bolt+sandbolt+ssc, otherwise the agent refuses it; -
Enable TLS: Optional, defaults to
false. It adds+sto the scheme, so that the connection is encrypted and the certificate of the server is verified; -
Trust server certificate: Optional, defaults to
false. Together with Enable TLS it makes the scheme+ssc: the connection is encrypted but the certificate is not verified, which suits a self-signed certificate; -
CA certificate path (PEM): (optional) A PEM file with the certificate authority that signed the certificate of the server. The file can also be uploaded through Core Hub. When it is set, the connection is encrypted and the certificate is verified against that authority, whatever the Enable TLS and Trust server certificate settings are, and the scheme stays plain;
-
Disable auth: Optional, defaults to
false. Connects without credentials, for a server that has authentication turned off; -
Max connections count: Size of the connection pool of the driver. Defaults to
25.
The URI that the agent builds from the host is <scheme>[+s|+ssc]://<host>:<port>. An IPv6 address is put in square brackets for you.
Custom properties
This can be also set via Rest API by specifying the customHostCredentials param.
-
URI scheme: (optional, defaults to
neo4j)neo4jorbolt.neo4juses routing: it asks the server for the topology of the cluster and sends reads and writes to the right members, which a cluster and Aura need.boltconnects directly to the server you name. Ignored when a connection URI is set; -
Bearer token: (optional) A bearer token, for a server with single sign-on. When it is set, it is used instead of the username and password.
The agent connects with a timeout of 30 seconds, waits up to 60 seconds for a connection of the pool, and retries a read or a write that fails with a transient error, such as a deadlock or a cluster member that changes.
Specific configuration
| Setting | Default | Description |
|---|---|---|
Source change retention in hours ( |
|
The common setting of the Gluesync source agents, described in Source change retention in hours. It does not set how long Neo4j keeps its transaction log, which is configured on the server: see Transaction log retention. |
CDC query fetch size ( |
|
Number of changes that one read of |
Technical fields ( |
none |
Adds |
Entity settings
Each entity has settings of its own. These apply to the source side of an entity, and the ones for the target are in Target entity settings.
| Setting | Default | Description |
|---|---|---|
Entity kind ( |
|
|
Start node label ( |
empty |
Relationship entities only. The label of the start node of the relationship, when the nodes at that end carry several labels or the type connects several pairs of labels. |
End node label ( |
empty |
Relationship entities only. The label of the end node, with the same meaning. |
When the start and end labels are empty, discovery takes them from the schema counts of the database: if the type connects several pairs of labels, it picks the first pair, in label order, whose labels both have a key, otherwise the first pair. Set the labels on the entity when this guess is wrong. When a CDC entity has no labels set, the key properties of an end node are taken from whichever label at that end has them in the log.
Setup via Rest APIs
Here following an example of calling the Core Hub’s Rest API via curl to setup the connection for this Agent.
Connect the agent
curl --location --request PUT 'http://core-hub-ip-address/pipelines/{pipelineId}/agents/{agentId}/config/credentials' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"agentType": "SOURCE",
"agentTag": "neo4j",
"hostCredentials": {
"connectionName": "myAgentNickName",
"host": "neo4j-host-address",
"port": 7687,
"databaseName": "neo4j",
"username": "gluesync",
"password": "your_password",
"maxConnectionsCount": 25,
"enableTls": false
},
"customHostCredentials": {
"uriScheme": "neo4j"
}
}'
For Aura, give the URI of the instance instead of the host and the port:
{
"hostCredentials": {
"connectionName": "myAura",
"connectionString": "neo4j+s://<id>.databases.neo4j.io",
"databaseName": "neo4j",
"username": "neo4j",
"password": "your_password"
}
}
Setup specific configuration
curl --location --request PUT 'http://core-hub-ip-address/pipelines/{pipelineId}/agents/{agentId}/config/specific' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"configuration": {
"cdcQueryFetchSize": 2000,
"sourceChangeRetention": 24
}
}'
Entities: nodes and relationships
When you browse a Neo4j database in Gluesync, the database is the schema and each label and each relationship type is an object: labels are listed as they are (Person), and relationship types as [:KNOWS].
Node entities
The columns of a node entity are the properties of the label, with the type that Neo4j reports for each (see Data types). A property that nodes of the label hold with more than one type is read as STRING. A property is not nullable when the key includes it, or when every combination of labels the nodes have makes it mandatory. A node that carries several labels belongs to the entity of each of them.
Relationship entities
The columns of a relationship entity are:
| Column | Content |
|---|---|
|
Each key property of the start node (a key column), for example |
|
Each key property of the end node (a key column), for example |
|
A property of the relationship. If the relationship has a key, its properties are key columns too. |
The endpoint columns exist only when the label at that end has a key constraint. A relationship entity without them cannot tell which nodes a relationship connects, and fails its check with the statement that creates the constraint.
Snapshot
The agent counts the rows from the count store of Neo4j, which is immediate, then reads:
-
A node entity with a key in pages ordered by the key. Each page is a read of its own, and every page after the first starts after the last key of the page before it, which is a range seek on the index of the constraint with no sort. A composite key is read the same way. The page size is Max fetch items per iteration of the entity. A node that has no value for one of the key properties is not read;
-
A node entity without a key (possible only when the entity is snapshot-only) as one streaming read, with the page size as the fetch size of the driver;
-
A relationship entity as one streaming read of
(start)-[relationship]→(end)with the key properties of the two end nodes. A relationship whose start or end node has no value for a key property is skipped, and the agent logs a warning with the number of relationships it skipped.
After a restart, a snapshot of a node entity with a key continues from the rows that were already migrated. A snapshot of an entity read as one stream reads everything again from the start, which is idempotent on the target.
With logical partitioning the snapshot reads each partition as a range of the partition column. See Logical partitioning for snapshot tasks.
Change data capture
The agent reads db.cdc.query for each CDC entity, filtered on its label or its relationship type, in pages of CDC query fetch size changes, each page in its own read transaction. It reads pages until one comes back short, which means the entity is level with the log, and then waits for the polling interval of the entity (pollingIntervalMilliseconds) before it asks again. Each page first asks the server for the current position of the log, so an entity that has nothing new moves to the end of the log.
The changes of one Neo4j transaction are one transaction for Gluesync, and its position is the last change of the transaction. A transaction larger than the message size limit of the entity (maxTransactionMessageKbSize) is split in several messages.
How a change reaches the target:
| Change in Neo4j | Reaches the target as |
|---|---|
A node or a relationship is created |
An insert with the properties after the change. |
A property of a node or a relationship changes |
An update with the new properties, and the properties before the change as the old values. |
A property is removed |
An update in which the value of the property is |
A node or a relationship is deleted |
A delete, with the key. |
A node gains the label of the entity |
An insert in that entity: the node joins it. |
A node loses the label of the entity |
A delete in that entity: the node leaves it, although it still exists in Neo4j. |
Label changes
A node belongs to the entity of a label when it carries that label before or after the change. If an update of a node adds the label Customer, the Customer entity receives an insert of the node. If it removes the label, the entity receives a delete. The entities of the other labels the node carries receive an ordinary update. The log reports the update of such a node with a single operation, and the agent works out from the labels before and after which of the three cases it is.
A delete reaches a target that replicates the entity as the delete of the row: on a Neo4j target, the node and the relationships attached to it are removed.
A removed property
Neo4j has no NULL property: a property that has no value does not exist. When a change removes a property from a node or a relationship, the agent sends the property with the value NULL, so that the target clears the column. The same holds for a node that never had the property: its column is NULL.
Relationships
A relationship change carries the key properties of its start and end nodes in the start* and end* columns, taken from the node key of the label at each end that the log lists. If the log does not list them, the entity fails with this message: The log does not give the key properties … of the start node of a relationship of entity …: it lists the keys of a node only for a label with a NODE KEY constraint. Create a node key constraint … See Key constraints.
Technical fields
Technical fields are optional columns that describe the change. See Technical fields. Turn them on with the Technical fields setting. On this agent:
| Field | Type | Value |
|---|---|---|
|
|
The change id of the log. Empty for a row of a snapshot. |
|
|
The commit time of the transaction in epoch milliseconds. Empty for a row of a snapshot. |
|
|
|
|
|
The Neo4j user that ran the transaction ( |
Data types
The agent reads the type of each property from the schema procedures of Neo4j (db.schema.nodeTypeProperties() and db.schema.relTypeProperties()). A property that holds more than one type in the database, or a type the agent does not know, is read as STRING.
| Neo4j type | Gluesync type | Notes |
|---|---|---|
|
|
|
|
|
A 64-bit integer. |
|
|
A 64-bit float. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The offset is kept. |
|
|
|
|
|
A value with a named zone ( |
|
|
As ISO 8601 text, in the form Cypher writes it with |
|
|
A map |
Lists of simple values ( |
|
|
|
|
The elements are read as |
|
|
The text form. |
A value that does not match the type of its column, because the property holds mixed types, is converted when it can be and read as NULL when it cannot.
Known behaviour
-
Parallel relationships collapse without a relationship key. A relationship that has no
RELATIONSHIP KEYor uniqueness constraint of its own is identified by its start key, its type and its end key. If two relationships of the same type connect the same two nodes, they are one and the same row for Gluesync: the target holds one of them, and the delete of either reaches the target as the delete of that row. Give the relationships a key property, such as an id, with aRELATIONSHIP KEYconstraint (Enterprise Edition) or a relationship uniqueness constraint; -
neo4j-admin importand database restores do not produce change events. An offline import writes nothing to the transaction log, so the changes it makes never reach the target through CDC, and a database that is restored or recreated has a different identity: the position of the entities is no longer valid and they stop with the errorCDC Position Invalid. Snapshot the entities again after an import or a restore; -
A uniqueness constraint is not a node key. A relationship CDC entity needs node keys on the end labels. On Enterprise Edition the Gluesync target creates node keys, but a uniqueness constraint that already exists, or that the target created as a fallback because existing nodes lacked a key property, stays as it is: replace it as described in Key constraints;
-
Truncate is not replicated. Neo4j has no truncate: a mass removal of nodes arrives as one delete for each node;
-
Query Studio is not available on this agent.
Troubleshooting
Change data capture needs Neo4j Enterprise Edition or Aura
The server is Community Edition. The message names the entities that cannot run. Mark them snapshot-only, or connect an Enterprise server. A server older than 5.13 fails with Change data capture needs Neo4j 5.13 or later: upgrade the server, or mark the entities snapshot-only.
Change data capture needs txLogEnrichment set to FULL
The message gives the state of the database (DIFF or OFF) and the statement to run on the system database. See Log full states. If db.cdc.current() answers that change data capture is disabled, the database is OFF and the message is the same.
The user may not call the change data capture procedures
The user of the agent lacks the grants. The message has the statements to run as an administrator, with the role of the user:
GRANT EXECUTE PROCEDURE db.cdc.* ON DBMS TO <role>;
GRANT EXECUTE BOOSTED PROCEDURE db.cdc.query ON DBMS TO <role>;
Entity keys are missing or wrong
The check lists one line for each entity: a node entity with no key column, a relationship entity whose start or end node has no key, or a node key constraint that is missing on the label of an end node. See Key constraints for how to create the key. The agent does not start the entity until it is fixed.
The position is lost
The entity stops with one of these errors, and the agent never skips the changes:
| Error | Cause |
|---|---|
|
The transaction log was pruned past the position of the entity. Raise |
|
The position does not belong to this database any more: it was restored or recreated, or the stored position is damaged. Snapshot the entity again. |
|
Change data capture was turned off for the database. Turn it on again with |
A resynchronization repeats the snapshot of the entity and starts a new position. Retrying never helps.
Authentication Failed, Token Expired, Neo4j Unavailable
These errors report what the driver answered: a wrong username or password (Authentication Failed), a bearer token that is no longer valid (Token Expired), or a server that cannot be reached or a cluster that cannot be discovered (Neo4j Unavailable). Check the connection URI, the scheme (a cluster and Aura need neo4j, not bolt), the TLS settings and the network path to the Bolt port. Database Not Found means the Database name does not exist or the user cannot see it, and Permission Denied means the user lacks a privilege that the statement in the message needs.