Skip to content

Commit

Permalink
also add check for data bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anshul committed Jan 17, 2025
1 parent 536fdaa commit 4540d95
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions runtime/pkg/rduckdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ func NewDB(ctx context.Context, opts *DBOptions) (DB, error) {
// migrate db from old storage structure to new
err = db.migrateDB(ctx)
if err != nil && !errors.Is(err, context.Canceled) {
// do not return error data will be reingested
// do not return error just truncate the directory and start fresh
db.logger.Error("failed to migrate db", slog.String("error", err.Error()))
// just truncate the directory and start fresh
err = os.RemoveAll(db.localPath)
if err != nil {
return nil, err
Expand All @@ -254,15 +253,14 @@ func NewDB(ctx context.Context, opts *DBOptions) (DB, error) {
isBackedUp, _ := db.isBackedUp()
if !isBackedUp && db.remote != nil {
// switched on remote storage
// backup local data
// push local data to remote
err := db.iterateLocalTables(false, func(name string, meta *tableMeta) error {
return db.pushToRemote(ctx, name, nil, meta)
})
if err != nil {
return nil, fmt.Errorf("unable to write local data to remote: %w", err)
}
}
// add a backup true/false signal so that we can check if the db is backed up
err = os.WriteFile(filepath.Join(db.localPath, "__rill_backup.txt"), []byte(strconv.FormatBool(db.remote != nil)), fs.ModePerm)
if err != nil {
return nil, err
Expand Down

0 comments on commit 4540d95

Please sign in to comment.