summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Davis <joseph.davis@suse.com>2019-02-28 15:06:45 -0800
committerJoseph Davis <joseph.davis@suse.com>2019-02-28 23:21:54 +0000
commit6ea3df4d86a058dfc4aff4f9f01ff399a07228ab (patch)
treee13020d1ba8ed0a0012d4594febc81dcc3fcf679
parentb554dc3e29c780d037050c9b92d169b2a134ab4b (diff)
downloadceilometer-6ea3df4d86a058dfc4aff4f9f01ff399a07228ab.tar.gz
Change sample id from int to BigInt
For long running users of Ceilometer with heavy sample loads, the index for samples can run out of numbers. The int type only allows over 2 billion samples to be loaded. To allow a user with database backed sample storage (postgres or mysql) to continue to operate, we need to up the data type to BigInteger. Change-Id: I9ed1d69a05efd47368497674ffe68b43c8dc1074
-rw-r--r--ceilometer/storage/sqlalchemy/migrate_repo/versions/046_sample_id_to_bigint.py21
-rw-r--r--ceilometer/storage/sqlalchemy/models.py2
2 files changed, 22 insertions, 1 deletions
diff --git a/ceilometer/storage/sqlalchemy/migrate_repo/versions/046_sample_id_to_bigint.py b/ceilometer/storage/sqlalchemy/migrate_repo/versions/046_sample_id_to_bigint.py
new file mode 100644
index 00000000..4300a631
--- /dev/null
+++ b/ceilometer/storage/sqlalchemy/migrate_repo/versions/046_sample_id_to_bigint.py
@@ -0,0 +1,21 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from sqlalchemy import BigInteger
+from sqlalchemy import MetaData
+from sqlalchemy import Table
+
+
+def upgrade(migrate_engine):
+ meta = MetaData(bind=migrate_engine)
+ sample = Table('sample', meta, autoload=True)
+ sample.c.id.alter(type=BigInteger)
diff --git a/ceilometer/storage/sqlalchemy/models.py b/ceilometer/storage/sqlalchemy/models.py
index 386d7361..ac82b26e 100644
--- a/ceilometer/storage/sqlalchemy/models.py
+++ b/ceilometer/storage/sqlalchemy/models.py
@@ -220,7 +220,7 @@ class Sample(Base):
Index('ix_sample_meter_id_resource_id', 'meter_id', 'resource_id'),
_COMMON_TABLE_ARGS,
)
- id = Column(Integer, primary_key=True)
+ id = Column(BigInteger, primary_key=True)
meter_id = Column(Integer, ForeignKey('meter.id'))
resource_id = Column(Integer, ForeignKey('resource.internal_id'))
volume = Column(Float(53))