Skip to content

Commit

Permalink
Merge pull request #93 from aliismayilov/minimal-wal-level
Browse files Browse the repository at this point in the history
Recommend minimal wal_level on desktop environments
  • Loading branch information
le0pard authored Aug 5, 2024
2 parents aad5524 + af1b8b5 commit 7c9a147
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
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

0 comments on commit 7c9a147

Please sign in to comment.