axlsx icon indicating copy to clipboard operation
axlsx copied to clipboard

Fix Relationship.instances cache.

Open marshall-lee opened this issue 7 years ago • 13 comments

This PR aims to fix several issues with Relationship cache:

  1. It's not threadsafe, so I propose to use a TLS variable for this.
  2. Memory obtained by cache remains non-freed before the next run of serialize. I think it should be freed immediately.
  3. Memory should be freed in ensure block to prevent memory bloating in case of exception.

There are only two hard things in Computer Science: cache invalidation and naming things.

marshall-lee avatar Aug 03 '16 09:08 marshall-lee

Hmm, fails only on Ruby 1.9

marshall-lee avatar Aug 03 '16 09:08 marshall-lee

@marshall-lee would you be kind enough to rebase and add specs for your changes?

randym avatar Nov 03 '16 01:11 randym

@marhall-lee are you still interested in solving this problem?

randym avatar May 09 '17 14:05 randym

Ran into this problem today. Luckly I was able to fork the master branch and apply this patch to make axlsx work asynchronously with Sidekiq. EDIT: Unfortunately this didn't solved my thread problems completely =/

guilpejon avatar Jun 14 '18 20:06 guilpejon

@marshall-lee do you mind applying a rebase on the current master-branch to trigger a fresh travis-ci build?l

loybert avatar Mar 08 '19 15:03 loybert

@randym @loybert I rebased the branch and added a couple of tests.

marshall-lee avatar Mar 09 '19 15:03 marshall-lee

I also rewrote the cache to use the hash table instead of array. And also there's no need to store relationship instances — storing just ids is enough.

marshall-lee avatar Mar 09 '19 16:03 marshall-lee

@marshall-lee awesome! thanks for the fast feedback @randym anything missing from your side?

loybert avatar Mar 11 '19 12:03 loybert

This PR fixes the thread safety issues we've had with the gem. Hoping this one can be merged soon!

mtoneil avatar Jul 04 '19 13:07 mtoneil

ping @randym

marshall-lee avatar Jul 09 '19 08:07 marshall-lee

@marshall-lee thank you! :)

delphaber avatar Jul 10 '19 05:07 delphaber

@marshall-lee Thanks a lot for working on this! Would you like to recreate this pull request in https://github.com/caxlsx/caxlsx/ ? I think this is an important fix and we should definitively get this merged.

noniq avatar Dec 15 '19 16:12 noniq

Oh my, I just realized that this has already been done in https://github.com/caxlsx/caxlsx/pull/10 🤦‍♂️ Sorry for the noise.

To minimize this kind of confusion in the future I created and new label “Done in caxlsx” that can be applied to prs / issues that have been included in caxlsx.

noniq avatar Dec 15 '19 16:12 noniq