You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ibessonov (via GitHub)" <gi...@apache.org> on 2024/01/12 08:35:23 UTC
[PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager. [ignite-3]
ibessonov opened a new pull request, #3042:
URL: https://github.com/apache/ignite-3/pull/3042
https://issues.apache.org/jira/browse/IGNITE-21245
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1452068421
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -855,19 +824,19 @@ private void onSafeTimeAdvanced(HybridTimestamp time) {
}
/**
- * Saves processed Meta Storage revision and corresponding entries to the Vault.
+ * Saves processed Meta Storage revision to the {@link #appliedRevision}.
*/
- private CompletableFuture<Void> onRevisionApplied(WatchEvent watchEvent) {
+ private CompletableFuture<Void> onRevisionApplied(long revision) {
Review Comment:
1. This method doesn't need to return a future anymore.
2. All it does is assign a field, I guess we no longer need the busy lock as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450497710
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
Review Comment:
Mirza knows. I'll add a comment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450494157
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
+
/**
* Future which completes when MetaStorage manager finished local recovery. The value of the future is the revision which must be used
* for state recovery by other components.
*/
private final CompletableFuture<Long> recoveryFinishedFuture = new CompletableFuture<>();
+ private final CompletableFuture<Long> recoveryFinishedPublicFuture
+ = recoveryFinishedFuture.whenComplete((revision, e) -> appliedRevision.set(revision));
Review Comment:
Maybe
EDIT you know what, this one looks good. `thenAccept` returns `Void`, I need `Long`, and `thenApply` would look ugly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450458462
##########
modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/WatchProcessorTest.java:
##########
@@ -98,7 +99,7 @@ void testGroupEventNotification() {
WatchEvent event = watchEventCaptor.getValue();
- assertThat(event.entryEvents(), containsInAnyOrder(entryEvent1, entryEvent2));
+ assertThat(event.entryEvents(), is(equalTo(emptyList())));
Review Comment:
I believe there should be a Matcher that looks something like `is(empty())`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1451979676
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
Review Comment:
I think I'll change the fix to avoid confusion. Good explanation would be too long.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450573131
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
+
/**
* Future which completes when MetaStorage manager finished local recovery. The value of the future is the revision which must be used
* for state recovery by other components.
*/
private final CompletableFuture<Long> recoveryFinishedFuture = new CompletableFuture<>();
+ private final CompletableFuture<Long> recoveryFinishedPublicFuture
+ = recoveryFinishedFuture.whenComplete((revision, e) -> appliedRevision.set(revision));
Review Comment:
Can `recoveryFinishedFuture` be completed with a exception? If yes, then the current approach is incorrect (you should verify that `e != null`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450469163
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -449,7 +422,7 @@ public CompletableFuture<Void> deployWatches() {
}
try {
- return recoveryFinishedFuture
+ return recoveryFinishedPublicFuture
.thenAccept(revision -> inBusyLock(busyLock, () -> {
// Meta Storage contract states that all updated entries under a particular revision must be stored in the Vault.
Review Comment:
Also, this comment is obsolete
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450574171
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -105,7 +106,8 @@ public interface EntryReader {
public WatchProcessor(String nodeName, EntryReader entryReader) {
this.entryReader = entryReader;
- this.watchExecutor = Executors.newFixedThreadPool(4, NamedThreadFactory.create(nodeName, "metastorage-watch-executor", LOG));
+ this.watchExecutor = Executors.newSingleThreadScheduledExecutor(
Review Comment:
yeah, the idea was to be able to process multiple watches for a single event simultaneously
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450494157
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
+
/**
* Future which completes when MetaStorage manager finished local recovery. The value of the future is the revision which must be used
* for state recovery by other components.
*/
private final CompletableFuture<Long> recoveryFinishedFuture = new CompletableFuture<>();
+ private final CompletableFuture<Long> recoveryFinishedPublicFuture
+ = recoveryFinishedFuture.whenComplete((revision, e) -> appliedRevision.set(revision));
Review Comment:
Maybe
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450500688
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -284,16 +288,10 @@ private CompletableFuture<List<WatchAndEvents>> collectWatchesAndEvents(List<Ent
}, watchExecutor);
}
- private CompletableFuture<Void> invokeOnRevisionCallback(List<WatchAndEvents> watchAndEventsList, long revision, HybridTimestamp time) {
+ private CompletableFuture<Void> invokeOnRevisionCallback(long revision, HybridTimestamp time) {
try {
- // Only notify about entries that have been accepted by at least one Watch.
- var acceptedEntries = new HashSet<EntryEvent>();
-
- for (WatchAndEvents watchAndEvents : watchAndEventsList) {
- acceptedEntries.addAll(watchAndEvents.events);
- }
-
- var event = new WatchEvent(acceptedEntries, revision, time);
+ // We consciously put empty set here. Revision applied callback doesn't need any data.
Review Comment:
Ok, I'll do it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1451979849
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
+
/**
* Future which completes when MetaStorage manager finished local recovery. The value of the future is the revision which must be used
* for state recovery by other components.
*/
private final CompletableFuture<Long> recoveryFinishedFuture = new CompletableFuture<>();
+ private final CompletableFuture<Long> recoveryFinishedPublicFuture
+ = recoveryFinishedFuture.whenComplete((revision, e) -> appliedRevision.set(revision));
Review Comment:
You are right
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1451980130
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -105,7 +106,8 @@ public interface EntryReader {
public WatchProcessor(String nodeName, EntryReader entryReader) {
this.entryReader = entryReader;
- this.watchExecutor = Executors.newFixedThreadPool(4, NamedThreadFactory.create(nodeName, "metastorage-watch-executor", LOG));
+ this.watchExecutor = Executors.newSingleThreadScheduledExecutor(
Review Comment:
I'll remove this change
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1452073118
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -173,12 +172,20 @@ public CompletableFuture<Void> notifyWatches(List<Entry> updatedEntries, HybridT
CompletableFuture<Void> notifyUpdateRevisionFuture = notifyUpdateRevisionListeners(newRevision);
CompletableFuture<Void> notificationFuture = allOf(notifyWatchesFuture, notifyUpdateRevisionFuture)
- .thenAcceptAsync(
- unused -> invokeOnRevisionCallback(newRevision, time),
+ .thenRunAsync(
+ () -> invokeOnRevisionCallback(newRevision, time),
watchExecutor
);
- notificationFuture.whenComplete((unused, e) -> maybeLogLongProcessing(updatedEntries, startTimeNanos));
+ notificationFuture.whenComplete((unused, e) -> {
+ maybeLogLongProcessing(updatedEntries, startTimeNanos);
+
+ if (e != null) {
+ LOG.error("Error occurred when notifying watches", e);
+
+ throw new CompletionException(e);
Review Comment:
That's right, I feel stupid now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450455297
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
Review Comment:
what was wrong with `volatile long`?
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
+
/**
* Future which completes when MetaStorage manager finished local recovery. The value of the future is the revision which must be used
* for state recovery by other components.
*/
private final CompletableFuture<Long> recoveryFinishedFuture = new CompletableFuture<>();
+ private final CompletableFuture<Long> recoveryFinishedPublicFuture
+ = recoveryFinishedFuture.whenComplete((revision, e) -> appliedRevision.set(revision));
Review Comment:
maybe you intended to use `thenAccept` here?
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -284,16 +288,10 @@ private CompletableFuture<List<WatchAndEvents>> collectWatchesAndEvents(List<Ent
}, watchExecutor);
}
- private CompletableFuture<Void> invokeOnRevisionCallback(List<WatchAndEvents> watchAndEventsList, long revision, HybridTimestamp time) {
+ private CompletableFuture<Void> invokeOnRevisionCallback(long revision, HybridTimestamp time) {
try {
- // Only notify about entries that have been accepted by at least one Watch.
- var acceptedEntries = new HashSet<EntryEvent>();
-
- for (WatchAndEvents watchAndEvents : watchAndEventsList) {
- acceptedEntries.addAll(watchAndEvents.events);
- }
-
- var event = new WatchEvent(acceptedEntries, revision, time);
+ // We consciously put empty set here. Revision applied callback doesn't need any data.
Review Comment:
I would suggest to change the `revisionCallback` interface explicitly only require the revision and the timestamp
##########
modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/WatchProcessorTest.java:
##########
@@ -98,7 +99,7 @@ void testGroupEventNotification() {
WatchEvent event = watchEventCaptor.getValue();
- assertThat(event.entryEvents(), containsInAnyOrder(entryEvent1, entryEvent2));
+ assertThat(event.entryEvents(), is(equalTo(emptyList())));
Review Comment:
I believe there should be Matcher that looks something like `is(empty())`
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -105,7 +106,8 @@ public interface EntryReader {
public WatchProcessor(String nodeName, EntryReader entryReader) {
this.entryReader = entryReader;
- this.watchExecutor = Executors.newFixedThreadPool(4, NamedThreadFactory.create(nodeName, "metastorage-watch-executor", LOG));
+ this.watchExecutor = Executors.newSingleThreadScheduledExecutor(
Review Comment:
What is this change for?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450576952
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -174,7 +173,7 @@ public CompletableFuture<Void> notifyWatches(List<Entry> updatedEntries, HybridT
CompletableFuture<Void> notifyUpdateRevisionFuture = notifyUpdateRevisionListeners(newRevision);
CompletableFuture<Void> notificationFuture = allOf(notifyWatchesFuture, notifyUpdateRevisionFuture)
- .thenComposeAsync(
+ .thenAcceptAsync(
Review Comment:
you can use `thenRunAsync` instead
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -121,12 +105,17 @@ public class MetaStorageManagerImpl implements MetaStorageManager {
/** Prevents double stopping of the component. */
private final AtomicBoolean isStopped = new AtomicBoolean();
+ private final AtomicLong appliedRevision = new AtomicLong(0L);
Review Comment:
> primitive fields won't allow using {@code Mockito#spy(metastorage)}
What do you mean?
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -105,7 +106,8 @@ public interface EntryReader {
public WatchProcessor(String nodeName, EntryReader entryReader) {
this.entryReader = entryReader;
- this.watchExecutor = Executors.newFixedThreadPool(4, NamedThreadFactory.create(nodeName, "metastorage-watch-executor", LOG));
+ this.watchExecutor = Executors.newSingleThreadScheduledExecutor(
Review Comment:
If you are going to leave this change, then the whole class should be refactored a bit
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -288,23 +287,15 @@ private CompletableFuture<List<WatchAndEvents>> collectWatchesAndEvents(List<Ent
}, watchExecutor);
}
- private CompletableFuture<Void> invokeOnRevisionCallback(long revision, HybridTimestamp time) {
+ private void invokeOnRevisionCallback(long revision, HybridTimestamp time) {
try {
- // We consciously put empty set here. Revision applied callback doesn't need any data.
- var event = new WatchEvent(emptySet(), revision, time);
-
revisionCallback.onSafeTimeAdvanced(time);
- return revisionCallback.onRevisionApplied(event)
- .whenComplete((ignored, e) -> {
- if (e != null) {
- LOG.error("Error occurred when notifying watches", e);
- }
- });
+ revisionCallback.onRevisionApplied(revision);
} catch (Throwable e) {
LOG.error("Error occurred when notifying watches", e);
Review Comment:
I think we can remove this catch and use `whenComplete` above to log any errors
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1450500453
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -105,7 +106,8 @@ public interface EntryReader {
public WatchProcessor(String nodeName, EntryReader entryReader) {
this.entryReader = entryReader;
- this.watchExecutor = Executors.newFixedThreadPool(4, NamedThreadFactory.create(nodeName, "metastorage-watch-executor", LOG));
+ this.watchExecutor = Executors.newSingleThreadScheduledExecutor(
Review Comment:
Slipped accidentally. Anyway, only 1 thread is used in reality, others do nothing, you can clearly see that in a profiler
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21245 Remove APPLIED_REV_KEY from metastorage manager [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3042:
URL: https://github.com/apache/ignite-3/pull/3042#discussion_r1452068421
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -855,19 +824,19 @@ private void onSafeTimeAdvanced(HybridTimestamp time) {
}
/**
- * Saves processed Meta Storage revision and corresponding entries to the Vault.
+ * Saves processed Meta Storage revision to the {@link #appliedRevision}.
*/
- private CompletableFuture<Void> onRevisionApplied(WatchEvent watchEvent) {
+ private CompletableFuture<Void> onRevisionApplied(long revision) {
Review Comment:
1. This method doesn't need to return a future anymore.
2. All it does is assigning a field, I guess we no longer need the busy lock as well.
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/WatchProcessor.java:
##########
@@ -173,12 +172,20 @@ public CompletableFuture<Void> notifyWatches(List<Entry> updatedEntries, HybridT
CompletableFuture<Void> notifyUpdateRevisionFuture = notifyUpdateRevisionListeners(newRevision);
CompletableFuture<Void> notificationFuture = allOf(notifyWatchesFuture, notifyUpdateRevisionFuture)
- .thenAcceptAsync(
- unused -> invokeOnRevisionCallback(newRevision, time),
+ .thenRunAsync(
+ () -> invokeOnRevisionCallback(newRevision, time),
watchExecutor
);
- notificationFuture.whenComplete((unused, e) -> maybeLogLongProcessing(updatedEntries, startTimeNanos));
+ notificationFuture.whenComplete((unused, e) -> {
+ maybeLogLongProcessing(updatedEntries, startTimeNanos);
+
+ if (e != null) {
+ LOG.error("Error occurred when notifying watches", e);
+
+ throw new CompletionException(e);
Review Comment:
This `throw` is redundant, it won't be propagated anywhere
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org