dice icon indicating copy to clipboard operation
dice copied to clipboard

#421: Config file support

Open vinitparekh17 opened this issue 1 year ago • 13 comments

This PR introduce more structured way of using config in DiceDB

1 introducing installation script:

  • creates appropriate user grp, files and folder to support configuration.
  • reduce user complexity of manual setup

[!NOTE] requires default config file and build file of Dice in cloud to copy

2 config file support using viper:

  • our db uses .toml file for config and can support live reloading of config thanks to viper

  • config file demo:

[Server]
  Addr = "0.0.0.0"
  Port = 7379
  KeepAlive = 60
  Timeout = 300
  MaxConn = 0
  ShardCronFrequency = "1s"
  MultiplexerPollTimeout = "100ms"
  MaxClients = 20000
  MaxMemory = 0
  EnvictionPolicy = "allkeys-lru"
  PersistanceEnabled = true

[Auth]
  UserName = "dice"
  Password = ""

[Network]
  IOBufferLength = 512
  IOBufferLengthMAX = 51200

vinitparekh17 avatar Sep 04 '24 08:09 vinitparekh17

Please resolve conflicts

JyotinderSingh avatar Sep 04 '24 11:09 JyotinderSingh

Done.

vinitparekh17 avatar Sep 04 '24 13:09 vinitparekh17

@vinitparekh17 thanks for getting this very important PR out @lucifercr07 thanks for the thorough review, lets make sure we have this important change in asap. Today the configs are global variables which is dangerous, this PR will make the config management much saner.

soumya-codes avatar Sep 07 '24 00:09 soumya-codes

Config file test cases implemented and locally tested, PersistenceEnabled flag won't cause any test to fail (except flakiness issues due to io timeout, the present cause)

@soumya-codes @lucifercr07 I think we are good to go now.

vinitparekh17 avatar Sep 07 '24 06:09 vinitparekh17

Please rebase this PR.

JyotinderSingh avatar Sep 08 '24 13:09 JyotinderSingh

Please rebase this PR.

@JyotinderSingh Cleaned up the mess of conflicts, rebase completed

vinitparekh17 avatar Sep 10 '24 15:09 vinitparekh17

now it won't lead to nil pointer err while testing ./internals/...

vinitparekh17 avatar Sep 10 '24 16:09 vinitparekh17

Recheck plz

vinitparekh17 avatar Sep 11 '24 19:09 vinitparekh17

@JyotinderSingh would like a second eye on this PR.

lucifercr07 avatar Sep 12 '24 15:09 lucifercr07

If we do not include the shell script, will these changes still work out of the box? We shouldn't require the user to set up user groups and permissions just to run the database (even running a script shouldn't be necessary).

JyotinderSingh avatar Sep 12 '24 17:09 JyotinderSingh

If we do not include the shell script, will these changes still work out of the box? We shouldn't require the user to set up user groups and permissions just to run the database (even running a script shouldn't be necessary).

It will work seamlessly, but the catch is that the database won’t be able to access /etc/<dbname>/<fileName>, unlike Redis.

current behaviour will be as follow as:

  • Dice will use the default configuration if it starts in the usual way.
  • Dice will read the config if started with the -c flag (file path of the config file).
  • Dice will create a configuration file if started with the -o flag (destination path to create the config), provided it has sufficient permissions to access that path.

vinitparekh17 avatar Sep 13 '24 03:09 vinitparekh17

If we do not include the shell script, will these changes still work out of the box? We shouldn't require the user to set up user groups and permissions just to run the database (even running a script shouldn't be necessary).

It will work seamlessly, but the catch is that the database won’t be able to access /etc/<dbname>/<fileName>, unlike Redis.

current behaviour will be as follow as:

  • Dice will use the default configuration if it starts in the usual way.

  • Dice will read the config if started with the -c flag (file path of the config file).

  • Dice will create a configuration file if started with the -o flag (destination path to create the config), provided it has sufficient permissions to access that path.

Got it. Please document this behavior and information in the README.

We can add the shell script as a separate change (just mention what permissions the user needs to set for the directory stuff to work so that they can do it manually and don't have to depend on a script)

JyotinderSingh avatar Sep 13 '24 08:09 JyotinderSingh

If we do not include the shell script, will these changes still work out of the box? We shouldn't require the user to set up user groups and permissions just to run the database (even running a script shouldn't be necessary).

It will work seamlessly, but the catch is that the database won’t be able to access /etc/<dbname>/<fileName>, unlike Redis.

current behaviour will be as follow as:

  • Dice will use the default configuration if it starts in the usual way.
  • Dice will read the config if started with the -c flag (file path of the config file).
  • Dice will create a configuration file if started with the -o flag (destination path to create the config), provided it has sufficient permissions to access that path.

Got it. Please document this behavior and information in the README.

We can add the shell script as a separate change (just mention what permissions the user needs to set for the directory stuff to work so that they can do it manually and don't have to depend on a script)

Changes made

vinitparekh17 avatar Sep 14 '24 11:09 vinitparekh17

Had a few minor comments, please resolve them. Will merge once done.

JyotinderSingh avatar Sep 14 '24 16:09 JyotinderSingh

Had a few minor comments, please resolve them. Will merge once done.

We are good to go 👍

vinitparekh17 avatar Sep 14 '24 17:09 vinitparekh17

@vinitparekh17 there seem to be some data races happening. Can you look into it?

JyotinderSingh avatar Sep 14 '24 17:09 JyotinderSingh

@vinitparekh17 there seem to be some data races happening. Can you look into it?

Checking

vinitparekh17 avatar Sep 14 '24 17:09 vinitparekh17

@JyotinderSingh Isolated config test in order to prevent race condition.

vinitparekh17 avatar Sep 14 '24 18:09 vinitparekh17

@JyotinderSingh Isolated config test in order to prevent race condition.

Why did we remove test case for scenario 5?

JyotinderSingh avatar Sep 14 '24 19:09 JyotinderSingh

@JyotinderSingh Isolated config test in order to prevent race condition.

Why did we remove test case for scenario 5?

Scenario 4 and 5 is almost identical so thought it was unnecessary

vinitparekh17 avatar Sep 14 '24 19:09 vinitparekh17

Anyways have to look into it coz in my machine it works in Github action it fails

vinitparekh17 avatar Sep 14 '24 19:09 vinitparekh17

@JyotinderSingh It will work now, hopefully

added back scenario 5, made necessary changes to make it cleaner and accurate and now tested it on cloud instance.

btw, I am really sorry for your inconvenience

vinitparekh17 avatar Sep 14 '24 19:09 vinitparekh17