Skip to content

IGNITE-18121 add scale up scheduler - #1508

Merged
sanpwc merged 19 commits into
apache:mainfrom
gridgain:ignite-18121
Jan 26, 2023
Merged

IGNITE-18121 add scale up scheduler#1508
sanpwc merged 19 commits into
apache:mainfrom
gridgain:ignite-18121

Conversation

@alievmirza

Copy link
Copy Markdown
Contributor

private final LogicalTopologyService logicalTopologyService;

private final ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(
8,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use an adjustable value, something like Math.min(Utils.cpus() * 3, 20);


private final ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(
8,
new NamedThreadFactory("dst-zones-scheduler", LOG),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add node name as a prefix, e.g.
NamedThreadFactory.threadPrefix(clusterNetSvc.localConfiguration().getName(),
and extract dst-zones-scheduler to a constant.

.forEach(zoneName -> {
int zoneId = zonesConfiguration.distributionZones().get(zoneName).zoneId().value();

zonesTimers.put(zoneId, new ZoneState());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And don't forget about the default zone, that is not the part of zonesConfiguration.distributionZones() but zonesConfiguration.defaultDistributionZone()

updateMetaStorageOnZoneCreate(ctx.newValue().zoneId(), ctx.storageRevision());
int zoneId = ctx.newValue().zoneId();

ZoneState timers = new ZoneState();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's not only timers.

if (invokeResult) {
lockForZone.lock();
try {
zoneState.nodesToAdd().clear();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that it's valid. Let's imagine that while we are here, trying to add +D, new node was added to zoneState.nodesToAdd(), so it's +D,E. We should just exclude the delta we've successfully added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thats obviously an inattention from my side, algorithm in pseudocode has the logic that you've described

lockForZone.unlock();
}
} else {
return saveDataNodesToMetaStorageOnScaleUp(zoneId, revision);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging is missing.


if (newScaleUp != Integer.MAX_VALUE && oldScaleUp != newScaleUp) {
// It is safe to zonesTimers.get(zoneId) in term of NPE because meta storage notifications are one-threaded
zonesTimers.get(zoneId).rescheduleOngoingScaleUp(newScaleUp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you expect mandatory ongoing timer at this point? Let's say that that timer was already fired, should we consider it as an ongoing one, probably not.

scaleUp.reschedule(delay);
}

private void rescheduleOngoingScaleUp(long delay) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provided logic with (ongoing)rescheduling is error-prone and cumbersome, please rethink and reimplement it. There are 3 possible states for timers:

  1. no scheduled task.
  2. task is scheduled but not fired yet.
  3. task is executing right now.

In case of 1 and 3 we should schedule new task, so it's possible for current timer to execute one right now and have one more in a pending queue.
In case of option 2 we should reschedule the task.
Aforementioned scheduling and rescheduling should be thread-safe.

ops().yield(false)
);

metaStorageManager.invoke(iifScaleUp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in updateMetaStorage... you are ignoring invoke result. It's probably not a good idea ;)

@alievmirza
alievmirza marked this pull request as ready for review January 25, 2023 07:26
@sanpwc
sanpwc merged commit 54da917 into apache:main Jan 26, 2023
@sanpwc
sanpwc deleted the ignite-18121 branch January 26, 2023 12:16
maxzhuravkov pushed a commit to gridgain/apache-ignite-3 that referenced this pull request Mar 18, 2023
maxzhuravkov pushed a commit to gridgain/apache-ignite-3 that referenced this pull request Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants