Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCF-3052 - Job Based KV Store and juelsFeePerCoin reboot persistence #12392

Merged
merged 22 commits into from
Mar 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update kVStore sql to match migration
  • Loading branch information
ilija42 committed Mar 12, 2024
commit d0827472e4091f141615299fcec83bf04d1a7395
9 changes: 4 additions & 5 deletions core/services/job/kv_orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ func (kv kVStore) Store(key string, val interface{}) error {
return err
}

sql := `INSERT INTO job_kv_store (id, key, val)
sql := `INSERT INTO job_kv_store (job_id, key, val)
VALUES ($1, $2, $3)
ON CONFLICT (id, key) DO UPDATE SET
ON CONFLICT (job_id, key) DO UPDATE SET
val = EXCLUDED.val,
updated_at = $4
RETURNING id;`
updated_at = $4;`

if err = kv.q.ExecQ(sql, kv.jobID, key, types.JSONText(jsonVal), time.Now()); err != nil {
return fmt.Errorf("failed to store value: %s for key: %s for jobID: %d : %w", string(jsonVal), key, kv.jobID, err)
Expand All @@ -60,7 +59,7 @@ func (kv kVStore) Store(key string, val interface{}) error {
// Get retrieves serializable value by key.
func (kv kVStore) Get(key string, dest interface{}) error {
var ret json.RawMessage
sql := "SELECT val FROM job_kv_store WHERE id = $1 AND key = $2"
sql := "SELECT val FROM job_kv_store WHERE job_id = $1 AND key = $2"
if err := kv.q.Get(&ret, sql, kv.jobID, key); err != nil {
return fmt.Errorf("failed to get value by key: %s for jobID: %d : %w", key, kv.jobID, err)
}
Expand Down
Loading