Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memgraph replication IN_MEMORY_ANALYTICAL and IN_MEMORY_TRANSACTIONAL switch bug. #2000

Open
antejavor opened this issue May 3, 2024 · 0 comments
Labels
bug bug community community Effort - Unknown Effort - Unknown Frequency - EveryTime Frequency - EveryTime high-availability Reach - Some Reach - Some Severity - S2 Severity - S2

Comments

@antejavor
Copy link
Contributor

antejavor commented May 3, 2024

The things we often recommend for faster import are IN_MEMORY ANALYTICAL, moving to ANALYTICAL for import, and then getting back to TRANSACTIONAL once the import is complete.

Turns out that it affects the replication setup. Below is the script that simulate following:

  1. Setup the replication
  2. Move to ANALYTICAL
  3. Import the data
  4. Move back to TRANSACTIONAL
  5. There is no data in ASYNC and SYNC replicas. (bug)

Full context and discussion: https://discord.com/channels/842007348272169002/1235670651403239425/1235918233429606451

#!/bin/bash

# Start the MAIN instance
docker run -d --name memgraph-main -p 7687:7687 memgraph/memgraph:2.16.0

# Start REPLICA instance 1 (SYNC mode)
docker run -d --name memgraph-replica1 -p 7688:7687 memgraph/memgraph:2.16.0

# Start REPLICA instance 2 (ASYNC mode)
docker run -d --name memgraph-replica2 -p 7689:7687 memgraph/memgraph:2.16.0

# Wait for instances to be ready
echo "Waiting for instances to start up..."
sleep 5

# Get IP addresses of the containers
MAIN_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' memgraph-main)
REPLICA1_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' memgraph-replica1)
REPLICA2_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' memgraph-replica2)

echo "MAIN instance IP: $MAIN_IP"
echo "REPLICA 1 IP: $REPLICA1_IP"
echo "REPLICA 2 IP: $REPLICA2_IP"

# Demote instances to REPLICA role and set replication port
echo "Setting replication roles..."
echo "SET REPLICATION ROLE TO REPLICA WITH PORT 10000;" | docker exec -i memgraph-replica1 mgconsole
echo "SET REPLICATION ROLE TO REPLICA WITH PORT 10000;" | docker exec -i memgraph-replica2 mgconsole

# Register replicas on the MAIN instance
echo "Registering replicas..."
echo "REGISTER REPLICA REP1 SYNC TO \"$REPLICA1_IP\";" | docker exec -i memgraph-main mgconsole
echo "REGISTER REPLICA REP2 ASYNC TO \"$REPLICA2_IP\";" | docker exec -i memgraph-main mgconsole

# Change MAIN instance to IN_MEMORY_ANALYTICAL mode
echo "Changing MAIN instance to IN_MEMORY_ANALYTICAL mode..."
echo "STORAGE MODE IN_MEMORY_ANALYTICAL;" | docker exec -i memgraph-main mgconsole

# Create dummy nodes
echo "Creating dummy nodes..."
echo "CREATE (n:Dummy {id: 1});" | docker exec -i memgraph-main mgconsole
echo "CREATE (n:Dummy {id: 2});" | docker exec -i memgraph-main mgconsole
echo "CREATE (n:Dummy {id: 3});" | docker exec -i memgraph-main mgconsole

# Revert MAIN instance to IN_MEMORY_TRANSACTIONAL mode
echo "Reverting MAIN instance to IN_MEMORY_TRANSACTIONAL mode..."
echo "STORAGE MODE IN_MEMORY_TRANSACTIONAL;" | docker exec -i memgraph-main mgconsole

# Check the status of the registered replicas
echo "Checking registered replicas..."
echo "SHOW REPLICAS;" | docker exec -i memgraph-main mgconsole

echo "Replication setup complete."

# Wait for key press
echo "Press any key to remove instances..."
read -n 1 -s

# Remove instances
echo "Removing instances..."
docker stop memgraph-main
docker rm memgraph-main
docker stop memgraph-replica1
docker rm memgraph-replica1
docker stop memgraph-replica2
docker rm memgraph-replica2

echo "Instances removed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug community community Effort - Unknown Effort - Unknown Frequency - EveryTime Frequency - EveryTime high-availability Reach - Some Reach - Some Severity - S2 Severity - S2
Projects
Development

No branches or pull requests

2 participants