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

Iris에서 go-redis 관련 오류시 fall back 로직 추가 #1735

Open
3 tasks done
goathoon opened this issue Jun 4, 2024 · 0 comments
Open
3 tasks done

Iris에서 go-redis 관련 오류시 fall back 로직 추가 #1735

goathoon opened this issue Jun 4, 2024 · 0 comments
Assignees
Labels
p2-nice-to-have 🚦 Priority 2: 기존 동작에 영향은 없지만, 추가되면 좋을 것 ⛳️ team-iris

Comments

@goathoon
Copy link
Member

goathoon commented Jun 4, 2024

Describe the problem and solution

문제가 되는 코드는 아래와 같습니다.
Redis자체에서(go-redis 라이브러리 포함) 오류가 생길 경우, 빈 TestCase를 받아오고 return해버려서, go-redis 오픈소스에서 문제가 생기면 채점 요청이 이뤄지지 못합니다. 이를 개선하기 위한 작업이 필요합니다.

++ 추가로, AWS ElastiCache에 문제가 생길 경우에 fallback로직도 마련할 필요가 있을것 같습니다.

func (t *testcaseManager) GetTestcase(problemId string) (Testcase, error) {
	isExist, err := t.cache.IsExist(problemId)
	if err != nil {
		return Testcase{}, fmt.Errorf("GetTestcase: %w", err)
	}

	if !isExist {
		bytes, err := t.source.Get(problemId)
		if err != nil {
			return Testcase{}, fmt.Errorf("get testcase: %w", err)
		}

		elements := []Element{}
		err = json.Unmarshal(bytes, &elements) // validate
		if err != nil {
			return Testcase{}, fmt.Errorf("invalid testcase data: %w", err)
		}

		testcase := Testcase{Elements: elements}
		err = t.cache.Set(problemId, testcase)
		if err != nil {
			return Testcase{}, fmt.Errorf("cache set: %w", err)
		}

		return testcase, nil
	}

	data, err := t.cache.Get(problemId)
	if err != nil {
		return Testcase{}, fmt.Errorf("testcase: %s: %w", problemId, err)
	}

	testcase := Testcase{}
	err = testcase.UnmarshalBinary(data)
	if err != nil {
		return Testcase{}, fmt.Errorf("testcase: %w", err)
	}
	return testcase, nil
}

Validations

@goathoon goathoon added p2-nice-to-have 🚦 Priority 2: 기존 동작에 영향은 없지만, 추가되면 좋을 것 pending triage ⛳️ team-iris labels Jun 4, 2024
@goathoon goathoon self-assigned this Jun 4, 2024
@goathoon goathoon changed the title Iris에서 Redis 오류시 fall back 로직 추가 Iris에서 go-redis 관련 오류시 fall back 로직 추가 Jun 4, 2024
@goathoon goathoon removed their assignment Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have 🚦 Priority 2: 기존 동작에 영향은 없지만, 추가되면 좋을 것 ⛳️ team-iris
Projects
Status: Pending
Development

No branches or pull requests

3 participants