You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@amoro.apache.org by "wardlican (via GitHub)" <gi...@apache.org> on 2025/11/17 08:02:43 UTC
[PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
wardlican opened a new pull request, #3950:
URL: https://github.com/apache/amoro/pull/3950
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://amoro.apache.org/how-to-contribute/
2. If the PR is related to an issue in https://github.com/apache/amoro/issues, add '[AMORO-XXXX]' in your PR title, e.g., '[AMORO-XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][AMORO-XXXX] Your PR title ...'.
-->
## Why are the changes needed?
In master-slave mode, the optimizer needs to support pulling optimization tasks from each ams node for processing.
Close #xxx.
## Brief change log
1. In master-slave mode, the optimizer can pull tasks from each currently active AMS.
2. In master-slave mode, the AMS automatically detects the addition and timeout of the optimizer from the database.
-
## How was this patch tested?
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [ ] Run test locally before making a pull request
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007240980
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -86,25 +157,79 @@ private boolean shouldReturnNull(Throwable t) {
return false;
}
- protected <T> T callAuthenticatedAms(AmsAuthenticatedCallOperation<T> operation)
+ /**
+ * Call authenticated AMS with a specific AMS URL.
+ *
+ * @param amsUrl The AMS node URL to call
+ * @param operation The operation to execute
+ * @return The result of the operation
+ * @throws TException If the operation fails
+ */
+ protected <T> T callAuthenticatedAms(String amsUrl, AmsAuthenticatedCallOperation<T> operation)
throws TException {
+ // Maximum retry time window for auth errors in master-slave mode (30 seconds)
+ long maxAuthRetryTimeWindow = TimeUnit.SECONDS.toMillis(90);
Review Comment:
The purpose of this window is to allow the optimizer to wait for the slave AMS node to complete its automatic registration (PLUGIN_RETRY_AUTH_ERROR_CODE) once a connection has been established. The process by which a slave node discovers its assigned buckets and completes registration is as follows:
- ZK Mode: Triggered by a ZK watch; typically completes within seconds.
- DB Mode: Discovered via polling based on the `node_heartbeat_ts` timestamp, with a polling interval of approximately 10–30 seconds.
Conclusion: A duration of 30 seconds is more appropriate.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3009157709
##########
amoro-ams/src/main/resources/mysql/upgrade.sql:
##########
@@ -164,12 +164,13 @@ ADD COLUMN `process_parameters` mediumtext COMMENT 'Table process parameters';
-- ADD table bucket_assignments for storing assigned info
CREATE TABLE IF NOT EXISTS bucket_assignments (
- cluster_name VARCHAR(64) NOT NULL COMMENT 'AMS cluster name',
+ cluster_name VARCHAR(64) NOT NULL COMMENT 'AMS cluster name',
node_key VARCHAR(256) NOT NULL COMMENT 'Node key (host:thriftBindPort)',
server_info_json TEXT NULL COMMENT 'JSON encoded AmsServerInfo',
assignments_json TEXT NULL COMMENT 'JSON array of bucket IDs',
last_update_time BIGINT NOT NULL DEFAULT 0 COMMENT 'Last update timestamp (ms since epoch)',
+ node_heartbeat_ts BIGINT NOT NULL DEFAULT 0 COMMENT 'Per-node heartbeat timestamp updated only by the owning node (ms since epoch)',
Review Comment:
Okay, I will separate 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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "xxubai (via GitHub)" <gi...@apache.org>.
xxubai commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007968648
##########
amoro-ams/src/test/java/org/apache/amoro/server/TestOptimizerGroupKeeper.java:
##########
@@ -80,7 +81,7 @@ public static Object[] parameters() {
@Before
public void prepare() throws Exception {
optimizerRegistrar = registerInfo -> optimizingService().authenticate(registerInfo);
- setupMockContainer();
+ setupMockContainer(() -> currentGroupName);
Review Comment:
Could you open a separate PR to fix this unit test?
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "xxubai (via GitHub)" <gi...@apache.org>.
xxubai commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3008182107
##########
amoro-ams/src/test/java/org/apache/amoro/server/TestOptimizerGroupKeeper.java:
##########
@@ -80,7 +81,7 @@ public static Object[] parameters() {
@Before
public void prepare() throws Exception {
optimizerRegistrar = registerInfo -> optimizingService().authenticate(registerInfo);
- setupMockContainer();
+ setupMockContainer(() -> currentGroupName);
Review Comment:
Or you can wait until the fix PR is merged and then rebase.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #3950: Modify the optimizer to support obtaining tasks from each AMS node for processing.
URL: https://github.com/apache/amoro/pull/3950
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AMORO-3928] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "czy006 (via GitHub)" <gi...@apache.org>.
czy006 commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-4174392314
LGTM.After the overall functionality is completed, we need to conduct a comprehensive test
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "czy006 (via GitHub)" <gi...@apache.org>.
czy006 commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3692538050
After resolving any conflicts in the code, I will initiate the first review on my end cc @wardlican
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007259009
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerToucher.java:
##########
@@ -32,7 +32,7 @@
public class OptimizerToucher extends AbstractOptimizerOperator {
private static final Logger LOG = LoggerFactory.getLogger(OptimizerToucher.class);
- private TokenChangeListener tokenChangeListener;
+ private transient TokenChangeListener tokenChangeListener;
Review Comment:
The reason is that `AbstractOptimizerOperator` implements `Serializable`; consequently, `OptimizerToucher`—being a subclass—is also a serializable object. `TokenChangeListener` is an interface that is typically implemented by callers (such as the Flink or Spark optimizer) using lambda expressions or anonymous classes. If the `transient` keyword is omitted, a `NotSerializableException` will be thrown whenever `OptimizerToucher` is serialized (for instance, when Flink or Spark distributes tasks to executors).
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "xxubai (via GitHub)" <gi...@apache.org>.
xxubai commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r2995426257
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -86,25 +157,79 @@ private boolean shouldReturnNull(Throwable t) {
return false;
}
- protected <T> T callAuthenticatedAms(AmsAuthenticatedCallOperation<T> operation)
+ /**
+ * Call authenticated AMS with a specific AMS URL.
+ *
+ * @param amsUrl The AMS node URL to call
+ * @param operation The operation to execute
+ * @return The result of the operation
+ * @throws TException If the operation fails
+ */
+ protected <T> T callAuthenticatedAms(String amsUrl, AmsAuthenticatedCallOperation<T> operation)
throws TException {
+ // Maximum retry time window for auth errors in master-slave mode (30 seconds)
+ long maxAuthRetryTimeWindow = TimeUnit.SECONDS.toMillis(90);
+ Long firstAuthErrorTime = null;
+
while (isStarted()) {
if (tokenIsReady()) {
String token = getToken();
try {
- return operation.call(OptimizingClientPools.getClient(config.getAmsUrl()), token);
+ // Reset retry time on successful call
+ firstAuthErrorTime = null;
+ return operation.call(OptimizingClientPools.getClient(amsUrl), token);
Review Comment:
`firstAuthErrorTime` always be null in this pleace. I think it should reset after calling.
```suggestion
T res = operation.call(OptimizingClientPools.getClient(amsUrl), token);
// Reset retry time on successful call
firstAuthErrorTime = null;
return res;
```
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerExecutor.java:
##########
@@ -49,6 +53,112 @@ public OptimizerExecutor(OptimizerConfig config, int threadId) {
}
public void start() {
+ // Check if in master-slave mode (node manager initialised for either ZK or DB HA)
+ boolean isMasterSlaveMode = getConfig().isMasterSlaveMode() && hasAmsNodeManager();
+
+ if (isMasterSlaveMode) {
+ // Master-slave mode: get node list and process tasks from each node
+ startMasterSlaveMode();
Review Comment:
If I understand correctly, single-node mode is a special case of multi-node mode. Could we refactor startMasterSlaveMode and startSingleNodeMode into a more generic implementation that supports multiple modes?
##########
amoro-common/src/main/java/org/apache/amoro/OptimizerProperties.java:
##########
@@ -48,4 +48,5 @@ public class OptimizerProperties {
public static final String OPTIMIZER_CACHE_MAX_TOTAL_SIZE_DEFAULT = "128mb";
public static final String OPTIMIZER_CACHE_TIMEOUT = "cache-timeout";
public static final String OPTIMIZER_CACHE_TIMEOUT_DEFAULT = "10min";
+ public static final String OPTIMIZER_MASTER_SLAVE_MODE = "master-slave-mode";
Review Comment:
It is a boolean property. Can you rename it to `OPTIMIZER_MASTER_SLAVE_MODE_ENABLED` or just remove it.
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -86,25 +157,79 @@ private boolean shouldReturnNull(Throwable t) {
return false;
}
- protected <T> T callAuthenticatedAms(AmsAuthenticatedCallOperation<T> operation)
+ /**
+ * Call authenticated AMS with a specific AMS URL.
+ *
+ * @param amsUrl The AMS node URL to call
+ * @param operation The operation to execute
+ * @return The result of the operation
+ * @throws TException If the operation fails
+ */
+ protected <T> T callAuthenticatedAms(String amsUrl, AmsAuthenticatedCallOperation<T> operation)
throws TException {
+ // Maximum retry time window for auth errors in master-slave mode (30 seconds)
+ long maxAuthRetryTimeWindow = TimeUnit.SECONDS.toMillis(90);
Review Comment:
30 seconds or 90 seconds?
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerToucher.java:
##########
@@ -32,7 +32,7 @@
public class OptimizerToucher extends AbstractOptimizerOperator {
private static final Logger LOG = LoggerFactory.getLogger(OptimizerToucher.class);
- private TokenChangeListener tokenChangeListener;
+ private transient TokenChangeListener tokenChangeListener;
Review Comment:
Why set it to `transient`
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerExecutor.java:
##########
@@ -49,6 +53,112 @@ public OptimizerExecutor(OptimizerConfig config, int threadId) {
}
public void start() {
+ // Check if in master-slave mode (node manager initialised for either ZK or DB HA)
+ boolean isMasterSlaveMode = getConfig().isMasterSlaveMode() && hasAmsNodeManager();
+
+ if (isMasterSlaveMode) {
+ // Master-slave mode: get node list and process tasks from each node
+ startMasterSlaveMode();
+ } else {
+ // Active-standby mode: use original logic
+ startSingleNodeMode();
+ }
+ }
+
+ /** Start in master-slave mode: get node list and process tasks from each AMS node. */
+ private void startMasterSlaveMode() {
+ // Dynamic polling interval control
+ long basePollInterval = TimeUnit.SECONDS.toMillis(1); // Base interval: 1 second
+ long maxPollInterval = TimeUnit.SECONDS.toMillis(30); // Max interval: 10 seconds
Review Comment:
Max interval: 10 or 30 seconds
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerExecutor.java:
##########
@@ -49,6 +53,112 @@ public OptimizerExecutor(OptimizerConfig config, int threadId) {
}
public void start() {
+ // Check if in master-slave mode (node manager initialised for either ZK or DB HA)
+ boolean isMasterSlaveMode = getConfig().isMasterSlaveMode() && hasAmsNodeManager();
Review Comment:
If the existence of `hasAmsNodeManager` already determines whether we use the multi-node task fetching strategy, do we still need the `master-slave-mode` configuration?
If do not need, I recommand to remove this config property.
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -41,21 +43,90 @@ public class AbstractOptimizerOperator implements Serializable {
private final OptimizerConfig config;
private final AtomicReference<String> token = new AtomicReference<>();
private volatile boolean stopped = false;
+ private transient volatile AmsNodeManager amsNodeManager;
+ private transient volatile ThriftAmsNodeManager thriftAmsNodeManager;
public AbstractOptimizerOperator(OptimizerConfig config) {
Preconditions.checkNotNull(config);
this.config = config;
+ if (config.isMasterSlaveMode()) {
+ String amsUrl = config.getAmsUrl();
+ if (amsUrl.startsWith("zookeeper://")) {
+ // ZK mode: discover nodes from ZooKeeper ephemeral nodes
+ try {
+ this.amsNodeManager = new AmsNodeManager(amsUrl);
+ LOG.info("Initialized ZK AmsNodeManager for master-slave mode");
+ } catch (Exception e) {
+ LOG.warn("Failed to initialize AmsNodeManager, will use single AMS URL", e);
+ }
+ } else {
+ // DB mode (or direct thrift://): discover nodes via getOptimizingNodeUrls() Thrift RPC
+ try {
+ this.thriftAmsNodeManager = new ThriftAmsNodeManager(amsUrl);
+ LOG.info("Initialized ThriftAmsNodeManager for master-slave mode (DB HA)");
+ } catch (Exception e) {
+ LOG.warn("Failed to initialize ThriftAmsNodeManager, will use single AMS URL", e);
+ }
+ }
+ }
+ }
+
+ /** Get the AmsNodeManager instance if available (ZK mode). */
+ protected AmsNodeManager getAmsNodeManager() {
+ return amsNodeManager;
+ }
+
+ /** Get the ThriftAmsNodeManager instance if available (DB mode). */
+ protected ThriftAmsNodeManager getThriftAmsNodeManager() {
+ return thriftAmsNodeManager;
+ }
+
+ /**
+ * Returns true if any node manager (ZK or Thrift) is active. Used by OptimizerExecutor to decide
+ * whether to use master-slave polling logic.
+ */
+ protected boolean hasAmsNodeManager() {
+ return amsNodeManager != null || thriftAmsNodeManager != null;
+ }
+
+ /**
+ * Get all AMS URLs from the active node manager. Falls back to the single configured URL when no
+ * node manager is available or the node list is empty.
+ */
+ protected List<String> getAmsNodeUrls() {
+ if (amsNodeManager != null) {
+ List<String> urls = amsNodeManager.getAllAmsUrls();
+ if (!urls.isEmpty()) {
+ return urls;
+ }
+ }
+ if (thriftAmsNodeManager != null) {
+ return thriftAmsNodeManager.getAllAmsUrls();
+ }
+ return Collections.singletonList(getConfig().getAmsUrl());
}
protected <T> T callAms(AmsCallOperation<T> operation) throws TException {
+ return callAms(getConfig().getAmsUrl(), operation);
Review Comment:
I have one concern:
This breaks authentication in multi-node mode: the optimizer still registers and heartbeats against only one AMS endpoint, but OptimizerExecutor now polls/acks/completes against every AMS node.
The flow becomes:
- the optimizer authenticates with AMS-A and gets a token
- it uses that same token to call AMS-B
- AMS-B does not know this token because it validates against its own local authOptimizers
- the request fails with `PluginRetryAuthException` and keep retry
Unless we add per-node registration/token propagation, cross-node task fetching will not work reliably.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007274792
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerExecutor.java:
##########
@@ -49,6 +53,112 @@ public OptimizerExecutor(OptimizerConfig config, int threadId) {
}
public void start() {
+ // Check if in master-slave mode (node manager initialised for either ZK or DB HA)
+ boolean isMasterSlaveMode = getConfig().isMasterSlaveMode() && hasAmsNodeManager();
Review Comment:
After switching to the unified pattern shown above, this issue no longer occurs.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007320307
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -41,21 +43,90 @@ public class AbstractOptimizerOperator implements Serializable {
private final OptimizerConfig config;
private final AtomicReference<String> token = new AtomicReference<>();
private volatile boolean stopped = false;
+ private transient volatile AmsNodeManager amsNodeManager;
+ private transient volatile ThriftAmsNodeManager thriftAmsNodeManager;
public AbstractOptimizerOperator(OptimizerConfig config) {
Preconditions.checkNotNull(config);
this.config = config;
+ if (config.isMasterSlaveMode()) {
+ String amsUrl = config.getAmsUrl();
+ if (amsUrl.startsWith("zookeeper://")) {
+ // ZK mode: discover nodes from ZooKeeper ephemeral nodes
+ try {
+ this.amsNodeManager = new AmsNodeManager(amsUrl);
+ LOG.info("Initialized ZK AmsNodeManager for master-slave mode");
+ } catch (Exception e) {
+ LOG.warn("Failed to initialize AmsNodeManager, will use single AMS URL", e);
+ }
+ } else {
+ // DB mode (or direct thrift://): discover nodes via getOptimizingNodeUrls() Thrift RPC
+ try {
+ this.thriftAmsNodeManager = new ThriftAmsNodeManager(amsUrl);
+ LOG.info("Initialized ThriftAmsNodeManager for master-slave mode (DB HA)");
+ } catch (Exception e) {
+ LOG.warn("Failed to initialize ThriftAmsNodeManager, will use single AMS URL", e);
+ }
+ }
+ }
+ }
+
+ /** Get the AmsNodeManager instance if available (ZK mode). */
+ protected AmsNodeManager getAmsNodeManager() {
+ return amsNodeManager;
+ }
+
+ /** Get the ThriftAmsNodeManager instance if available (DB mode). */
+ protected ThriftAmsNodeManager getThriftAmsNodeManager() {
+ return thriftAmsNodeManager;
+ }
+
+ /**
+ * Returns true if any node manager (ZK or Thrift) is active. Used by OptimizerExecutor to decide
+ * whether to use master-slave polling logic.
+ */
+ protected boolean hasAmsNodeManager() {
+ return amsNodeManager != null || thriftAmsNodeManager != null;
+ }
+
+ /**
+ * Get all AMS URLs from the active node manager. Falls back to the single configured URL when no
+ * node manager is available or the node list is empty.
+ */
+ protected List<String> getAmsNodeUrls() {
+ if (amsNodeManager != null) {
+ List<String> urls = amsNodeManager.getAllAmsUrls();
+ if (!urls.isEmpty()) {
+ return urls;
+ }
+ }
+ if (thriftAmsNodeManager != null) {
+ return thriftAmsNodeManager.getAllAmsUrls();
+ }
+ return Collections.singletonList(getConfig().getAmsUrl());
}
protected <T> T callAms(AmsCallOperation<T> operation) throws TException {
+ return callAms(getConfig().getAmsUrl(), operation);
Review Comment:
Under the current design, the optimizer registers solely with the primary node to obtain a token. Each AMS node then automatically synchronizes the list of currently registered optimizers from the database; once this synchronization is complete, the optimizer is able to pull tasks from any of the other AMS nodes. Shifting to a model where each AMS node independently maintains tokens would introduce excessive complexity.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3008398885
##########
amoro-ams/src/test/java/org/apache/amoro/server/TestOptimizerGroupKeeper.java:
##########
@@ -80,7 +81,7 @@ public static Object[] parameters() {
@Before
public void prepare() throws Exception {
optimizerRegistrar = registerInfo -> optimizingService().authenticate(registerInfo);
- setupMockContainer();
+ setupMockContainer(() -> currentGroupName);
Review Comment:
Okay, I will use the rebase approach.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3850356401
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3695535680
> After resolving any conflicts in the code, I will initiate the first review on my end cc @wardlican
Okay, I will resolve the conflicts based on the latest master branch and add support for a database-based storage solution for bucket allocation information, based on the latest HA (High Availability) scheme.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3696253222
## [Codecov](https://app.codecov.io/gh/apache/amoro/pull/3950?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `31.68483%` with `815 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 30.03%. Comparing base ([`cbdc517`](https://app.codecov.io/gh/apache/amoro/commit/cbdc5176b760b2ab46daa5051f29b72f1fee7175?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`b6be852`](https://app.codecov.io/gh/apache/amoro/commit/b6be852c301e2a5b879818145383c2233cdfc2d3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 23 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/amoro/pull/3950?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...apache/amoro/server/table/DefaultTableService.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-ams%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fserver%2Ftable%2FDefaultTableService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tYW1zL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9zZXJ2ZXIvdGFibGUvRGVmYXVsdFRhYmxlU2VydmljZS5qYXZh) | 8.21% | [181 Missing and 9 partials :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ache/amoro/optimizer/common/OptimizerExecutor.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-optimizer%2Famoro-optimizer-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Foptimizer%2Fcommon%2FOptimizerExecutor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tb3B0aW1pemVyL2Ftb3JvLW9wdGltaXplci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Ftb3JvL29wdGltaXplci9jb21tb24vT3B0aW1pemVyRXhlY3V0b3IuamF2YQ==) | 2.04% | [94 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...apache/amoro/server/DatabaseBucketAssignStore.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-ams%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fserver%2FDatabaseBucketAssignStore.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tYW1zL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9zZXJ2ZXIvRGF0YWJhc2VCdWNrZXRBc3NpZ25TdG9yZS5qYXZh) | 0.00% | [80 Missing :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../apache/amoro/server/DefaultOptimizingService.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-ams%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fserver%2FDefaultOptimizingService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tYW1zL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9zZXJ2ZXIvRGVmYXVsdE9wdGltaXppbmdTZXJ2aWNlLmphdmE=) | 19.78% | [71 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ain/java/org/apache/amoro/client/AmsThriftUrl.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fclient%2FAmsThriftUrl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9jbGllbnQvQW1zVGhyaWZ0VXJsLmphdmE=) | 0.00% | [60 Missing :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...java/org/apache/amoro/server/AmsAssignService.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-ams%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fserver%2FAmsAssignService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tYW1zL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9zZXJ2ZXIvQW1zQXNzaWduU2VydmljZS5qYXZh) | 75.84% | [40 Missing and 17 partials :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../apache/amoro/optimizer/common/AmsNodeManager.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-optimizer%2Famoro-optimizer-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Foptimizer%2Fcommon%2FAmsNodeManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tb3B0aW1pemVyL2Ftb3JvLW9wdGltaXplci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Ftb3JvL29wdGltaXplci9jb21tb24vQW1zTm9kZU1hbmFnZXIuamF2YQ==) | 0.00% | [47 Missing :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...o/server/ha/DataBaseHighAvailabilityContainer.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-ams%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fserver%2Fha%2FDataBaseHighAvailabilityContainer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tYW1zL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9zZXJ2ZXIvaGEvRGF0YUJhc2VIaWdoQXZhaWxhYmlsaXR5Q29udGFpbmVyLmphdmE=) | 0.00% | [45 Missing :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...a/org/apache/amoro/server/ZkBucketAssignStore.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-ams%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fserver%2FZkBucketAssignStore.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tYW1zL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9zZXJ2ZXIvWmtCdWNrZXRBc3NpZ25TdG9yZS5qYXZh) | 66.66% | [34 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...org/apache/amoro/server/AmoroServiceContainer.java](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&filepath=amoro-ams%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Famoro%2Fserver%2FAmoroServiceContainer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YW1vcm8tYW1zL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9hbW9yby9zZXJ2ZXIvQW1vcm9TZXJ2aWNlQ29udGFpbmVyLmphdmE=) | 7.89% | [33 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| ... and [9 more](https://app.codecov.io/gh/apache/amoro/pull/3950?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #3950 +/- ##
============================================
+ Coverage 22.12% 30.03% +7.90%
- Complexity 2461 4155 +1694
============================================
Files 445 652 +207
Lines 40897 53031 +12134
Branches 5767 6763 +996
============================================
+ Hits 9050 15929 +6879
- Misses 31089 35927 +4838
- Partials 758 1175 +417
```
| [Flag](https://app.codecov.io/gh/apache/amoro/pull/3950/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [core](https://app.codecov.io/gh/apache/amoro/pull/3950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `30.03% <31.68%> (?)` | |
| [trino](https://app.codecov.io/gh/apache/amoro/pull/3950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/amoro/pull/3950?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3013721725
##########
amoro-common/src/main/java/org/apache/amoro/OptimizerProperties.java:
##########
@@ -48,5 +48,5 @@ public class OptimizerProperties {
public static final String OPTIMIZER_CACHE_MAX_TOTAL_SIZE_DEFAULT = "128mb";
public static final String OPTIMIZER_CACHE_TIMEOUT = "cache-timeout";
public static final String OPTIMIZER_CACHE_TIMEOUT_DEFAULT = "10min";
- public static final String OPTIMIZER_MASTER_SLAVE_MODE = "master-slave-mode";
+ public static final String OPTIMIZER_MASTER_SLAVE_MODE_ENABLED = "master-slave-mode";
Review Comment:
okay,i will fix 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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3008398885
##########
amoro-ams/src/test/java/org/apache/amoro/server/TestOptimizerGroupKeeper.java:
##########
@@ -80,7 +81,7 @@ public static Object[] parameters() {
@Before
public void prepare() throws Exception {
optimizerRegistrar = registerInfo -> optimizingService().authenticate(registerInfo);
- setupMockContainer();
+ setupMockContainer(() -> currentGroupName);
Review Comment:
Okay, I will reverted it and fix it in another PR.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "czy006 (via GitHub)" <gi...@apache.org>.
czy006 commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3008863780
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -86,25 +157,77 @@ private boolean shouldReturnNull(Throwable t) {
return false;
}
- protected <T> T callAuthenticatedAms(AmsAuthenticatedCallOperation<T> operation)
+ /**
+ * Call authenticated AMS with a specific AMS URL.
+ *
+ * @param amsUrl The AMS node URL to call
+ * @param operation The operation to execute
+ * @return The result of the operation
+ * @throws TException If the operation fails
+ */
+ protected <T> T callAuthenticatedAms(String amsUrl, AmsAuthenticatedCallOperation<T> operation)
throws TException {
+ // Maximum retry time window for auth errors in master-slave mode (30 seconds)
+ long maxAuthRetryTimeWindow = TimeUnit.SECONDS.toMillis(30);
+ Long firstAuthErrorTime = null;
+
while (isStarted()) {
if (tokenIsReady()) {
Review Comment:
I suspect that if a node keeps failing, it will get stuck on that node for a long time, and subsequent nodes will stop polling.We can Enforce per-node retry budget (attempt count or retry window), then fail fast to continue with next node.
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -86,25 +157,79 @@ private boolean shouldReturnNull(Throwable t) {
return false;
}
- protected <T> T callAuthenticatedAms(AmsAuthenticatedCallOperation<T> operation)
+ /**
+ * Call authenticated AMS with a specific AMS URL.
+ *
+ * @param amsUrl The AMS node URL to call
+ * @param operation The operation to execute
+ * @return The result of the operation
+ * @throws TException If the operation fails
+ */
+ protected <T> T callAuthenticatedAms(String amsUrl, AmsAuthenticatedCallOperation<T> operation)
throws TException {
+ // Maximum retry time window for auth errors in master-slave mode (30 seconds)
+ long maxAuthRetryTimeWindow = TimeUnit.SECONDS.toMillis(90);
+ Long firstAuthErrorTime = null;
+
while (isStarted()) {
if (tokenIsReady()) {
String token = getToken();
try {
- return operation.call(OptimizingClientPools.getClient(config.getAmsUrl()), token);
+ // Reset retry time on successful call
+ firstAuthErrorTime = null;
+ return operation.call(OptimizingClientPools.getClient(amsUrl), token);
Review Comment:
elapsedTime every time is near 0, maxAuthRetryTimeWindow is not to do it
##########
amoro-ams/src/main/java/org/apache/amoro/server/DBBucketAssignStore.java:
##########
@@ -180,6 +180,25 @@ public void updateLastUpdateTime(AmsServerInfo nodeInfo) throws BucketAssignStor
}
}
+ @Override
+ public List<AmsServerInfo> getAliveNodes() throws BucketAssignStoreException {
+ try {
+ List<BucketAssignmentMeta> rows =
+ getAs(BucketAssignMapper.class, mapper -> mapper.selectAllByCluster(clusterName));
Review Comment:
`getAliveNodes()` directly iterates through all `bucket_assignments` and returns them (only verifying the port), without filtering by `node_heartbeat_ts`. Could this result in the optimizer's node list containing offline nodes, triggering additional retries?
##########
amoro-ams/src/main/resources/mysql/upgrade.sql:
##########
@@ -164,12 +164,13 @@ ADD COLUMN `process_parameters` mediumtext COMMENT 'Table process parameters';
-- ADD table bucket_assignments for storing assigned info
CREATE TABLE IF NOT EXISTS bucket_assignments (
- cluster_name VARCHAR(64) NOT NULL COMMENT 'AMS cluster name',
+ cluster_name VARCHAR(64) NOT NULL COMMENT 'AMS cluster name',
node_key VARCHAR(256) NOT NULL COMMENT 'Node key (host:thriftBindPort)',
server_info_json TEXT NULL COMMENT 'JSON encoded AmsServerInfo',
assignments_json TEXT NULL COMMENT 'JSON array of bucket IDs',
last_update_time BIGINT NOT NULL DEFAULT 0 COMMENT 'Last update timestamp (ms since epoch)',
+ node_heartbeat_ts BIGINT NOT NULL DEFAULT 0 COMMENT 'Per-node heartbeat timestamp updated only by the owning node (ms since epoch)',
Review Comment:
`ALTER TABLE ... ADD COLUMN (node_heartbeat_ts)`
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3009129066
##########
amoro-ams/src/main/java/org/apache/amoro/server/DBBucketAssignStore.java:
##########
@@ -180,6 +180,25 @@ public void updateLastUpdateTime(AmsServerInfo nodeInfo) throws BucketAssignStor
}
}
+ @Override
+ public List<AmsServerInfo> getAliveNodes() throws BucketAssignStoreException {
+ try {
+ List<BucketAssignmentMeta> rows =
+ getAs(BucketAssignMapper.class, mapper -> mapper.selectAllByCluster(clusterName));
Review Comment:
There is indeed a window-period issue here; I'll optimize 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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007302404
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerExecutor.java:
##########
@@ -49,6 +53,112 @@ public OptimizerExecutor(OptimizerConfig config, int threadId) {
}
public void start() {
+ // Check if in master-slave mode (node manager initialised for either ZK or DB HA)
+ boolean isMasterSlaveMode = getConfig().isMasterSlaveMode() && hasAmsNodeManager();
+
+ if (isMasterSlaveMode) {
+ // Master-slave mode: get node list and process tasks from each node
+ startMasterSlaveMode();
+ } else {
+ // Active-standby mode: use original logic
+ startSingleNodeMode();
+ }
+ }
+
+ /** Start in master-slave mode: get node list and process tasks from each AMS node. */
+ private void startMasterSlaveMode() {
+ // Dynamic polling interval control
+ long basePollInterval = TimeUnit.SECONDS.toMillis(1); // Base interval: 1 second
+ long maxPollInterval = TimeUnit.SECONDS.toMillis(30); // Max interval: 10 seconds
Review Comment:
Remove the inner upper bound of `Math.min(backoffFactor, 3)` to allow the backoff to truly utilize `maxPollInterval`.
Following the fix, the actual progress of the backoff is as follows:
+1 | 2s
-- | --
+2 | 4s
+3 | 8s
+4 | 16s
+5 | 30s(maxPollInterval limit is in effect.)
+6 | 30s
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AMORO-3928] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "czy006 (via GitHub)" <gi...@apache.org>.
czy006 merged PR #3950:
URL: https://github.com/apache/amoro/pull/3950
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3814580582
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@amoro.apache.org list. Thank you for your contributions.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3677048658
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@amoro.apache.org list. Thank you for your contributions.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "xxubai (via GitHub)" <gi...@apache.org>.
xxubai commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3019520395
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerConfig.java:
##########
@@ -214,6 +220,14 @@ public void setCacheTimeout(String cacheTimeout) {
this.cacheTimeout = cacheTimeout;
}
+ public boolean isMasterSlaveMode() {
+ return masterSlaveMode;
+ }
+
+ public void setMasterSlaveMode(boolean masterSlaveMode) {
+ this.masterSlaveMode = masterSlaveMode;
+ }
+
@Override
public String toString() {
Review Comment:
nit: missing field `masterSlaveMode` in `toString`
##########
amoro-ams/src/main/resources/postgres/upgrade.sql:
##########
@@ -224,12 +224,15 @@ ADD COLUMN process_parameters text;
-- ADD table bucket_assignments for storing assigned info
CREATE TABLE IF NOT EXISTS bucket_assignments (
- cluster_name VARCHAR(64) NOT NULL,
+ cluster_name VARCHAR(64) NOT NULL,
node_key VARCHAR(256) NOT NULL,
server_info_json TEXT NULL,
assignments_json TEXT NULL,
last_update_time BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (cluster_name, node_key)
- );
+);
CREATE INDEX IF NOT EXISTS idx_bucket_assignments_cluster ON bucket_assignments (cluster_name);
+
+-- ADD node_heartbeat_ts to table bucket_assignments
+ALTER TABLE table_process ADD COLUMN node_heartbeat_ts BIGINT NOT NULL DEFAULT 0;
Review Comment:
```suggestion
ALTER TABLE bucket_assignments ADD COLUMN node_heartbeat_ts BIGINT NOT NULL DEFAULT 0;
```
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007252077
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/AbstractOptimizerOperator.java:
##########
@@ -86,25 +157,79 @@ private boolean shouldReturnNull(Throwable t) {
return false;
}
- protected <T> T callAuthenticatedAms(AmsAuthenticatedCallOperation<T> operation)
+ /**
+ * Call authenticated AMS with a specific AMS URL.
+ *
+ * @param amsUrl The AMS node URL to call
+ * @param operation The operation to execute
+ * @return The result of the operation
+ * @throws TException If the operation fails
+ */
+ protected <T> T callAuthenticatedAms(String amsUrl, AmsAuthenticatedCallOperation<T> operation)
throws TException {
+ // Maximum retry time window for auth errors in master-slave mode (30 seconds)
+ long maxAuthRetryTimeWindow = TimeUnit.SECONDS.toMillis(90);
+ Long firstAuthErrorTime = null;
+
while (isStarted()) {
if (tokenIsReady()) {
String token = getToken();
try {
- return operation.call(OptimizingClientPools.getClient(config.getAmsUrl()), token);
+ // Reset retry time on successful call
+ firstAuthErrorTime = null;
+ return operation.call(OptimizingClientPools.getClient(amsUrl), token);
Review Comment:
Resetting the timer before every invocation causes the `elapsedTime >= maxAuthRetryTimeWindow` branch to never trigger, meaning `resetToken` is never executed. Consequently, the optimizer will retry indefinitely in master-slave mode and will be unable to recover in the event of a genuine authentication failure.
When the method returns successfully, `firstAuthErrorTime` acts as a local variable that is destroyed upon method exit; therefore, it requires no manual reset whatsoever. The correct fix is simply to delete these two lines:
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007273253
##########
amoro-optimizer/amoro-optimizer-common/src/main/java/org/apache/amoro/optimizer/common/OptimizerExecutor.java:
##########
@@ -49,6 +53,112 @@ public OptimizerExecutor(OptimizerConfig config, int threadId) {
}
public void start() {
+ // Check if in master-slave mode (node manager initialised for either ZK or DB HA)
+ boolean isMasterSlaveMode = getConfig().isMasterSlaveMode() && hasAmsNodeManager();
+
+ if (isMasterSlaveMode) {
+ // Master-slave mode: get node list and process tasks from each node
+ startMasterSlaveMode();
Review Comment:
That's an excellent suggestion; I will optimize the implementation here.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3007294146
##########
amoro-common/src/main/java/org/apache/amoro/OptimizerProperties.java:
##########
@@ -48,4 +48,5 @@ public class OptimizerProperties {
public static final String OPTIMIZER_CACHE_MAX_TOTAL_SIZE_DEFAULT = "128mb";
public static final String OPTIMIZER_CACHE_TIMEOUT = "cache-timeout";
public static final String OPTIMIZER_CACHE_TIMEOUT_DEFAULT = "10min";
+ public static final String OPTIMIZER_MASTER_SLAVE_MODE = "master-slave-mode";
Review Comment:
Okay, it will be renamed to OPTIMIZER_MASTER_SLAVE_MODE_ENABLED.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3008096129
##########
amoro-ams/src/test/java/org/apache/amoro/server/TestOptimizerGroupKeeper.java:
##########
@@ -80,7 +81,7 @@ public static Object[] parameters() {
@Before
public void prepare() throws Exception {
optimizerRegistrar = registerInfo -> optimizingService().authenticate(registerInfo);
- setupMockContainer();
+ setupMockContainer(() -> currentGroupName);
Review Comment:
So, does this need to be reverted?
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "xxubai (via GitHub)" <gi...@apache.org>.
xxubai commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3008125210
##########
amoro-ams/src/test/java/org/apache/amoro/server/TestOptimizerGroupKeeper.java:
##########
@@ -80,7 +81,7 @@ public static Object[] parameters() {
@Before
public void prepare() throws Exception {
optimizerRegistrar = registerInfo -> optimizingService().authenticate(registerInfo);
- setupMockContainer();
+ setupMockContainer(() -> currentGroupName);
Review Comment:
Yeah...
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3008398885
##########
amoro-ams/src/test/java/org/apache/amoro/server/TestOptimizerGroupKeeper.java:
##########
@@ -80,7 +81,7 @@ public static Object[] parameters() {
@Before
public void prepare() throws Exception {
optimizerRegistrar = registerInfo -> optimizingService().authenticate(registerInfo);
- setupMockContainer();
+ setupMockContainer(() -> currentGroupName);
Review Comment:
Okay, I will reverted it and fix it in another PR. https://github.com/apache/amoro/issues/4151
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "xxubai (via GitHub)" <gi...@apache.org>.
xxubai commented on code in PR #3950:
URL: https://github.com/apache/amoro/pull/3950#discussion_r3010469513
##########
amoro-common/src/main/java/org/apache/amoro/OptimizerProperties.java:
##########
@@ -48,5 +48,5 @@ public class OptimizerProperties {
public static final String OPTIMIZER_CACHE_MAX_TOTAL_SIZE_DEFAULT = "128mb";
public static final String OPTIMIZER_CACHE_TIMEOUT = "cache-timeout";
public static final String OPTIMIZER_CACHE_TIMEOUT_DEFAULT = "10min";
- public static final String OPTIMIZER_MASTER_SLAVE_MODE = "master-slave-mode";
+ public static final String OPTIMIZER_MASTER_SLAVE_MODE_ENABLED = "master-slave-mode";
Review Comment:
`master-slave-mode-enabled`
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "wardlican (via GitHub)" <gi...@apache.org>.
wardlican commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3681754284
Please help with the code review.
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modify the optimizer to support obtaining tasks from each AMS node for processing. [amoro]
Posted by "czy006 (via GitHub)" <gi...@apache.org>.
czy006 commented on PR #3950:
URL: https://github.com/apache/amoro/pull/3950#issuecomment-3692537969
After resolving any conflicts in the code, I will initiate the first review on my end cc @wardlican
--
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: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org