Replica registration: editing a host leaves the old replica registered, and deleting one deregisters nothing

Open
#1,800 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend, databases

Research direction

Trace the scaling form and DBSlave class, then inspect the service actions addSlave, removeSlave, and onStarted. Reproduce the registration sequence described in the issue and determine how deletion and existing sessions are handled. Done should mean host edits leave one registration, duplicate registration is prevented, deletion deregisters the replica, and removal has an explicit session outcome.

Written by the indexing model from the issue text.

Description

The scaling form and the DBSlave class are the whole surface for putting a replica into a cluster and taking it out. Four things about it are wrong, and they are filed together because they compound each other and a fix for one changes what the others do.

None of this has been reproduced live — it is read off the behaviour of the service actions and the module that drives them.

1. Editing the host of a replica leaves the old one registered
WHEN CHANGED(host(DBSlave slave)) DO {
    asyncRemoveSlave(slave);
    asyncAddSlave(slave);
}

Both run in their own session and thread, and both read host after the change, so both see the new value. The removal looks for the new host, which is not registered yet, and therefore removes nothing; the addition then registers it.

The server goes on balancing connections onto a host that is no longer in the configuration, and keeps doing so until it is restarted.

The two threads are also unordered with respect to each other, so the addition can as easily run first.

2. Registering a replica that is already registered is not prevented

addSlave does not check whether that host, or that DBSlave, is already in use. Together with 1 this means editing a host A → B → A leaves two registrations of the same database, each a separate server as far as the rest of the system is concerned.

3. Deleting a DBSlave deregisters nothing

The scaling form offers DELETE, and nothing reacts to it — there is no counterpart to onStarted, which registers everything it finds. The replica stays registered with its subscription enabled and goes on receiving connections until the server is restarted, with no row left anywhere to say it should not be.

4. Removing a replica does not wait for the sessions that are on it

removeSlave disables the subscription and closes its own connection immediately. Sessions that already hold a connection to that replica keep it and keep reading from it — from a database that is no longer receiving changes, so what they read is silently out of date rather than an error. Whether a replica may be removed at all while sessions are still on it is a question nothing currently asks.

Repro (1 and 2)
  1. Add a DBSlave on the scaling form and give it a host, wait for it to come up.
  2. Edit its host to a second one, wait.
  3. Edit it back to the first.

Expected: one registration, of the host shown on the form. Actual: three registrations accumulated, two of them for the same database.

Why it matters beyond the leak

Two registrations of one database are not just untidy: they make one database look like two to everything that records which server something is on, and each of them has its own connections. A stale registration also keeps a replica in the load balancing after it has been taken out of the cluster on purpose.

Dominant language
Java
Stars
214
Forks
46
PR merge metrics
No merged PRs in 30d

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

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.

More from lsfusion/platform

All issues in lsfusion/platform

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.