[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] leventov commented on a change in pull request #6041: Synchronize scheduled poll() calls in SQLMetadataSegmentManager


leventov commented on a change in pull request #6041: Synchronize scheduled poll() calls in SQLMetadataSegmentManager
URL: https://github.com/apache/incubator-druid/pull/6041#discussion_r204922700
 
 

 ##########
 File path: server/src/main/java/io/druid/metadata/SQLMetadataSegmentManager.java
 ##########
 @@ -96,9 +94,18 @@
   private final AtomicReference<ConcurrentHashMap<String, DruidDataSource>> dataSourcesRef;
   private final SQLMetadataConnector connector;
 
-  private volatile ListeningScheduledExecutorService exec = null;
-  private volatile ListenableFuture<?> future = null;
-  private volatile boolean started;
+  /** The number of times this SQLMetadataSegmentManager was started. */
+  private long startCount = 0;
+  /**
+   * Equal to the current {@link #startCount} value, if the SQLMetadataSegmentManager is currently started; -1 if
+   * currently stopped.
+   *
+   * This field is used to implement a simple stamp mechanism instead of just a boolean "started" flag to prevent
+   * the theoretical situation of two tasks scheduled in {@link #start()} calling {@link #poll()} concurrently, if
+   * the sequence of {@link #start()} - {@link #stop()} - {@link #start()} actions occurs quickly.
+   */
 
 Review comment:
   Please cross-reference those things in both classes. Like I changed one class and didn't know that there is another one that demands a similar change. You knew that, but this knowledge should be in the code available to any developer.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@xxxxxxxxxxxxxxxx


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxxx