rstudio / pins-r

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

Cannot rewrite a pin that was deleted in the web interface #634

Closed dewoller closed 2 years ago

dewoller commented 2 years ago

This is a problem born of success. We have too many versioned pins, and we need to change them to unversioned, as they are taking over the server. If we delete the pins programmatically, using pin_delete, it works fine, but if we delete the pins using the web interface, that pin namespace is broken, and cannot be used again. Annoying to have to rename a heap of pins. This might be related to #539 , as it is the same server with the somewhat broken Azure firewall in between. Here is the code:

This code works

library(dplyr)
library( pins )
rsconnect_board = pins::board_register_rsconnect()

iris %>% pin( board='rsconnect', name='dennis.wollersheim/test5')
pin_delete( board=rsconnect_board, name='dennis.wollersheim/test5')
iris %>% pin_write( board=rsconnect_board, name='dennis.wollersheim/test5', versioned=FALSE)

This code, followed by a manual web interface deletion, makes all attempts to rewrite this pin name fail. I have learned my lesson, but on a side note, is there anyway to reclaim this pin namespace?

library(dplyr)
library( pins )
rsconnect_board = pins::board_register_rsconnect()

iris %>% pin( board='rsconnect', name='dennis.wollersheim/test5')

Using pins_1.0.1.9000 , RSC 2022.07.0

Full error and traceback follows:


r$> iris %>% pin_write( board=rsconnect_board, name='dennis.wollersheim@XXXX/test5', versioned=FALSE)
Guessing `type = 'rds'`
Error in `rsc_check_status()`:
! RStudio Connect API failed [404]
* The requested object does not exist.
Run `rlang::last_error()` to see where the error occurred.

r$> rlang::last_error()
<error/rlang_error>
Error in `rsc_check_status()`:
! RStudio Connect API failed [404]
* The requested object does not exist.
---
Backtrace:
  1. iris %>% ...
  2. pins::pin_write(...)
  4. pins:::pin_store.pins_board_rsconnect(...)
  9. pins:::rsc_content_update(board, guid, metadata, access_type = access_type)
 10. pins:::rsc_PATCH(board, rsc_v1("content", guid), body = body)
 11. pins:::rsc_POST(...)
 12. pins:::rsc_check_status(req)
Run `rlang::last_trace()` to see the full context.

r$> rlang::last_trace()
<error/rlang_error>
Error in `rsc_check_status()`:
! RStudio Connect API failed [404]
* The requested object does not exist.
---
Backtrace:
     x
  1. +-iris %>% ...
  2. \-pins::pin_write(...)
  3.   +-pins::pin_store(...)
  4.   \-pins:::pin_store.pins_board_rsconnect(...)
  5.     +-base::tryCatch(...)
  6.     | \-base (local) tryCatchList(expr, classes, parentenv, handlers)
  7.     |   \-base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  8.     |     \-base (local) doTryCatch(return(expr), name, parentenv, handler)
  9.     \-pins:::rsc_content_update(board, guid, metadata, access_type = access_type)
 10.       \-pins:::rsc_PATCH(board, rsc_v1("content", guid), body = body)
 11.         \-pins:::rsc_POST(...)
 12.           \-pins:::rsc_check_status(req)
 13.             \-rlang::abort(...)

r$>

Using old pins API


r$> iris %>% pin( board='rsconnect', name='dennis.wollersheim@XXXX/test5')
Error in `rsc_check_status()`:
! RStudio Connect API failed [404]
* The requested object does not exist.
Run `rlang::last_error()` to see where the error occurred.

r$> traceback()
19: stop(fallback)
18: signal_abort(cnd, .file)
17: abort(c(paste0("RStudio Connect API failed [", req$status_code,
        "]"), json$error))
16: rsc_check_status(req)
15: rsc_POST(board, path, query = query, body = body, ..., .method = "PATCH")
14: rsc_PATCH(board, rsc_v1("content", guid), body = body)
13: rsc_content_update(board, guid, metadata, access_type = access_type)
12: doTryCatch(return(expr), name, parentenv, handler)
11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
10: tryCatchList(expr, classes, parentenv, handlers)
9: tryCatch({
       guid <- rsc_content_find(board, name, warn = FALSE)$guid
       rsc_content_update(board, guid, metadata, access_type = access_type)
       guid
   }, pins_pin_missing = function(e) {
       rsc_content_create(board, name, metadata, access_type = access_type)$guid
   })
8: pin_store.pins_board_rsconnect(board = board, name = name, paths = path,
       metadata = metadata, ...)
7: pin_store(board = board, name = name, paths = path, metadata = metadata,
       ...)
6: board_pin_create.pins_board_rsconnect(board, store_path, name = name,
       metadata = metadata, ...)
5: board_pin_create(board, store_path, name = name, metadata = metadata,
       ...)
4: board_pin_store(board, path, name, metadata, ...)
3: pin.data.frame(., board = "rsconnect", name = "dennis.wollersheim@XXXX/test5")
2: pin(., board = "rsconnect", name = "dennis.wollersheim@XXXX/test5")
1: iris %>% pin(board = "rsconnect", name = "dennis.wollersheim@XXXX/test5")
machow commented 2 years ago

Thanks for reporting this issue--it looks like this is an issue with the RSConnect board's content cache:

https://github.com/rstudio/pins-r/blob/main/R/board_rsconnect.R#L393-L400

In brief, with RSCconnect boards, pin keeps a file mapping content name to an underlying identifier (guid). However, when changes are made from other places (other users' laptops, web UI) the cache goes stale (does not reflect reality).

juliasilge commented 2 years ago

Related to #635

Have you tried these steps to clear your cache @dewoller?

dewoller commented 2 years ago

Julia!! You da best. Problem solved, cache cleaned, pin namespace reclaimed. Life is good. Thanks

github-actions[bot] commented 2 years 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.