Skip to content

Commit

Permalink
support connecting to cluster members missing default database (#1832)
Browse files Browse the repository at this point in the history
* support connecting to cluster members missing default database

* Fix slow label data in 3.5 testing
  • Loading branch information
OskarDamkjaer authored Oct 4, 2022
1 parent 5922832 commit 6fd391b
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/shared/modules/dbMeta/dbMetaEpics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ import {
setAuthEnabled,
setRetainCredentials,
updateConnection,
useDb
useDb,
getConnectedHost
} from 'shared/modules/connections/connectionsDuck'
import { clearHistory } from 'shared/modules/history/historyDuck'
import { backgroundTxMetadata } from 'shared/services/bolt/txMetadata'
Expand All @@ -81,6 +82,7 @@ import {
import { isInt, Record } from 'neo4j-driver'
import semver, { gte, SemVer } from 'semver'
import { triggerCredentialsTimeout } from '../credentialsPolicy/credentialsPolicyDuck'
import { isNonRoutingScheme } from 'services/boltscheme.utils'

async function databaseList(store: any) {
try {
Expand Down Expand Up @@ -166,16 +168,23 @@ async function getLabelsAndTypes(store: any) {

async function getFunctionsAndProcedures(store: any) {
const version = getSemanticVersion(store.getState())
const supportsMultiDb = await bolt.hasMultiDbSupport()
try {
const procedurePromise = bolt.routedReadTransaction(
getListProcedureQuery(version),
{},
backgroundTxMetadata
{
...backgroundTxMetadata,
useDb: supportsMultiDb ? SYSTEM_DB : undefined
}
)
const functionPromise = bolt.routedReadTransaction(
getListFunctionQuery(version),
{},
backgroundTxMetadata
{
...backgroundTxMetadata,
useDb: supportsMultiDb ? SYSTEM_DB : undefined
}
)
const [procedures, functions] = await Promise.all([
procedurePromise,
Expand Down Expand Up @@ -219,7 +228,10 @@ async function fetchServerInfo(store: any) {
const serverInfo = await bolt.directTransaction(
serverInfoQuery,
{},
backgroundTxMetadata
{
...backgroundTxMetadata,
useDb: (await bolt.hasMultiDbSupport()) ? SYSTEM_DB : undefined
}
)
store.dispatch(updateServerInfo(serverInfo))
} catch {}
Expand Down Expand Up @@ -301,10 +313,15 @@ export const dbMetaEpic = (some$: any, store: any) =>
.merge(some$.ofType(FORCE_FETCH))
// Throw away newly initiated calls until done
.throttle(() => some$.ofType(DB_META_DONE))
.do(() => {
// Cluster setups where the default database is unavailable,
// get labels and types takes a long time to finish and it shouldn't
// be blocking the rest of the bootup process, so we don't await the promise
getLabelsAndTypes(store)
})
.mergeMap(() =>
Rx.Observable.fromPromise(
Promise.all([
getLabelsAndTypes(store),
getFunctionsAndProcedures(store),
clusterRole(store),
databaseList(store)
Expand Down

0 comments on commit 6fd391b

Please sign in to comment.