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

[Bug]: Atuin seems to randomly "forget" lots of history also strange fuzzy search behavior. #2375

Open
1 task done
NeckBeardPrince opened this issue Aug 28, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@NeckBeardPrince
Copy link

What did you expect to happen?

I went to search my history for gcloud but there were no valid hits. I know I just used that command about 20 times this week, so it didn't make sense that nothing was showing up. Well, when I say nothing, I mean nothing that has the word gcloud in it. None of those commands have the word gcloud, I tried "gcloud" and just gcloud. Nothing.

CleanShot 2024-08-28 at 14 51 46

docker run \
    -e KEYCLOAK_URL="<removed>" \
    -e KEYCLOAK_USER="<removed>" \
    -e KEYCLOAK_PASSWORD="<removed>" \
    -e KEYCLOAK_AVAILABILITYCHECK_ENABLED=true \
    -e KEYCLOAK_AVAILABILITYCHECK_TIMEOUT=120s \
    -e IMPORT_FILES_LOCATIONS='/config/*' \
    -v $PWD/config:/config \
    adorsys/keycloak-config-cli:latest

What happened?

Running atuin stats atuin is counting the times I've used gcloud.
CleanShot 2024-08-28 at 14 55 38

atuin sync
Uploading 8 records to 0190c3daa0ed7c53933dd5eaeb013b8f/history
  [00:00:00] [####################################################################################################################################################################################################################] 8/8 (0.0s)9/0 up/down to record store
Sync complete! 37598 items in history database, force: falseatuin sync --force
Uploading 1 records to 0190c3daa0ed7c53933dd5eaeb013b8f/history
  [00:00:00] [####################################################################################################################################################################################################################] 1/1 (0.0s)2/0 up/down to record store
Sync complete! 37599 items in history database, force: true

Checking the SQLite db 37599 is the number of rows I have.

CleanShot 2024-08-28 at 14 58 14

If I search the command column for contains gcloud I get 675 rows.

CleanShot 2024-08-28 at 14 59 25

If I cat ~/.zsh_history | grep gcloud I see results.

Atuin doctor output

{
  "atuin": {
    "version": "18.3.0",
    "sync": {
      "cloud": false,
      "records": true,
      "auto_sync": true,
      "last_sync": "2024-08-28 19:16:08.379861 +00:00:00"
    },
    "sqlite_version": "3.44.0"
  },
  "shell": {
    "name": "zsh",
    "default": "zsh",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Darwin",
    "arch": "arm64",
    "version": "14.6.1",
    "disks": [
      {
        "name": "Macintosh HD",
        "filesystem": "apfs"
      },
      {
        "name": "Macintosh HD",
        "filesystem": "apfs"
      },
      {
        "name": "Backups",
        "filesystem": "apfs"
      },
      {
        "name": "Time Machine",
        "filesystem": "apfs"
      }
    ]
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@NeckBeardPrince NeckBeardPrince added the bug Something isn't working label Aug 28, 2024
@NeckBeardPrince
Copy link
Author

I ran atuin import auto then atuin sync.
I have a cronjob that runs atuin sync every 30min or so. I ran atuin sync several times while troubleshooting this.

atuin import auto
        Atuin
======================
          🌍
       🐘🐘🐘🐘
          🐢
======================
Importing history...
Detected ZSH
Importing history from zsh
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 11273/11273Import complete!atuin sync
Uploading 5 records to 0190c3daa0ed7c53933dd5eaeb013b8f/history
  [00:00:00] [####################################################################################################################################################################################################################] 5/5 (0.0s)6/0 up/down to record store
48553 in history index, but 37617 in history store
Running automatic history store init...
  Import complete                                                                                                                                                                                                                             Re-running sync due to new records locally
Uploading 10964 records to 0190c3daa0ed7c53933dd5eaeb013b8f/history
  [00:00:12] [##########################################################################################################################################################################################################] 10,964/10,964 (0.0s)10965/0 up/down to record store
Sync complete! 48553 items in history database, force: false

@NeckBeardPrince
Copy link
Author

Another one

CleanShot 2024-09-03 at 17 09 06

CleanShot 2024-09-03 at 17 10 02

@codyps
Copy link

codyps commented Sep 20, 2024

It looks like you're doing "HOST" searches here and are using macos. Is it possible that the hostname macos is reporting is different between the time when the command is looked up and the content stored in the history database?

See #2391 for an issue I wrote about this and a workaround.

@NeckBeardPrince
Copy link
Author

It looks like you're doing "HOST" searches here and are using macos. Is it possible that the hostname macos is reporting is different between the time when the command is looked up and the content stored in the history database?

See #2391 for an issue I wrote about this and a workaround.

Hmmm interesting, I just installed 15.1. Are you saying that on 15.0 you should no longer have this issue, and you don't need to run scutil --set HostName bar anymore? Or that you still do need to, even if on 15.0?

@codyps
Copy link

codyps commented Sep 20, 2024

@NeckBeardPrince

Hmmm interesting, I just installed 15.1. Are you saying that on 15.0 you should no longer have this issue, and you don't need to run scutil --set HostName bar anymore? Or that you still do need to, even if on 15.0?

  • MacOS before 15.0: Send "local hostname" (configurable in settings) to DHCP server hostname, potentially assigned a name like "mylocalhostname.foo.example.com" or "mylocalhostname.something.else.if.dhcpserver.decides.it.example.com".
  • MacOS on 15.0 and later: Send a generic hardware name ("MacBookPro") to the DHCP server as the hostname, now assigned "MacBookPro.foo.example.com" or "MacBookPro.something.else.if.dhcpserver.decides.it.example.com".

In both cases (before 15.0 and on 15.0 and later) its desirable to use scutil --set HostName bar to get a fixed hostname from the hostname command/function so that atuin has a consistent idea about what host one is running commands (given the current use of hostname for this. Probably, there should be some unique identifier used that isn't the hostname but is generated on initialization of atuin or obtained from the system itself).

Updating to MacOS 15.0 from something before 15.0 will change the hostname in many cases, causing atuin after the upgrade to potentially believe the host is different (because the hostname changed), and Host searches in atuin will return a new/different list of commands. And if on MacOS 15.0 and later, it's more likely that if someone has multiple computers, atuin (due to hostname stuff) might consider them to be the same/different computer depending on which gets their hostname assignment first.

I noticed this issue (in #2391) because it showed up for me more clearly after the macos upgrade to 15.0.

You can check if this is what you're seeing here by seeing what hostname returns and then examining the history.db for entires in the hostname column with different hostname variations/suffixes.

@NeckBeardPrince
Copy link
Author

@NeckBeardPrince

Hmmm interesting, I just installed 15.1. Are you saying that on 15.0 you should no longer have this issue, and you don't need to run scutil --set HostName bar anymore? Or that you still do need to, even if on 15.0?

* MacOS before 15.0: Send "local hostname" (configurable in settings) to DHCP server hostname, potentially assigned a name like "mylocalhostname.foo.example.com" or "mylocalhostname.something.else.if.dhcpserver.decides.it.example.com".

* MacOS on 15.0 and later: Send a generic hardware name ("MacBookPro") to the DHCP server as the hostname, now assigned "MacBookPro.foo.example.com" or "MacBookPro.something.else.if.dhcpserver.decides.it.example.com".

In both cases (before 15.0 and on 15.0 and later) its desirable to use scutil --set HostName bar to get a fixed hostname from the hostname command/function so that atuin has a consistent idea about what host one is running commands (given the current use of hostname for this. Probably, there should be some unique identifier used that isn't the hostname but is generated on initialization of atuin or obtained from the system itself).

Updating to MacOS 15.0 from something before 15.0 will change the hostname in many cases, causing atuin after the upgrade to potentially believe the host is different (because the hostname changed), and Host searches in atuin will return a new/different list of commands. And if on MacOS 15.0 and later, it's more likely that if someone has multiple computers, atuin (due to hostname stuff) might consider them to be the same/different computer depending on which gets their hostname assignment first.

I noticed this issue (in #2391) because it showed up for me more clearly after the macos upgrade to 15.0.

You can check if this is what you're seeing here by seeing what hostname returns and then examining the history.db for entires in the hostname column with different hostname variations/suffixes.

Well, you're entirely correct. I just checked the sqlite db and in the hostname column and the hostname for the same laptop has indeed changed several times! So, I guess the next steps would be to run the scutil --set HostName command then purge my Atuin database and then do a new import from my ~/.zsh_history.

@NeckBeardPrince
Copy link
Author

@NeckBeardPrince

Hmmm interesting, I just installed 15.1. Are you saying that on 15.0 you should no longer have this issue, and you don't need to run scutil --set HostName bar anymore? Or that you still do need to, even if on 15.0?

* MacOS before 15.0: Send "local hostname" (configurable in settings) to DHCP server hostname, potentially assigned a name like "mylocalhostname.foo.example.com" or "mylocalhostname.something.else.if.dhcpserver.decides.it.example.com".

* MacOS on 15.0 and later: Send a generic hardware name ("MacBookPro") to the DHCP server as the hostname, now assigned "MacBookPro.foo.example.com" or "MacBookPro.something.else.if.dhcpserver.decides.it.example.com".

In both cases (before 15.0 and on 15.0 and later) its desirable to use scutil --set HostName bar to get a fixed hostname from the hostname command/function so that atuin has a consistent idea about what host one is running commands (given the current use of hostname for this. Probably, there should be some unique identifier used that isn't the hostname but is generated on initialization of atuin or obtained from the system itself).
Updating to MacOS 15.0 from something before 15.0 will change the hostname in many cases, causing atuin after the upgrade to potentially believe the host is different (because the hostname changed), and Host searches in atuin will return a new/different list of commands. And if on MacOS 15.0 and later, it's more likely that if someone has multiple computers, atuin (due to hostname stuff) might consider them to be the same/different computer depending on which gets their hostname assignment first.
I noticed this issue (in #2391) because it showed up for me more clearly after the macos upgrade to 15.0.
You can check if this is what you're seeing here by seeing what hostname returns and then examining the history.db for entires in the hostname column with different hostname variations/suffixes.

Well, you're entirely correct. I just checked the sqlite db and in the hostname column and the hostname for the same laptop has indeed changed several times! So, I guess the next steps would be to run the scutil --set HostName command then purge my Atuin database and then do a new import from my ~/.zsh_history.

Looks like LocalHostName and HostName are different. I ended up setting them both to the same thing.

❯ scutil --get LocalHostName
Adams-MacBook-Pro
❯ scutil --set HostName Adams-MRI-MacBook-Pro
❯ scutil --get LocalHostName
Adams-MacBook-Pro
❯ scutil --set HostName Adams-MRI-MacBook-Pro
❯ scutil --get LocalHostName
Adams-MacBook-Pro
❯ scutil --get HostName
Adams-MRI-MacBook-Pro
❯ scutil --set LocalHostName Adams-MRI-MacBook-Pro
❯ scutil --get LocalHostName
Adams-MRI-MacBook-Pro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants