rstudio / pins-r

Pin, discover, and share resources
https://pins.rstudio.com
Other
312 stars 63 forks source link

"Data rewind wasn't possible" #794

Closed erdnaxel closed 5 months ago

erdnaxel commented 11 months ago

I have a script in which I read a pin, make changes to the data and then write the new data to the same pin.

I sometimes get the message: "Error in curl::curl_fetch_memory(url, handle = handle) : necessary data rewind wasn't possible"

If I run the same pin_write line again, it works.

(I don't know how to make this a reproducible example. I have many scripts that operate on the same idea and that don't get this error. Even in this script, the error sometimes occur and sometimes doesn't.)

juliasilge commented 11 months ago

I believe this may be related to #762.

Is this on Posit Connect? Or a different backend? If so, is there a chance the server you use in board_connect() now redirects?

erdnaxel commented 11 months ago

It's Posit Connect, but my organization has its own server -- if that makes sense.

I use board_rsconnect() to connect.

I thought of maybe disconnecting and reconnecting before saving the new data, to reset everything, but I didn't find a function to disconnect.

juliasilge commented 11 months ago

Definitely makes sense that your org has its own Connect server! Could you ask the folks who maintain your server if:

We have observed both of those things to cause a "data rewind" curl error. If it's intermittent, that makes me think maybe it could be a proxy problem.

erdnaxel commented 11 months ago

i stumbled on the cause of my problem. i had accidentally included the directory in the name of the pin ("username/table_name" instead of just "table_name"). i'm guessing the special character was causing the issue, even though it would still save (unreliably). once i gave the table a proper name, everything worked well.

it be worth adding adding a warning if the name includes forbidden characters.

juliasilge commented 11 months ago

Hmmmm @erdnaxel are you saying that the problem crops up when you include your username, like "julia.silge" here?

library(pins)

b <- board_connect()
#> Connecting to Posit Connect 2023.07.0 at <https://colorado.posit.co/rsc>
b |> pin_write(
    sample(1:100, 10), 
    "julia.silge/snazzy_numbers", 
    type = "json"
)
#> Writing to pin 'julia.silge/snazzy_numbers'

Created on 2023-10-30 with reprex v2.0.2

We definitely expect that to work and in fact recommend including your username when storing pins to Connect.

Or did you mean something else by "special character"?

erdnaxel commented 11 months ago

ah, the plot thickens!

so the way that works for me is when i save using just the name of the table.

board_rsc %>% pin_write(table_to_save, "name_of_the_table")

when i save like that, it automatically puts it in my directory (username) and everything works well.

when i read the table, i have to put the directory so it knows where to look:

table <- board_rsc %>% pin_read("username/name_of_the_table")

the issue arose when i included the username while saving (which i did because i'm used to including it when reading).

board_rsc %>% pin_write(table_to_save, "username/name_of_the_table")

when i logged onto the web interface to look at my tables, i noticed that the name on the table on the server was username/name_of_the_table instead of just name_of_the_table.

by special character, i meant the forward slash. i thought that might be causing the issue, but based on what you said, that shouldn't create the issue.

juliasilge commented 11 months ago

Yeah, the forward slash definitely should be fine and we generally recommend including the username. It is true that right now, when you write, it will write to different pins, which is not great. I'll open another issue on that.

Were you able to look into any of these possibilities?

Definitely makes sense that your org has its own Connect server! Could you ask the folks who maintain your server if:

  • there are redirects for your server?
  • there is a proxy in front of your server?

We have observed both of those things to cause a "data rewind" curl error. If it's intermittent, that makes me think maybe it could be a proxy problem.

Intermittent problems can be super hard to find but we've definitely had reports of other "data rewind" errors.

juliasilge commented 11 months ago

I had one more thought here. Folks have gotten into trouble with the Connect user and content caches that pins used to use. If you install from GitHub, you'll get a version which (although slightly slower in some circumstances) will have fewer surprising failures. You might try using the development version to see if that avoids your intermittent problem:

pak::pak("rstudio/pins-r")
juliasilge commented 5 months ago

Let us know if you have further questions! 🙌

erdnaxel commented 5 months ago

Ah, sorry, I thought I had closed the loop on this, but I realize I hadn't.

I got a new laptop for work, so I had to reinstall packages, including the latest version of pins, and all the problems went away. The updated version of pins recommends using the username in the name of the pin, which I've done, and everything works well now.

github-actions[bot] commented 4 months ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.