atlasdb
atlasdb copied to clipboard
[PDS-265616] Prevent NotInitializedExceptions from failing the AtlasDB CLI
General
Before this PR: AtlasDB CLI could fail if KVS async initialization is enabled, and the KVS is used before it is initialized.
This is because use throws a NotInitializedException, which is fatal. After this PR: The Dagger service used by the CLI actually performs some createTable operations, before returning the KVS. This PR ensures that the KVS is initialized before the kvs wrapper performs operations.
==COMMIT_MSG==
AtlasDB CLI and other Dagger AtlasDB consumers no longer throw NotInitializedException when KVS async initialization is enabled.
==COMMIT_MSG==
Priority: P2
Concerns / possible downsides (what feedback would you like?): Is there a nicer way to wait on the initialization? Could we just change the standard rawKvs provider to wait for initialization, without needing a second provider? I didn't find a use for the Dagger module outside of the CLI. The approach taken in this PR is safer, since it's not a break, but doesn't clean up tech debt.
Is documentation needed?: No
Compatibility
Does this PR create any API breaks (e.g. at the Java or HTTP layers) - if so, do we have compatibility?: No Does this PR change the persisted format of any data - if so, do we have forward and backward compatibility?: No The code in this PR may be part of a blue-green deploy. Can upgrades from previous versions safely coexist? (Consider restarts of blue or green nodes.): Yes Does this PR rely on statements being true about other products at a deployment - if so, do we have correct product dependencies on these products (or other ways of verifying that these statements are true)?: No Does this PR need a schema migration? No
Testing and Correctness
What, if any, assumptions are made about the current state of the world? If they change over time, how will we find out?: That existing Dagger consumers of the wrapped kvs want an initialized version. That KVSs eventually initialize.
What was existing testing like? What have you done to improve it?: Previously, there was very very little. For this PR, I've added tests to show that the new provider returns an initialized KVS, and propagates exceptions during the isInitialized check.
If this PR contains complex concurrent or asynchronous code, is it correct? The onus is on the PR writer to demonstrate this.: Wouldn't say it is complex...
If this PR involves acquiring locks or other shared resources, how do we ensure that these are always released?: N/A How would I tell this PR works in production? (Metrics, logs, etc.): Operators do not complain Has the safety of all log arguments been decided correctly?: N/A Will this change significantly affect our spending on metrics or logs?: N/A How would I tell that this PR does not work in production? (monitors, etc.): Operators will complain If this PR does not work as expected, how do I fix that state? Would rollback be straightforward?: Switch off initializeAsync.
If the above plan is more complex than “recall and rollback”, please tag the support PoC here (if it is the end of the week, tag both the current and next PoC): N/A
Scale
Would this PR be expected to pose a risk at scale? Think of the shopping product at our largest stack.: N/A Would this PR be expected to perform a large number of database calls, and/or expensive database calls (e.g., row range scans, concurrent CAS)?: N/A Would this PR ever, with time and scale, become the wrong thing to do - and if so, how would we know that we need to do something differently?: N/A
Development Process
Where should we start reviewing?: P2 priority
If this PR is in excess of 500 lines excluding versions lock-files, why does it not make sense to split it?: N/A
Please tag any other people who should be aware of this PR: N/A
Generate changelog in changelog/@unreleased
changelog/@unreleasedType
See change types. Select one:
- [ ] Feature
- [ ] Improvement
- [x] Fix
- [ ] Break
- [ ] Deprecation
- [ ] Manual task
- [ ] Migration
Description
NotInitializedException when KVS async initialization is enabled.
Check the box to generate changelog(s)
- [x] Generate changelog entry
Left a comment on why it's safe for posterity :) While the interrupt flag will get set, none of the methods in the critical path will throw on exception (from docs). The cancel is actually optional from a default executor policy, since shutdown will prevent a new periodic task from getting scheduled, but I've left the cancel for clarity as it's cheap, in case anything gets changed.