Skip to content

Conversation

kai-franz
Copy link

@kai-franz kai-franz commented Apr 22, 2025

Currently, we have an issue (yugabyte/yugabyte-db#9861) that causes ysqlsh history to not work between sessions.

We truncate the history file to the size limit (default 500) each time we write to it, keeping the 500 newest history commands and deleting the older ones. Libedit keeps a cookie at the beginning of the history file (after the oldest line of history). During truncation, the cookie gets deleted. The next time we try to load the history file, libedit sees that the cookie is missing and does not load the history file. This is a bug in libedit and is known to affect vanilla PostgreSQL as well.

To fix this, we patch libedit to load the file even if the cookie is missing.

@kai-franz kai-franz requested a review from Copilot April 24, 2025 20:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses the issue with ysqlsh history by patching libedit to ignore the missing history cookie during file truncation.

  • Added a new patch file ('libedit-ignore-missing-cookie.patch') to ensure history is loaded even if the cookie is missing.
  • Updates the build definitions to incorporate the patch in the libedit build process.
Files not reviewed (1)
  • patches/libedit-ignore-missing-cookie.patch: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants