Skip to content

fix parameter timeout checks, rename timeOut to retryTimeout#3172

Closed
EdColeman wants to merge 2 commits intoapache:2.1from
EdColeman:rename_timeout
Closed

fix parameter timeout checks, rename timeOut to retryTimeout#3172
EdColeman wants to merge 2 commits intoapache:2.1from
EdColeman:rename_timeout

Conversation

@EdColeman
Copy link
Contributor

Fixes parameter validation of timeout where the instance variable timeOut was used.
Renames instance variable timeOut to retryTimeout to reflect the intended purpose in the javadoc.

This replaces #3166.

There may be follow-on work to rename the setter / getters for timeout as a follow-on and this PR helps distinguish variations in timeout used in the code, As is this a minimal set of changes for quick review.

this.size = scanner.getBatchSize();
this.timeOut = scanner.getTimeout(MILLISECONDS);
this.retryTimeout = scanner.getTimeout(MILLISECONDS);
this.batchTimeOut = scanner.getTimeout(MILLISECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to also update batchTimeOut to match the case of retryTimeout for uniformity?

Copy link
Contributor

Choose a reason for hiding this comment

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

It appears that the use of timeout between Scanner and BatchScanner is inconsistent. Even though they use the same API method the BatchScanner actually times out. This is an issue we should fix. This PR is step 1 I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - this is step one with the minimum to fix the parameter checks and a little renaming to help with resolving the API conflict.

@ddanielr
Copy link
Contributor

👍 Changing the verbiage to retryTimeout makes its use much clearer!


return new TabletServerBatchReaderIterator(context, tableId, tableName, authorizations, ranges,
numThreads, queryThreadPool, this, timeOut);
numThreads, queryThreadPool, this, retryTimeout);
Copy link
Contributor

Choose a reason for hiding this comment

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

The BatchScanner interface overrides the ScannerBase interface method setTimeout and has a different definition for it. I'm wondering if it would be better to go one step further here and change ScannerBase. For example:

diff --git a/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java b/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
index 5270c45221..a2f9a22c46 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
@@ -208,17 +208,47 @@ public interface ScannerBase extends Iterable<Entry<Key,Value>>, AutoCloseable {
    * @param timeOut the length of the timeout
    * @param timeUnit the units of the timeout
    * @since 1.5.0
+   * @deprecated - replaced by {@link #setRetryTimeout(long, TimeUnit)}
    */
-  void setTimeout(long timeOut, TimeUnit timeUnit);
+  @Deprecated
+  default void setTimeout(long timeOut, TimeUnit timeUnit) {
+    setRetryTimeout(timeOut, timeUnit);
+  }
 
   /**
    * Returns the setting for how long a scanner will automatically retry when a failure occurs.
    *
    * @return the timeout configured for this scanner
    * @since 1.5.0
+   * @deprecated - replaced by {@link #getRetryTimeout(TimeUnit)}
    */
-  long getTimeout(TimeUnit timeUnit);
+  @Deprecated
+  default long getTimeout(TimeUnit timeUnit) {
+    return getRetryTimeout(timeUnit);
+  }
 
+  /**
+   * This setting determines how long a scanner will automatically retry when a failure occurs. By
+   * default, a scanner will retry forever.
+   *
+   * <p>
+   * Setting the timeout to zero (with any time unit) or {@link Long#MAX_VALUE} (with
+   * {@link TimeUnit#MILLISECONDS}) means no timeout.
+   *
+   * @param timeOut the length of the timeout
+   * @param timeUnit the units of the timeout
+   * @since 2.1.1
+   */
+  void setRetryTimeout(long retryTimeout, TimeUnit timeUnit);
+  
+  /**
+   * Returns the setting for how long a scanner will automatically retry when a failure occurs.
+   *
+   * @return the timeout configured for this scanner
+   * @since 2.1.1
+   */
+  long getRetryTimeout(TimeUnit timeUnit);
+  
   /**
    * Closes any underlying connections on the scanner. This may invalidate any iterators derived
    * from the Scanner, causing them to throw exceptions.

You would make the same changes that you have here already, changing the ScannerOptions variable from timeOut to retryTimeout and renaming the ScannerOptions set/getTimeout method. However, TabletServerBatchReader would need it's own setTimeout implementation and timeout variable for its different use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intend to tackle this next. The renaming here should help make sure the next changes are correct and easier to review.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, when you say next, you are adding to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No - my preference is to commit this and then move on to keep the changes isolated - it was tough to track chages when I tried to deprecate setTimeout and use setRetryTimeout with the conflict with batch override

dlmarion
dlmarion previously approved these changes Jan 25, 2023
ctubbsii
ctubbsii previously approved these changes Jan 25, 2023
Copy link
Member

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

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

Might want to check to see if the bug affects 1.10 also, so it can be patched, too.

@EdColeman
Copy link
Contributor Author

This looks like 1.10 may be a better target - but the package names have changed - @ctubbsii do you have a preference for the way the changes are applied? I could try an see if I can use the UI to target 1.10, close this and make the same changes in 1.10 and then merge forward,...?

@ctubbsii ctubbsii linked an issue Jan 25, 2023 that may be closed by this pull request
@EdColeman EdColeman changed the base branch from 2.1 to 1.10 January 26, 2023 17:57
@EdColeman EdColeman dismissed stale reviews from ctubbsii and dlmarion January 26, 2023 17:57

The base branch was changed.

@EdColeman EdColeman changed the base branch from 1.10 to 2.1 January 26, 2023 17:58
@EdColeman
Copy link
Contributor Author

Replaced with #3176 that is based on 1.10.

@EdColeman EdColeman closed this Jan 30, 2023
@EdColeman EdColeman deleted the rename_timeout branch February 8, 2023 20:39
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.

Scanner.setTimeout() does not work

4 participants