Skip to content

Commit

Permalink
Create repository using time on DB
Browse files Browse the repository at this point in the history
Using system time [causes weirdness](https://youtu.be/-w0WPkB3XJ4) when there are multiple
lakefs daemons.
  • Loading branch information
arielshaqed committed Sep 14, 2020
1 parent 1aff5ce commit aedb342
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions catalog/cataloger_create_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ func (c *cataloger) CreateRepository(ctx context.Context, repository string, sto
}

// create repository with ref to branch
creationDate := c.clock.Now()
if _, err := tx.Exec(`INSERT INTO catalog_repositories (id,name,storage_namespace,creation_date,default_branch)
VALUES ($1,$2,$3,$4,$5)`, repoID, repository, storageNamespace, creationDate, branchID); err != nil {
VALUES ($1,$2,$3,transaction_timestamp(),$4)`, repoID, repository, storageNamespace, branchID); err != nil {
return nil, fmt.Errorf("insert repository: %w", err)
}

Expand All @@ -51,8 +50,8 @@ func (c *cataloger) CreateRepository(ctx context.Context, repository string, sto

// create initial commit
_, err := tx.Exec(`INSERT INTO catalog_commits (branch_id,commit_id,committer,message,creation_date,previous_commit_id)
VALUES ($1,nextval('catalog_commit_id_seq'),$2,$3,$4,0)`,
branchID, CatalogerCommitter, createRepositoryCommitMessage, creationDate)
VALUES ($1,nextval('catalog_commit_id_seq'),$2,$3,transaction_timestamp(),0)`,
branchID, CatalogerCommitter, createRepositoryCommitMessage)
if err != nil {
return nil, fmt.Errorf("insert commit: %w", err)
}
Expand Down

0 comments on commit aedb342

Please sign in to comment.