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

SNOW-614539: incorrect error messages in writeOCSPCacheFile in ocsp.go #589

Closed
setharnold opened this issue Jun 17, 2022 · 4 comments
Closed
Assignees
Labels
bug Erroneous or unexpected behaviour

Comments

@setharnold
Copy link

func writeOCSPCacheFile() {

Hello, there's some inconsistent error messages in writeOCSPCacheFile():

	err := os.Mkdir(cacheLockFileName, 0600)
	switch {
	case os.IsExist(err):
		statinfo, err := os.Stat(cacheLockFileName)
		if err != nil {
			logger.Debugf("failed to write OCSP response cache file. file: %v, err: %v. ignored.\n", cacheFileName, err)
			return
		}
		if time.Since(statinfo.ModTime()) < 15*time.Minute {
			logger.Debugf("other process locks the cache file. %v. ignored.\n", cacheFileName)
			return
		}
		if err = os.Remove(cacheLockFileName); err != nil {
			logger.Debugf("failed to delete lock file. file: %v, err: %v. ignored.\n", cacheLockFileName, err)
			return
		}
		if err = os.Mkdir(cacheLockFileName, 0600); err != nil {
			logger.Debugf("failed to delete lock file. file: %v, err: %v. ignored.\n", cacheLockFileName, err)
			return
		}
	}

The first two might be more about showing the high-level intentions of the code rather than the lower-level indicator of what exactly failed, but in my experience, trying to give higher-level descriptions of failures is more confusing than helpful:

The first logger.Debugf() reports a failure to write the cache file, but what actually failed was a stat(2) on the lock file. The wrong filename is given in the error message.

The second logger.Debugf() reports the name of the cache file, not the lock file, despite the operation being on the lock file. The wrong filename is given in the error message.

The fourth logger.Debugf() reports the wrong operation.

I'm not accustomed to seeing lock directories used; especially since all the log messages here are discussing lock files. There's two very similar variables in play here, cacheFileName and cacheLockFileName and I'm worried that some of these operations may be using the wrong one.

Also left unhandled is if the original os.Mkdir(cacheLockFileName, 0600) fails for other reasons: permission denied, operation not permitted, I/O error, too many open files, etc.

Thanks

@github-actions github-actions bot changed the title incorrect error messages in writeOCSPCacheFile in ocsp.go SNOW-614539: incorrect error messages in writeOCSPCacheFile in ocsp.go Jun 17, 2022
@github-actions github-actions bot closed this as completed Jul 1, 2022
@setharnold
Copy link
Author

Hmm, has the automation run amok here? I don't see a change in the most recent version, where the Mkdir on line 843 is called a delete operation in the log message:

func writeOCSPCacheFile() {

Thanks

@sfc-gh-jfan sfc-gh-jfan reopened this Jul 1, 2022
@github-actions github-actions bot closed this as completed Jul 2, 2022
@sfc-gh-jfan sfc-gh-jfan reopened this Jul 6, 2022
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Mar 28, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Mar 28, 2023
@sfc-gh-dszmolka
Copy link
Contributor

hi, thank you for submitting this issue with us ! indeed the automation went a little bit amok last summer, but it has been rectified and this issue reopened.
which is still valid even today, so we'll take a look. appreciated the detailed description and thank you for bearing with us until this is taken care of.

@sfc-gh-dszmolka sfc-gh-dszmolka added status-in_progress Issue is worked on by the driver team and removed status-triage Issue is under initial triage labels Mar 28, 2023
@sfc-gh-igarish sfc-gh-igarish added the bug Erroneous or unexpected behaviour label Mar 30, 2023
@sfc-gh-dszmolka
Copy link
Contributor

fix is merged and will be part of April's release, expected to come towards the end of the month

@sfc-gh-dszmolka sfc-gh-dszmolka added status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. and removed status-in_progress Issue is worked on by the driver team labels Apr 6, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka removed the status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. label Apr 19, 2023
@sfc-gh-dszmolka
Copy link
Contributor

fix released with 1.6.20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Erroneous or unexpected behaviour
Projects
None yet
Development

No branches or pull requests

4 participants