Skip to content
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

Recommend minimal wal_level on desktop environments #93

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/common/components/configurationView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
selectEffectiveIoConcurrency,
selectParallelSettings,
selectWorkMem,
selectWarningInfoMessages
selectWarningInfoMessages,
selectWalLevel
} from '@features/configuration/configurationSlice'
import {
openConfigTab,
Expand Down Expand Up @@ -110,6 +111,7 @@ const ConfigurationView = () => {
const effectiveCacheSizeVal = useSelector(selectEffectiveCacheSize)
const maintenanceWorkMemVal = useSelector(selectMaintenanceWorkMem)
const checkpointSegmentsVal = useSelector(selectCheckpointSegments)
const walLevelVal = useSelector(selectWalLevel)
const checkpointCompletionTargetVal = useSelector(selectCheckpointCompletionTarget)
const walBuffersVal = useSelector(selectWalBuffers)
const defaultStatisticsTargetVal = useSelector(selectDefaultStatisticsTarget)
Expand Down Expand Up @@ -153,6 +155,8 @@ const ConfigurationView = () => {
return [item.key, formatValue(item.value)]
})

const getWalLevel = () => walLevelVal.map((item) => [item.key, item.value])

const getParallelSettings = () => parallelSettingsVal.map((item) => [item.key, item.value])

const postgresqlConfig = () => {
Expand All @@ -171,6 +175,7 @@ const ConfigurationView = () => {
]
.concat(getCheckpointSegments())
.concat(getParallelSettings())
.concat(getWalLevel())

return configData
.filter((item) => !!item[1])
Expand Down
28 changes: 27 additions & 1 deletion src/features/configuration/__tests__/configurationSlice.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
selectDefaultStatisticsTarget,
selectRandomPageCost,
selectEffectiveIoConcurrency,
selectParallelSettings
selectParallelSettings,
selectWalLevel
} from '../configurationSlice'

describe('selectIsConfigured', () => {
Expand Down Expand Up @@ -268,3 +269,28 @@ describe('selectParallelSettings', () => {
])
})
})

describe('selectWalLevel', () => {
it('desktop app', () => {
expect(
selectWalLevel({
configuration: {
dbType: 'desktop'
}
})
).toEqual([
{ key: 'wal_level', value: 'minimal' },
{ key: 'max_wal_senders', value: '0' }
])
})

it('web app', () => {
expect(
selectWalLevel({
configuration: {
dbType: 'web'
}
})
).toEqual([])
})
})
18 changes: 18 additions & 0 deletions src/features/configuration/configurationSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,23 @@ export const selectWarningInfoMessages = createSelector(
}
)

export const selectWalLevel = createSelector([selectDBType], (dbType) => {
if (dbType === DB_TYPE_DESKTOP) {
return [
{
key: 'wal_level',
value: 'minimal'
},
// max_wal_senders must be 0 when wal_level=minimal
{
key: 'max_wal_senders',
value: '0'
}
]
}

return []
})

// Export the slice reducer as the default export
export default configurationSlice.reducer