virgodb 0.3.0-x86_64-linux-gnu → 0.4.2-x86_64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6141e1a5628b4293f7d63bd3143fe20bcbff6f697df38fc67c1da4c2669369ab
4
- data.tar.gz: 7814e9e3a10ba0ce4e5126e492d38410637aa818d21abb4352b6f038fc9b4139
3
+ metadata.gz: c1f9d93ae7a3e693c2d7f2d7ba19a30ea89a3e54c53c7e9ab604eadc3afe3eda
4
+ data.tar.gz: c25d394c1ee0e2554abebdbcc58233f6fb13a816b8676e916861511e8689f81a
5
5
  SHA512:
6
- metadata.gz: '0468833ba6f07aed2d56ea13ca5d158a523fb64486ec4fa5259c969200f9c4e991fb96a545ad26a78c8531460855c59dcbcc0904be5a8d43f558dd2bb4f27255'
7
- data.tar.gz: 475c654f9a604b83c05b0036c4cdffb478c339b05fb794a9cef445b5244584394cef90289bbb57cdc8f7c65a8918fb7a8111e545d9a790c6b375eca454929a47
6
+ metadata.gz: bc0fce13a70b6de835b7ad1077520915ef5baacaa48b7bacc69cfe35607de9e9e5be1e717e0fa3a9e654c5a8d0f7624cb4be8c6db7b957ca7026842c498b8b1e
7
+ data.tar.gz: bc9891ee73cffeb89a56f2512cc8047af9779cdac1c3b6671a4c542c2c38ed29eb8e337831c78e6aa72ed911dfc537de2f0a2cbc1090a30c8c6681506321fd8c
data/lib/virgodb/table.rb CHANGED
@@ -4,7 +4,8 @@ require "json"
4
4
  require "fileutils"
5
5
 
6
6
  module Virgodb
7
- # A memoized Writer + its maintenance thread, both created lazily on first
7
+ # A memoized Writer + its maintenance thread + its periodic flush timer
8
+ # (see `ensure_flush_timer_started` below), all created lazily on first
8
9
  # use -- not eagerly at process boot, since Writer.new and
9
10
  # Virgodb.start_maintenance both raise if this table hasn't been migrated
10
11
  # yet, and eager init would crash the whole process on that instead of
@@ -44,6 +45,7 @@ module Virgodb
44
45
  @tuning = tuning
45
46
  @mutex = Mutex.new
46
47
  @maintenance_started = false
48
+ @flush_timer_started = false
47
49
  end
48
50
 
49
51
  attr_reader :manifest_path
@@ -124,6 +126,18 @@ module Virgodb
124
126
  Virgodb.release_maintenance_lease(@manifest_path, @sql_table_name, holder.to_s)
125
127
  end
126
128
 
129
+ # Extends a lease claimed via `claim_maintenance_lease` above without
130
+ # needing it to expire first -- calling `claim_maintenance_lease` again
131
+ # on a lease you already validly hold is a guaranteed no-op, not a
132
+ # renewal (see `Manifest::renew_maintenance_lease`'s own doc comment).
133
+ # For a caller whose work under the lease might run longer than one
134
+ # fixed grant. Returns `false` (not an error) if `holder` no longer
135
+ # matches the current holder -- treat that as "lost the lease," not
136
+ # something to retry blindly.
137
+ def renew_maintenance_lease(holder:, lease_duration_secs:)
138
+ Virgodb.renew_maintenance_lease(@manifest_path, @sql_table_name, holder.to_s, lease_duration_secs)
139
+ end
140
+
127
141
  private
128
142
 
129
143
  def writer
@@ -132,6 +146,7 @@ module Virgodb
132
146
 
133
147
  def build_writer
134
148
  ensure_maintenance_started
149
+ ensure_flush_timer_started
135
150
  Virgodb::Writer.new(@manifest_path, @sql_table_name, @tier1_max_rows, @tier1_max_age_secs, @data_dir)
136
151
  end
137
152
 
@@ -142,5 +157,41 @@ module Virgodb
142
157
  Virgodb.start_maintenance(@manifest_path, @sql_table_name, @data_dir, @key_column, @sort_by, @tuning, @partition_column)
143
158
  @maintenance_started = true
144
159
  end
160
+
161
+ # Periodically force-flushes this table's Tier 1 buffer on a real
162
+ # timer, independent of write traffic -- see `Writer#write_row`'s own
163
+ # doc comment (crates/virgodb_ruby/src/writer.rs) for the full
164
+ # reasoning: write_row's inline flush only fires on the ROW-COUNT half
165
+ # of tier1_max_rows/tier1_max_age_secs, not age, because an actual
166
+ # flush fsyncs (storage::write_inline_file) and checking age inline
167
+ # meant whichever request happened to cross that threshold paid for a
168
+ # real disk sync on its own thread -- under low/sparse traffic, that
169
+ # was effectively every request. This background thread is what makes
170
+ # tier1_max_age_secs a real wall-clock bound again, off any caller's
171
+ # own thread -- moved here (not left to each host app to build its
172
+ # own copy) so every consumer of this gem gets the same guarantee
173
+ # write_row itself no longer provides alone.
174
+ #
175
+ # Uses `flush!` (force-flush regardless of policy) through the SAME
176
+ # `@mutex` write_row/tombstone already use -- a Ruby Thread cooperates
177
+ # correctly with that lock, unlike a Rust-native thread would (the
178
+ # underlying Writer's RefCell isn't safe for genuine concurrent access
179
+ # outside Ruby's own GVL/Mutex protection -- see this class's own doc
180
+ # comment above). No locking needed around @flush_timer_started itself:
181
+ # this method only ever runs from inside build_writer, which only ever
182
+ # runs once per instance, already inside `writer`'s own @mutex-guarded
183
+ # lazy-init (`@writer ||= build_writer`).
184
+ def ensure_flush_timer_started
185
+ return if @flush_timer_started
186
+
187
+ @flush_timer_started = true
188
+ Thread.new { loop { sleep(@tier1_max_age_secs); flush_timer_tick } }
189
+ end
190
+
191
+ def flush_timer_tick
192
+ flush!
193
+ rescue => e
194
+ warn "[virgodb] #{@sql_table_name} periodic flush failed: #{e.class}: #{e.message}"
195
+ end
145
196
  end
146
197
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Virgodb
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.2"
5
5
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virgodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.2
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
7
  - virgodb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-02 00:00:00.000000000 Z
11
+ date: 2026-09-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Embeds virgodb (an OLAP engine backed by Parquet + DataFusion) directly into a Ruby process