-
Notifications
You must be signed in to change notification settings - Fork 315
NoSQL: Node IDs - API, SPI + general implementation #2728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
return 0; | ||
} | ||
}; | ||
while (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd agree that permanent store/load failures are unlikely, but would it be worth adding a limit here just for general robustness?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean to fail startup in case we hit a limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here - yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worth breaking this loop on timeout (with an exception)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. It takes a bit. Worst that can happen is that it reads 1024 (default) rows in batches of 16 and figures out that none can be leased.
Renewals are safe. Unless you stall your system for 15+ minutes during the "renewal time window" (that would fall back to a new lease attempt).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure.... storeManagementState()
(line 153) could keep returning false
(for whatever reason, we do not know what the impl. will do 🤷 ) and stall startup... WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a retry-loop for having one state (think: the id-generator configuration) persisted. That configuration (for the snowflake id generator) must be immutable for the lifetime of the "repository", because changing the id-generator configuration will lead to ID collisions. Once that config is there, the loop's finished. That's orthogonal to the node-lease mechanism.
This loop is literally only for the case when concurrently starting nodes read "no state" and then attempt to persist "their" config.
A "legit DB error" bubbles up and aborts the startup anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit too fuzzy at this level (what the related components are and do depends on too many factors (build, config, etc.). I'd prefer to avoid the unlimited loop just for "general robustness".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a hard coded timeout. But there's not more we can do. It has to eventually succeed or fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx 👍
...istence/nosql/nodes/impl/src/main/java/org/apache/polaris/nodes/impl/NodeManagementImpl.java
Outdated
Show resolved
Hide resolved
This PR provides a mechanism to assign a Polaris-cluster-wide unique node-ID to each Polaris instance, which is then used when generating Polaris-cluster-wide unique Snowflake-IDs. The change is fundamental for the NoSQL work, but also demanded for the existing relational JDBC persistence. Does not include any persistence specific implementation.
Also move the expensive part to a `@PostConstruct` to not block CDI entirely from initializing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on it! Left some comments. Given this is a big change(23 new files and 3 new modules), is it worth to have a dev list discussion? So that people are aware of the changes and contribute their ideas.
Some ID generation mechanisms, | ||
like [Snowflake-IDs](https://medium.com/@jitenderkmr/demystifying-snowflake-ids-a-unique-identifier-in-distributed-computing-72796a827c9d), | ||
require unique integer IDs for each running node. This framework provides a mechanism to assign each running node a | ||
unique integer ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If snowflake id generator requires such complex node id generator, maybe we should consider other options. Would it possible to use other id generators? Since we are in the persistence module already, why cannot we use something like ObjectID
in mongoDB, or Java UUID?
* `polaris-nodes-api` provides the necessary Java interfaces and immutable types. | ||
* `polaris-nodes-impl` provides the storage agnostic implementation. | ||
* `polaris-nodes-spi` provides the necessary interfaces to provide a storage specific implementation. | ||
* `polaris-nodes-store-nosql` provides the storage implementation based on `polaris-persistence-nosql-api`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it's in the end-to-end NoSQL PR: #1189 ... to be made available for review later (to allow for smaller, easier-to-review PRs, as discussed)
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.polaris.nodes.api; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anywhere else in Polaris needs this. Can we rename it to org.apache.polaris.nosql.nodes.api
or org.apache.polaris.nosql.snowflakeid.nodes.api
?
* `polaris-nodes-api` provides the necessary Java interfaces and immutable types. | ||
* `polaris-nodes-impl` provides the storage agnostic implementation. | ||
* `polaris-nodes-spi` provides the necessary interfaces to provide a storage specific implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These modules are used by snowflake id generator only, can we merge it into the modules holding snowflake id generators? So that the snowflake id generator is more consistent and self-contained.
This PR provides a mechanism to assign a Polaris-cluster-wide unique node-ID to each Polaris instance, which is then used when generating Polaris-cluster-wide unique Snowflake-IDs.
The change is fundamental for the NoSQL work, but also demanded for the existing relational JDBC persistence.
Does not include any persistence specific implementation.