Skip to content

Commit

Permalink
Use /tmp dir to store temporary index (#4766)
Browse files Browse the repository at this point in the history
Fixes #4600
While running dgraph as systemd service, we may not have permissions
to create a folder in the current directory. Now, we instead use /tmp
dir to store the temporary index solving the permission denied error.

(cherry picked from commit 8bf9046)
  • Loading branch information
mangalaman93 authored and ashish-goswami committed Jun 25, 2020
1 parent 2e41128 commit 26ddfad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion posting/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"io/ioutil"
"math"
"os"
"path/filepath"
"sync/atomic"
"time"

Expand Down Expand Up @@ -512,7 +513,8 @@ func (r *rebuilder) Run(ctx context.Context) error {
// All the temp indexes go into the following directory. We delete the whole
// directory after the indexing step is complete. This deletes any other temp
// indexes that may have been left around in case defer wasn't executed.
tmpParentDir := "dgraph_index"
// TODO(Aman): If users are not happy, we could add a flag to choose this dir.
tmpParentDir := filepath.Join(os.TempDir(), "dgraph_index")

// We write the index in a temporary badger first and then,
// merge entries before writing them to p directory.
Expand Down

0 comments on commit 26ddfad

Please sign in to comment.