tnederlof commented on issue #15056:
URL: https://github.com/apache/arrow/issues/15056#issuecomment-1380574397

   @cgostic Thank you for posting some code and data to try and replicate. I 
was able to run into similar segfault issues without including the 
`reactivePoll()` piece. Most of the time, when we see segfault memory-related 
issues it is not on the Connect side but on the application side, which makes 
me think it's related to the `arrow::open_dataset()` function call being 
outside the server.
   
   Could you please try moving it into the server? When I made the switch and 
redeployed I have been unable to run into any of the memory errors, this way it 
will open the dataset when needed (reactive is triggered) rather than leaving 
it open and across connections. For reference the code I am using is below:
   
   ```
   # See attached lockfile for package versions
   library(shiny)
   library(dplyr)
   library(ggplot2)
   library(htmltools)
   library(arrow)
   library(aws.s3)
   
   aqs_site_code_unique <- c(51190007L, 60658001L, 60731022L, 100032004L, 
110010043L, 120110034L, 
                             120573002L, 130890002L, 170314201L, 180970078L, 
295100085L, 371190041L, 
                             371830014L, 420030008L, 440071010L, 510870014L, 
20900034L, 40191028L, 
                             60270002L, 60850005L, 121290001L, 150030010L, 
170191001L, 191630015L, 
                             230090103L, 300490004L, 310550019L, 340130003L, 
360551007L, 380150003L, 
                             380171004L, 391351001L, 470090101L, 10730023L, 
40139997L, 60371103L, 
                             60670006L, 202090021L, 260810020L, 270031002L, 
320030540L, 330150018L, 
                             390350060L, 390610040L, 410510080L, 421010048L, 
471570075L, 482011039L, 
                             490353006L, 530330080L, 60190011L, 80310026L, 
90050005L, 90090027L, 
                             160010010L, 220330009L, 240230002L, 240330030L, 
250250042L, 280490020L, 
                             330115001L, 350010023L, 360810124L, 361010003L, 
401431127L, 450790007L, 
                             481410044L, 500070007L, 530090013L, 540390020L, 
560210100L, 720210010L, 
                             320310031L, 400019009L)
   
   ui <- fluidPage(
     fluidRow(column(3,
                     selectInput('sitecode',
                                 label = 'Select Site',
                                 choices = aqs_site_code_unique,
                                 selected = NULL)),
              column(2,
                     div(style = 'padding-top:26px',
                         actionButton('go', 'Create Plot', width = '100%')))),
     fluidRow(plotOutput('TS')),
     
   )
   
   server <- function(input, output, session) {
     
     selected_site <- reactiveValues(sitecode = NULL)
     
     observeEvent(input$go, {
       selected_site$sitecode <- input$sitecode
     })
     
     plot_data <- reactive({
       req(selected_site$sitecode)
       
       s <- as.integer(selected_site$sitecode)
       
       
       bname <- 'BUCKETNAMEHERE'
       db_uri <- paste0('s3://', bname)
       ds <- arrow::open_dataset(db_uri, format = 'arrow', unify_schemas = F)
       ds %>%
         filter(parameter == 'Ozone',
                sample_duration == '1 HOUR',
                poc == 1) %>%
         select(aqs_sitecode, date_time2, sample_measurement) %>%
         collect()
     })
     
     output$TS <- renderPlot({
       req(selected_site$sitecode, 
           is.data.frame(plot_data()))
       
       ggplot(subset(plot_data(), aqs_sitecode == selected_site$sitecode)) +
         geom_line(aes(date_time2, sample_measurement)) +
         scale_x_datetime() +
         labs(x = 'DateTime', y = 'Ozone in ppb', main = selected_site$sitecode)
     })
   }
   
   shinyApp(ui = ui, server = server)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to